2025-01-30 16:51:35 +01:00
|
|
|
/*
|
|
|
|
|
This macro returns a boolean value for dates depending on the current day of the month
|
|
|
|
|
|
|
|
|
|
Logic:
|
2025-05-15 14:10:27 +00:00
|
|
|
- If today is the 12th or later of the current month:
|
2025-01-30 16:51:35 +01:00
|
|
|
- Returns **False** for all dates within the current month.
|
|
|
|
|
- Returns **True** for dates before the current month.
|
2025-05-15 14:10:27 +00:00
|
|
|
- If today is before the 12th:
|
2025-01-30 16:51:35 +01:00
|
|
|
- Returns **False** for all dates within the current and previous month.
|
|
|
|
|
- Returns **True** for dates before the previous month.
|
|
|
|
|
|
|
|
|
|
*/
|
2025-05-15 14:10:27 +00:00
|
|
|
{% macro is_date_before_12th_of_previous_month(date) %}
|
2025-01-30 16:51:35 +01:00
|
|
|
(
|
|
|
|
|
case
|
2025-05-15 14:10:27 +00:00
|
|
|
-- If today is the 12th or later, only exclude current month
|
|
|
|
|
when extract(day from now()) >= 12
|
2025-01-30 16:51:35 +01:00
|
|
|
then
|
|
|
|
|
date_trunc('month', ({{ date }})::date)::date
|
|
|
|
|
< date_trunc('month', now())::date
|
2025-05-15 14:10:27 +00:00
|
|
|
-- If today is before the 12th, exclude both current and previous month
|
2025-01-30 16:51:35 +01:00
|
|
|
else
|
|
|
|
|
date_trunc('month', ({{ date }})::date)::date
|
|
|
|
|
< date_trunc('month', now() - interval '1 month')::date
|
|
|
|
|
end
|
|
|
|
|
)
|
|
|
|
|
{% endmacro %}
|