Skip to content

Commit

Permalink
convert end_of_month_date calculations in payments tables to Pacifi…
Browse files Browse the repository at this point in the history
…c Time (#3210)

* convert end of month calculations to PT

* rename end_of_month_date to end_of_month_date_pacific

* update recommendations for use in docs for end_of_month_date_utc
  • Loading branch information
charlie-costanzo authored Jan 4, 2024
1 parent b43ba67 commit a2ef994
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
21 changes: 17 additions & 4 deletions warehouse/models/mart/payments/_payments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,21 @@ models:
description: |
`source_record_id` of the Cal-ITP defined organization (from `dim_organizations`) associated with this payments activity.
The mapping of organization records to payments entities is manually maintained in a seed file.
- name: end_of_month_date
- name: end_of_month_date_pacific
description: |
The last day of the month of the aggregation_datetime.
The last day of the month of the aggregation_datetime in Pacific Time (involves conversion of aggregation_datetime to Pacific Time).
This column is primarily for use in BI tooling to support consistent dates across activity types.
Aggregation activity happens throughout the month.
tests:
- not_null
- name: end_of_month_date_utc
description: |
The last day of the month of the aggregation_datetime in UTC.
This column preserves the end of month date value for the original UTC date as received by Littlepay, however,
`end_of_month_date_pacific` is primarily used in BI tooling instead to support consistent dates across activity types.
Aggregation activity happens throughout the month.
tests:
- not_null
- name: aggregation_id
description: |
Aggregation ID that uniquely identifies this aggregation.
Expand Down Expand Up @@ -269,10 +277,15 @@ models:
description: '{{ doc("lp_settlement_id") }}'
- *organization_name
- *organization_source_record_id
- name: end_of_month_date
- name: end_of_month_date_pacific
description: |
The last day of the month of the record_updated_timestamp_utc.
The last day of the month in Pacific Time (involves conversion of record_updated_timestamp_utc to Pacific Time).
This column is primarily for use in BI tooling to support consistent dates across activity types.
- name: end_of_month_date_utc
description: |
The last day of the month of the record_updated_timestamp_utc.
This column preserves the end of month date value for the original UTC date as received by Littlepay, however,
`end_of_month_date_pacific` is primarily used in BI tooling instead to support consistent dates across activity types.
- *participant_id
- name: aggregation_id
description: '{{ doc("lp_aggregation_id") }}'
Expand Down
3 changes: 2 additions & 1 deletion warehouse/models/mart/payments/fct_payments_aggregations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ fct_payments_aggregations AS (
participant_id,
organization_name,
organization_source_record_id,
LAST_DAY(EXTRACT(DATE FROM aggregation_datetime), MONTH) AS end_of_month_date,
LAST_DAY(EXTRACT(DATE FROM aggregation_datetime AT TIME ZONE "America/Los_Angeles"), MONTH) AS end_of_month_date_pacific,
LAST_DAY(EXTRACT(DATE FROM aggregation_datetime), MONTH) AS end_of_month_date_utc,
aggregation_id,
has_micropayment,
has_authorisation,
Expand Down
3 changes: 2 additions & 1 deletion warehouse/models/mart/payments/fct_payments_settlements.sql
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ fct_payments_settlements AS (
WHEN settlement_type = "CREDIT" THEN -1*(transaction_amount)
WHEN settlement_type = "DEBIT" THEN transaction_amount
END AS transaction_amount,
LAST_DAY(EXTRACT(DATE FROM record_updated_timestamp_utc), MONTH) AS end_of_month_date,
LAST_DAY(EXTRACT(DATE FROM record_updated_timestamp_utc AT TIME ZONE "America/Los_Angeles"), MONTH) AS end_of_month_date_pacific,
LAST_DAY(EXTRACT(DATE FROM record_updated_timestamp_utc), MONTH) AS end_of_month_date_utc,
imputed_type,
acquirer,
_line_number,
Expand Down

0 comments on commit a2ef994

Please sign in to comment.