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
@@ -120,6 +120,46 @@ class xlvaskUsageLogsRoute
]
);
$this->patch('/modules/xlvask/services/usage/orders/{id}/ignore', function () {
global $db, $response;
$this->requirePermission('ignore_xlvask_usage_order');
$user = (new authentication())->get_user();
if (!$user) {
$response->error('Invalid session', 400);
return;
}
$id = (int)($this->fromRoute('id') ?? 0);
if ($id < 1) {
$response->error('Invalid XL Vask usage log id', 400);
return;
}
$reason = $this->isParametersSet(['reason']) ? trim((string)$this->getParameter('reason')) : null;
$reasonSql = $reason === null || $reason === ''
? 'NULL'
: "'" . $db->escape_string($reason) . "'";
(new xlvask_usage_logs_o())->structure();
$db->query(
"UPDATE xlvask_usage_logs
SET ignored_at = NOW(),
ignored_by = " . (int)$user->id . ",
ignored_reason = {$reasonSql}
WHERE id = {$id}"
);
$response->success([
'id' => $id,
'ignored' => true,
]);
},
[
'ignore_xlvask_usage_order' => 'Ignore an XL Vask usage log for invoice period flagging',
]
);
$this->get('/modules/xlvask/services/usage/orders/fast-link', function () {
global $response;
self::requireParameters([
@@ -204,4 +244,4 @@ class xlvaskUsageLogsRoute
]
);
}
}
}