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:
parent
ae9bb524b7
commit
baf9d2767c
4 changed files with 15 additions and 15 deletions
|
|
@ -2,23 +2,23 @@
|
|||
This macro returns a boolean value for dates depending on the current day of the month
|
||||
|
||||
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 **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 **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
|
||||
-- If today is the 20th or later, only exclude current month
|
||||
when extract(day from now()) >= 20
|
||||
-- If today is the 12th or later, only exclude current month
|
||||
when extract(day from now()) >= 12
|
||||
then
|
||||
date_trunc('month', ({{ date }})::date)::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
|
||||
date_trunc('month', ({{ date }})::date)::date
|
||||
< date_trunc('month', now() - interval '1 month')::date
|
||||
Loading…
Add table
Add a link
Reference in a new issue