fix(view): minor label fix for pay-period

This commit is contained in:
Matthieu Haineault 2025-07-28 16:09:36 -04:00
parent 32201f0dba
commit 44b064b87f

View File

@ -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