From 44b064b87fcfa1b2ac71d1248f2b7441d11513e2 Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Mon, 28 Jul 2025 16:09:36 -0400 Subject: [PATCH] fix(view): minor label fix for pay-period --- .../migration.sql | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/prisma/migrations/20250724191659_create_pay_period_view/migration.sql b/prisma/migrations/20250724191659_create_pay_period_view/migration.sql index 08696ac..2319d74 100644 --- a/prisma/migrations/20250724191659_create_pay_period_view/migration.sql +++ b/prisma/migrations/20250724191659_create_pay_period_view/migration.sql @@ -7,13 +7,23 @@ WITH anchor AS ( SELECT '2023-12-17'::date AS anchor_date ), + current_pay_period AS( + SELECT + ((now()::date - anchor_date) % 14) +1 AS current_day_in_pay_period + FROM anchor + ), bounds AS ( SELECT - --ajouter vérification de la période actuel, validations et revoir la logique - (now()::date - INTERVAL '6 months')::date AS start_bound, - (now()::date + INTERVAL '1 month')::date AS end_bound, + (now()::date + - INTERVAL '6 months' + - (current_day_in_pay_period || ' days')::INTERVAL + )::date AS start_bound, + (now()::date + INTERVAL '1 month' + - (current_day_in_pay_period || ' days')::INTERVAL + )::date AS end_bound, anchor.anchor_date FROM anchor + CROSS JOIN current_pay_period ), series AS ( SELECT @@ -26,7 +36,7 @@ SELECT period_start AS start_date, period_start + INTERVAL '13 days' AS end_date, EXTRACT(YEAR FROM period_start)::int AS year, - period_start || ' → ' || + period_start || ' -> ' || to_char(period_start + INTERVAL '13 days', 'YYYY-MM-DD') AS label FROM series