Merged PR 5215: Switch from 20th to 12th for invoicing cap

# Description

After a discussion with Nathan, the invoicing cycle has again been reduced by quite a few days.
We agreed to move the cap from 20th to 12th of the following month.

# Checklist

- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

Related work items: #30147
This commit is contained in:
Oriol Roqué Paniagua 2025-05-15 14:10:27 +00:00
parent ae9bb524b7
commit baf9d2767c
4 changed files with 15 additions and 15 deletions

View file

@ -2,23 +2,23 @@
This macro returns a boolean value for dates depending on the current day of the month This macro returns a boolean value for dates depending on the current day of the month
Logic: Logic:
- If today is the 20th or later of the current month: - If today is the 12th or later of the current month:
- Returns **False** for all dates within the current month. - Returns **False** for all dates within the current month.
- Returns **True** for dates before the current month. - Returns **True** for dates before the current month.
- If today is before the 20th: - If today is before the 12th:
- Returns **False** for all dates within the current and previous month. - Returns **False** for all dates within the current and previous month.
- Returns **True** for dates before the previous month. - Returns **True** for dates before the previous month.
*/ */
{% macro is_date_before_20th_of_previous_month(date) %} {% macro is_date_before_12th_of_previous_month(date) %}
( (
case case
-- If today is the 20th or later, only exclude current month -- If today is the 12th or later, only exclude current month
when extract(day from now()) >= 20 when extract(day from now()) >= 12
then then
date_trunc('month', ({{ date }})::date)::date date_trunc('month', ({{ date }})::date)::date
< date_trunc('month', now())::date < date_trunc('month', now())::date
-- If today is before the 20th, exclude both current and previous month -- If today is before the 12th, exclude both current and previous month
else else
date_trunc('month', ({{ date }})::date)::date date_trunc('month', ({{ date }})::date)::date
< date_trunc('month', now() - interval '1 month')::date < date_trunc('month', now() - interval '1 month')::date

View file

@ -55,11 +55,11 @@ where
( (
( (
-- Not show current + previous month if the metric depends on -- Not show current + previous month if the metric depends on
-- invoicing cycle and it is before the 20th of the month, if it -- invoicing cycle and it is before the 12th of the month, if it
-- is the 20th of the month or after, only exclude the current -- is the 12th of the month or after, only exclude the current
-- month. -- month.
display_exclusion = 'INVOICING' display_exclusion = 'INVOICING'
and {{ is_date_before_20th_of_previous_month("date") }} and {{ is_date_before_12th_of_previous_month("date") }}
) )
or ( or (
-- Handle exclusion for Churn/MRR metrics: do not show them in the -- Handle exclusion for Churn/MRR metrics: do not show them in the

View file

@ -47,11 +47,11 @@ where
( (
( (
-- Not show current + previous month if the metric depends on -- Not show current + previous month if the metric depends on
-- invoicing cycle and it is before the 20th of the month, if it -- invoicing cycle and it is before the 12th of the month, if it
-- is the 20th of the month or after, only exclude the current -- is the 12th of the month or after, only exclude the current
-- month. -- month.
m.display_exclusion = 'INVOICING' m.display_exclusion = 'INVOICING'
and {{ is_date_before_20th_of_previous_month("m.date") }} and {{ is_date_before_12th_of_previous_month("m.date") }}
) )
or ( or (
-- Handle exclusion for Churn/MRR metrics: do not show them in the -- Handle exclusion for Churn/MRR metrics: do not show them in the

View file

@ -10,11 +10,11 @@ with
( (
( (
-- Not show current + previous month if the metric depends on -- Not show current + previous month if the metric depends on
-- invoicing cycle and it is before the 20th of the month, if it -- invoicing cycle and it is before the 12th of the month, if it
-- is the 20th of the month or after, only exclude the current -- is the 12th of the month or after, only exclude the current
-- month. -- month.
display_exclusion = 'INVOICING' display_exclusion = 'INVOICING'
and {{ is_date_before_20th_of_previous_month("date") }} and {{ is_date_before_12th_of_previous_month("date") }}
) )
or ( or (
-- Handle exclusion for Churn/MRR metrics: do not show them in the -- Handle exclusion for Churn/MRR metrics: do not show them in the