From 78e7e37c5e5bac25efc77555e28f82773251ae1a Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 17 Sep 2024 15:07:00 +0200 Subject: [PATCH 1/6] Update model core__verification_payments to include amounts without taxes --- .../core/core__verification_payments.sql | 10 ++-- models/reporting/core/schema.yml | 54 ++++++++++++++++++- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/models/reporting/core/core__verification_payments.sql b/models/reporting/core/core__verification_payments.sql index 5297fa0..d798780 100644 --- a/models/reporting/core/core__verification_payments.sql +++ b/models/reporting/core/core__verification_payments.sql @@ -1,6 +1,6 @@ with int_core__verification_payments as ( - select * from {{ ref("int_core__verification_payments") }} + select * from {{ ref("int_core__verification_payments", version=2) }} ) select vp.id_verification_to_payment as id_verification_to_payment, @@ -19,9 +19,13 @@ select vp.id_guest_user as id_guest_user, vp.id_verification as id_verification, vp.verification_payment_type as verification_payment_type, - vp.amount_in_txn_currency as amount_in_txn_currency, + vp.total_amount_in_txn_currency as amount_in_txn_currency, -- LEGACY + vp.total_amount_in_txn_currency as total_amount_in_txn_currency, + vp.amount_without_taxes_in_txn_currency as amount_without_taxes_in_txn_currency, vp.currency as currency, - vp.amount_in_gbp as amount_in_gbp, + vp.total_amount_in_gbp as amount_in_gbp, -- LEGACY + vp.total_amount_in_gbp as total_amount_in_gbp, + vp.amount_without_taxes_in_gbp as amount_without_taxes_in_gbp, vp.payment_status as payment_status, vp.notes as notes from int_core__verification_payments vp diff --git a/models/reporting/core/schema.yml b/models/reporting/core/schema.yml index 1b48715..359cbf8 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -29,10 +29,14 @@ models: - name: payment_due_at_utc data_type: timestamp without time zone description: The point in time at which this payment had to be paid. + tests: + - not_null - name: payment_due_date_utc data_type: date description: The date on which this payment had to be paid. + tests: + - not_null - name: payment_paid_at_utc data_type: timestamp without time zone @@ -83,30 +87,78 @@ models: - name: id_guest_user data_type: character varying description: The UUID of the guest user in the Superhog backend. + tests: + - not_null - name: id_verification data_type: bigint description: The ID of the verification that generated this payment. + tests: + - not_null - name: verification_payment_type data_type: character varying description: "The payment type. Can be one of: Waiver, Fee, Deposit, Reschedule, Cancellation." - name: amount_in_txn_currency + data_type: numeric + description: The payment amount in the currency in which the transaction actually happened. If the guest paid in Australian Dollars, this is measured in AUD. (To be decommissioned) + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + strictly: false + + - name: total_amount_in_txn_currency data_type: numeric description: The payment amount in the currency in which the transaction actually happened. If the guest paid in Australian Dollars, this is measured in AUD. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + strictly: false + + - name: amount_without_taxes_in_txn_currency + data_type: numeric + description: The payment amount without taxes in the currency in which the transaction actually happened. If the guest paid in Australian Dollars, this is measured in AUD. (To be decommissioned) + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + strictly: false - name: currency data_type: character varying description: The currency in which the transaction actually happened. If the guest paid in Australian Dollars, this is measured in AUD. + tests: + - not_null - name: amount_in_gbp data_type: numeric description: The payment amount value, converted to GBP, using the exchange rate for the day on which the payment happened. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + strictly: false + + - name: total_amount_in_gbp + data_type: numeric + description: The payment amount value, converted to GBP, using the exchange rate for the day on which the payment happened. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + strictly: false + + - name: amount_without_taxes_in_gbp + data_type: numeric + description: The payment amount value without taxes, converted to GBP, using the exchange rate for the day on which the payment happened. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + strictly: false - name: payment_status data_type: character varying - description: "The status of the payment. It can be one of: Paid, Refunded, Refund Failed." + description: "The status of the payment. It can be one of: Paid, Refunded, Refund Failed, Cancelled, Paid Manually, Unpaid." + tests: + - not_null - name: notes data_type: character varying From e854f2a99aadd34032466259c483b8ee7740ddca Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 17 Sep 2024 17:10:14 +0200 Subject: [PATCH 2/6] commit --- package-lock.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.yml b/package-lock.yml index 2b520db..d7ed31d 100644 --- a/package-lock.yml +++ b/package-lock.yml @@ -4,7 +4,7 @@ packages: - package: calogica/dbt_expectations version: 0.9.0 - package: dbt-labs/dbt_utils - version: 1.1.1 + version: 1.2.0 - package: calogica/dbt_date version: 0.8.1 -sha1_hash: 0d8e1bf7188f14d46813097c65818e3f96237266 +sha1_hash: ceec21d8037429db57330b6f23cfdc761bbb7698 From 9e62786aa9b844ade49d22600404f62e4683b0a8 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Wed, 18 Sep 2024 11:26:23 +0200 Subject: [PATCH 3/6] commit2 --- models/intermediate/core/schema.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index 350ce8f..222d707 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -932,7 +932,7 @@ models: date before a starting date. - name: int_core__verification_payments - latest_version: 1 + latest_version: 2 description: >- A simplified table that holds guest journey payments with details around when they happen, what service was being paid, what was the related @@ -1020,6 +1020,8 @@ models: versions: - v: 1 deprecation_date: 2024-10-15 00:00:00.00+00:00 + config: + alias: int_core__verification_payments - v: 2 columns: From 40bfa60016f86590c91686783f134df7c6eb0c80 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Wed, 18 Sep 2024 12:41:00 +0200 Subject: [PATCH 4/6] core__verification_payments_v2 --- ...=> int_core__verification_payments_v1.sql} | 0 .../core/core__verification_payments_v1.sql | 27 +++++++ ...sql => core__verification_payments_v2.sql} | 2 - models/reporting/core/schema.yml | 76 +++++++++++-------- 4 files changed, 71 insertions(+), 34 deletions(-) rename models/intermediate/core/{int_core__verification_payments.sql => int_core__verification_payments_v1.sql} (100%) create mode 100644 models/reporting/core/core__verification_payments_v1.sql rename models/reporting/core/{core__verification_payments.sql => core__verification_payments_v2.sql} (91%) diff --git a/models/intermediate/core/int_core__verification_payments.sql b/models/intermediate/core/int_core__verification_payments_v1.sql similarity index 100% rename from models/intermediate/core/int_core__verification_payments.sql rename to models/intermediate/core/int_core__verification_payments_v1.sql diff --git a/models/reporting/core/core__verification_payments_v1.sql b/models/reporting/core/core__verification_payments_v1.sql new file mode 100644 index 0000000..afd5715 --- /dev/null +++ b/models/reporting/core/core__verification_payments_v1.sql @@ -0,0 +1,27 @@ +with + int_core__verification_payments as ( + select * from {{ ref("int_core__verification_payments", version=1) }} + ) +select + vp.id_verification_to_payment as id_verification_to_payment, + vp.id_payment as id_payment, + vp.is_refundable as is_refundable, + vp.payment_due_at_utc as payment_due_at_utc, + vp.payment_due_date_utc as payment_due_date_utc, + vp.payment_paid_at_utc as payment_paid_at_utc, + vp.payment_paid_date_utc as payment_paid_date_utc, + vp.payment_reference as payment_reference, + vp.refund_due_at_utc as refund_due_at_utc, + vp.refund_due_date_utc as refund_due_date_utc, + vp.payment_refunded_at_utc as payment_refunded_at_utc, + vp.payment_refunded_date_utc as payment_refunded_date_utc, + vp.refund_payment_reference as refund_payment_reference, + vp.id_guest_user as id_guest_user, + vp.id_verification as id_verification, + vp.verification_payment_type as verification_payment_type, + vp.amount_in_txn_currency as amount_in_txn_currency, + vp.currency as currency, + vp.amount_in_gbp as amount_in_gbp, + vp.payment_status as payment_status, + vp.notes as notes +from int_core__verification_payments vp diff --git a/models/reporting/core/core__verification_payments.sql b/models/reporting/core/core__verification_payments_v2.sql similarity index 91% rename from models/reporting/core/core__verification_payments.sql rename to models/reporting/core/core__verification_payments_v2.sql index d798780..4db5f13 100644 --- a/models/reporting/core/core__verification_payments.sql +++ b/models/reporting/core/core__verification_payments_v2.sql @@ -19,11 +19,9 @@ select vp.id_guest_user as id_guest_user, vp.id_verification as id_verification, vp.verification_payment_type as verification_payment_type, - vp.total_amount_in_txn_currency as amount_in_txn_currency, -- LEGACY vp.total_amount_in_txn_currency as total_amount_in_txn_currency, vp.amount_without_taxes_in_txn_currency as amount_without_taxes_in_txn_currency, vp.currency as currency, - vp.total_amount_in_gbp as amount_in_gbp, -- LEGACY vp.total_amount_in_gbp as total_amount_in_gbp, vp.amount_without_taxes_in_gbp as amount_without_taxes_in_gbp, vp.payment_status as payment_status, diff --git a/models/reporting/core/schema.yml b/models/reporting/core/schema.yml index 359cbf8..2b966d7 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -2,6 +2,7 @@ version: 2 models: - name: core__verification_payments + latest_version: 2 description: | Payments that have happened as part of the Guest Journey. @@ -108,22 +109,6 @@ models: min_value: 0 strictly: false - - name: total_amount_in_txn_currency - data_type: numeric - description: The payment amount in the currency in which the transaction actually happened. If the guest paid in Australian Dollars, this is measured in AUD. - tests: - - dbt_expectations.expect_column_values_to_be_between: - min_value: 0 - strictly: false - - - name: amount_without_taxes_in_txn_currency - data_type: numeric - description: The payment amount without taxes in the currency in which the transaction actually happened. If the guest paid in Australian Dollars, this is measured in AUD. (To be decommissioned) - tests: - - dbt_expectations.expect_column_values_to_be_between: - min_value: 0 - strictly: false - - name: currency data_type: character varying description: The currency in which the transaction actually happened. If the guest paid in Australian Dollars, this is measured in AUD. @@ -138,22 +123,6 @@ models: min_value: 0 strictly: false - - name: total_amount_in_gbp - data_type: numeric - description: The payment amount value, converted to GBP, using the exchange rate for the day on which the payment happened. - tests: - - dbt_expectations.expect_column_values_to_be_between: - min_value: 0 - strictly: false - - - name: amount_without_taxes_in_gbp - data_type: numeric - description: The payment amount value without taxes, converted to GBP, using the exchange rate for the day on which the payment happened. - tests: - - dbt_expectations.expect_column_values_to_be_between: - min_value: 0 - strictly: false - - name: payment_status data_type: character varying description: "The status of the payment. It can be one of: Paid, Refunded, Refund Failed, Cancelled, Paid Manually, Unpaid." @@ -164,6 +133,49 @@ models: data_type: character varying description: Free text description on the payment. Typically, contains explanations for integration issues with the payment processor. + versions: + - v: 1 + deprecation_date: 2024-10-15 00:00:00.00+00:00 + config: + alias: core__verification_payments + + - v: 2 + columns: + - name: total_amount_in_txn_currency + data_type: numeric + description: The payment amount in the currency in which the transaction actually happened. If the guest paid in Australian Dollars, this is measured in AUD. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + strictly: false + + - name: amount_without_taxes_in_txn_currency + data_type: numeric + description: The payment amount without taxes in the currency in which the transaction actually happened. If the guest paid in Australian Dollars, this is measured in AUD. (To be decommissioned) + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + strictly: false + + - name: total_amount_in_gbp + data_type: numeric + description: The payment amount value, converted to GBP, using the exchange rate for the day on which the payment happened. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + strictly: false + + - name: amount_without_taxes_in_gbp + data_type: numeric + description: The payment amount value without taxes, converted to GBP, using the exchange rate for the day on which the payment happened. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + strictly: false + + - include: all + exclude: [amount_in_txn_currency, amount_in_gbp] + - name: core__bookings description: | From 923bfa70919bf552304150e8cc3ec9af7cdbe708 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Wed, 18 Sep 2024 14:20:48 +0200 Subject: [PATCH 5/6] Update exposures to pull from version 1 --- models/reporting/core/schema.yml | 2 +- models/reporting/exposures.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/models/reporting/core/schema.yml b/models/reporting/core/schema.yml index 2b966d7..3e05e26 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -192,7 +192,7 @@ models: description: The unique, Superhog generated id for this booking. tests: - unique - - not_null + - not_nullgit p - name: id_user_guest data_type: character varying diff --git a/models/reporting/exposures.yml b/models/reporting/exposures.yml index 79118ff..ce23470 100644 --- a/models/reporting/exposures.yml +++ b/models/reporting/exposures.yml @@ -12,7 +12,7 @@ exposures: depends_on: - ref('dates') - - ref('core__verification_payments') + - ref('core__verification_payments', version=1) owner: name: Pablo Martin From 7ceeabbe7b27449cf2c2cd22dbec662a66c343d9 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Wed, 18 Sep 2024 14:22:33 +0200 Subject: [PATCH 6/6] Revert "commit" This reverts commit e854f2a99aadd34032466259c483b8ee7740ddca. --- package-lock.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.yml b/package-lock.yml index d7ed31d..2b520db 100644 --- a/package-lock.yml +++ b/package-lock.yml @@ -4,7 +4,7 @@ packages: - package: calogica/dbt_expectations version: 0.9.0 - package: dbt-labs/dbt_utils - version: 1.2.0 + version: 1.1.1 - package: calogica/dbt_date version: 0.8.1 -sha1_hash: ceec21d8037429db57330b6f23cfdc761bbb7698 +sha1_hash: 0d8e1bf7188f14d46813097c65818e3f96237266