Add invoice_period_flag_ classes to manage invoice period flags with schema, services, and flag lifecycle methods

- Introduced `invoice_period_flag_schema_bootstrap` to initialize the schema for invoice period flags.
- Added `invoice_period_flag_service` to handle manual and automatic flag creation, updates, filtering, and context resolution.
- Implemented lifecycle methods such as `createManualFlag`, `updateAutomaticFlagStatus`, and `applyFlagsToPeriodTypes` for handling invoice period flags and their usage in processing periods.
- Included context-specific resolution methods for efficient flag management in invoicing workflows.
This commit is contained in:
Jeppe Bundgaard
2026-05-11 21:34:57 +02:00
parent 6d4066be1c
commit c1b66a81cc
13 changed files with 2777 additions and 7 deletions
@@ -141,6 +141,21 @@ class xlvask_usage_log extends xlvask_helper
* @see xlvask_wash_item
*/
public array $WashItems;
/**
* Timestamp for invoice-period ignore state, when the wash has been ignored by a superuser.
* @var string|int|null $ignored_at
*/
public string|int|null $ignored_at;
/**
* Superuser id for invoice-period ignore state.
* @var int|string|null $ignored_by
*/
public int|string|null $ignored_by;
/**
* Optional reason for invoice-period ignore state.
* @var string|int|null $ignored_reason
*/
public string|int|null $ignored_reason;
private string $default_string = 'DEFAULT_STRING_1';
private string $default_int = 'DEFAULT_INT_1';
@@ -194,6 +209,9 @@ class xlvask_usage_log extends xlvask_helper
$this->CustomerGuid = $this->default_string;
$this->VehicleId = $this->default_string;
$this->WashItems = []; // Initialize as an empty array
$this->ignored_at = $this->default_string_nullable;
$this->ignored_by = $this->default_int_nullable;
$this->ignored_reason = $this->default_string_nullable;
}
/**
@@ -226,6 +244,9 @@ class xlvask_usage_log extends xlvask_helper
'FinishStatus' => $this->default_int,
'CustomerGuid' => $this->default_string,
'VehicleId' => $this->default_string,
'ignored_at' => $this->default_string_nullable,
'ignored_by' => $this->default_int_nullable,
'ignored_reason' => $this->default_string_nullable,
];
foreach ( $data as $key => $value ) {
if (property_exists(self::class, $key)) {
@@ -363,7 +384,8 @@ class xlvask_usage_log extends xlvask_helper
'WashId', 'CustomerId', 'Customer', 'VatNumber', 'Location',
'Hall', 'HallId', 'StartTime', 'FinishTime', 'RegistrationNumber',
'VehicleType', 'IdentificationType', 'IdentificationId', 'Info',
'Updated', 'Prepaid', 'FinishStatus', 'CustomerGuid', 'VehicleId'
'Updated', 'Prepaid', 'FinishStatus', 'CustomerGuid', 'VehicleId',
'ignored_at', 'ignored_by', 'ignored_reason',
];
foreach ( $properties as $property ) {
if ($this->isEmptyOrDefault($this->{$property})) {
@@ -639,4 +661,4 @@ class xlvask_usage_log extends xlvask_helper
// Check if the wash is prepaid
return !empty($this->Prepaid) && $this->Prepaid === 1; // Assuming 1 indicates a prepaid wash
}
}
}