Fix invoice period flag cache fallbacks

This commit is contained in:
Jeppe B
2026-06-01 23:29:05 +02:00
parent 7cb248a112
commit bd7deaeded
3 changed files with 99 additions and 25 deletions
@@ -21,6 +21,31 @@ function invoice_period_flag_service_invoke(string $method, array $args = []): m
return $target->invokeArgs($service, $args);
}
it('normalizes invoice period date ranges to full-day timestamps before cache-backed reads', function (): void {
expect(invoice_period_flag_service_invoke('normalizePeriodDateRange', ['2025-03-01', '2025-03-31']))
->toBe(['2025-03-01 00:00:00', '2025-03-31 23:59:59']);
expect(invoice_period_flag_service_invoke('normalizePeriodDateRange', [
'2025-03-01 00:00:00',
'2025-03-31 23:59:59',
]))->toBe(['2025-03-01 00:00:00', '2025-03-31 23:59:59']);
});
it('canonicalizes invoice period redis keys for bare dates and normalized API timestamps', function (): void {
$reflection = new ReflectionClass(\classes\redis::class);
$redis = $reflection->newInstanceWithoutConstructor();
$key = $reflection->getMethod('invoicePeriodCacheKey');
$key->setAccessible(true);
expect($key->invoke($redis, 'invoice_period_automatic_flags', '2025-03-01', '2025-03-31'))
->toBe($key->invoke(
$redis,
'invoice_period_automatic_flags',
'2025-03-01 00:00:00',
'2025-03-31 23:59:59'
));
});
it('builds deterministic automatic flag fingerprints and interactive price message parts', function (): void {
$row = [
'customer_number' => 424242,