Invalidate cached session payloads on notification preferences update; enhance flag tab filtering logic

This commit is contained in:
Jeppe Bundgaard
2026-06-08 18:40:15 +02:00
parent 4fc66c72b8
commit cd100f1180
5 changed files with 143 additions and 19 deletions
@@ -398,12 +398,18 @@ class InvoicingPeriodRoute
$limit = min(500, $limit);
}
$allowedFlagTabs = ['all' => true, 'red' => true, 'yellow' => true, 'none' => true, 'filters' => true];
$flagTab = trim((string)($parameters['flagTab'] ?? 'all'));
if ($flagTab === '' || !isset($allowedFlagTabs[$flagTab])) {
$flagTab = 'all';
}
return [
'periodView' => $periodView,
'page' => $page,
'limit' => $limit,
'search' => trim((string)($parameters['search'] ?? '')),
'flagTab' => trim((string)($parameters['flagTab'] ?? 'all')),
'flagTab' => $flagTab,
'includeRequiresAction' => self::parsePeriodBooleanOption(
$parameters['includeRequiresAction'] ?? null,
true
@@ -506,25 +512,11 @@ class InvoicingPeriodRoute
$types[$viewName] = array_values(array_filter(
is_array($entries) ? $entries : [],
static function (array $customer) use ($flagTab): bool {
$hasManual = false;
$hasAutomatic = false;
if (is_array($customer['flags'] ?? null)) {
foreach ($customer['flags'] as $flag) {
if (!empty($flag['order_id']) || !empty($flag['invoice_collection_id'])) {
continue;
}
if ($flag['is_manual'] ?? ($flag['source'] ?? '') === 'manual') {
$hasManual = true;
} else {
$hasAutomatic = true;
}
}
}
$tab = 'none';
if ($hasManual) {
$flagCounts = self::getActivePeriodFlagCounts($customer);
if ($flagCounts['manual'] > 0) {
$tab = 'red';
} elseif ($hasAutomatic) {
} elseif ($flagCounts['automatic'] > 0) {
$tab = 'yellow';
}