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 ( anchor AS (
SELECT '2023-12-17'::date AS anchor_date 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 ( bounds AS (
SELECT SELECT
--ajouter vérification de la période actuel, validations et revoir la logique (now()::date
(now()::date - INTERVAL '6 months')::date AS start_bound, - INTERVAL '6 months'
(now()::date + INTERVAL '1 month')::date AS end_bound, - (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 anchor.anchor_date
FROM anchor FROM anchor
CROSS JOIN current_pay_period
), ),
series AS ( series AS (
SELECT SELECT
@ -26,7 +36,7 @@ SELECT
period_start AS start_date, period_start AS start_date,
period_start + INTERVAL '13 days' AS end_date, period_start + INTERVAL '13 days' AS end_date,
EXTRACT(YEAR FROM period_start)::int AS year, EXTRACT(YEAR FROM period_start)::int AS year,
period_start || ' ' || period_start || ' -> ' ||
to_char(period_start + INTERVAL '13 days', 'YYYY-MM-DD') to_char(period_start + INTERVAL '13 days', 'YYYY-MM-DD')
AS label AS label
FROM series FROM series