Merged PR 5214: Integrates Guest Product new flow Payments
# Description Integrates Guest Product Payments coming from the new flow of Guest Products. This also removes few fields that will not be used or that do not make sense for GP specifically. # 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. - [X] I have checked for DRY opportunities with other models and docs. - [X] 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: #30110
This commit is contained in:
parent
d5dd6df1c1
commit
ae9bb524b7
4 changed files with 76 additions and 32 deletions
|
|
@ -66,7 +66,9 @@ with
|
|||
id_guest_product_payment,
|
||||
id_payment,
|
||||
id_verification_request,
|
||||
is_refundable,
|
||||
-- At the moment, there's no functionality for tagging upfront when a
|
||||
-- Guest Product is refundable or not; thus we consider it null
|
||||
null as is_refundable,
|
||||
created_at_utc,
|
||||
updated_at_utc,
|
||||
payment_due_at_utc,
|
||||
|
|
|
|||
|
|
@ -15,15 +15,21 @@ with
|
|||
stg_core__payment as (select * from {{ ref("stg_core__payment") }}),
|
||||
stg_core__payment_status as (select * from {{ ref("stg_core__payment_status") }}),
|
||||
int_simple_exchange_rates as (select * from {{ ref("int_simple_exchange_rates") }}),
|
||||
guest_product_payments_from_verification_payments as (
|
||||
stg_core__verification_request_guest_product_to_payment as (
|
||||
select *
|
||||
from {{ ref("stg_core__verification_request_guest_product_to_payment") }}
|
||||
),
|
||||
stg_core__verification_request_to_guest_product as (
|
||||
select * from {{ ref("stg_core__verification_request_to_guest_product") }}
|
||||
),
|
||||
int_core__guest_products as (select * from {{ ref("int_core__guest_products") }}),
|
||||
guest_product_payments_from_verification_flow as (
|
||||
select
|
||||
-- Tags Guest Product Payments that come from the legacy flow, namely
|
||||
-- CheckInCover from Verification To Payment.
|
||||
'leg_'
|
||||
|| cast(vtp.id_verification_to_payment as text) as id_guest_product_payment,
|
||||
vtp.id_payment,
|
||||
vtp.id_verification_to_payment,
|
||||
vtp.is_refundable,
|
||||
vtp.created_at_utc,
|
||||
vtp.updated_at_utc,
|
||||
vtp.payment_due_at_utc,
|
||||
|
|
@ -38,7 +44,6 @@ with
|
|||
p.refund_payment_reference,
|
||||
vr.id_user_host,
|
||||
vtp.id_guest_user as id_user_guest,
|
||||
vtp.id_verification,
|
||||
v.id_verification_request,
|
||||
upper(vpt.verification_payment_type) as guest_product_name,
|
||||
'VERIFICATION_PAYMENT' as guest_product_payment_source,
|
||||
|
|
@ -76,13 +81,63 @@ with
|
|||
<= date({{ cut_off_date_check_in_cover_as_id_verification_payment }})
|
||||
and vr.created_date_utc
|
||||
<= date({{ cut_off_date_check_in_cover_as_id_verification_payment }})
|
||||
),
|
||||
guest_product_payments_from_guest_product_flow as (
|
||||
select
|
||||
cast(
|
||||
vrgptp.id_verification_request_guest_product_to_payment as text
|
||||
) as id_guest_product_payment,
|
||||
vrgptp.id_payment,
|
||||
vrgptp.created_at_utc,
|
||||
vrgptp.updated_at_utc,
|
||||
-- For the new Guest Product flow, there's no concept of Due Date, as we
|
||||
-- take the payment up front and if the payment fails, then they aren't
|
||||
-- able to complete the Journey.
|
||||
p.paid_at_utc as payment_due_at_utc,
|
||||
p.paid_date_utc as payment_due_date_utc,
|
||||
p.paid_at_utc as payment_paid_at_utc,
|
||||
p.paid_date_utc as payment_paid_date_utc,
|
||||
p.payment_reference,
|
||||
-- Same comment regarding Due Date + At the moment, Guest Products are not
|
||||
-- refundable, but these could be in the future
|
||||
p.refunded_at_utc as refund_due_at_utc,
|
||||
p.refunded_date_utc as refund_due_date_utc,
|
||||
p.refunded_at_utc as payment_refunded_at_utc,
|
||||
p.refunded_date_utc as payment_refunded_date_utc,
|
||||
p.refund_payment_reference,
|
||||
vr.id_user_host as id_user_host,
|
||||
vr.id_user_guest as id_user_guest,
|
||||
vrtgp.id_verification_request,
|
||||
gp.guest_product_name,
|
||||
'GUEST_PRODUCT_PAYMENT' as guest_product_payment_source,
|
||||
p.currency,
|
||||
p.amount as total_amount_in_txn_currency,
|
||||
p.amount * r.rate as total_amount_in_gbp,
|
||||
upper(coalesce(ps.payment_status, 'UNKNOWN')) as payment_status,
|
||||
p.notes
|
||||
from stg_core__verification_request_guest_product_to_payment vrgptp
|
||||
left join stg_core__payment p on vrgptp.id_payment = p.id_payment
|
||||
inner join
|
||||
stg_core__payment_status ps on p.id_payment_status = ps.id_payment_status
|
||||
inner join
|
||||
int_simple_exchange_rates r
|
||||
-- Note that the following conversion is made on Paid date, not Due Date,
|
||||
-- as Due Date does not make sense for Guest Products
|
||||
on p.paid_date_utc = r.rate_date_utc
|
||||
and p.currency = r.from_currency
|
||||
and r.to_currency = 'GBP'
|
||||
left join
|
||||
stg_core__verification_request_to_guest_product vrtgp
|
||||
on vrgptp.id_verification_request_to_guest_product
|
||||
= vrtgp.id_verification_request_to_guest_product
|
||||
left join
|
||||
int_core__guest_products gp on vrtgp.id_guest_product = gp.id_guest_product
|
||||
left join
|
||||
stg_core__verification_request vr
|
||||
on vrtgp.id_verification_request = vr.id_verification_request
|
||||
)
|
||||
select *
|
||||
from
|
||||
guest_product_payments_from_verification_payments
|
||||
-- This model is expecting to provide Guest Product Payment data for
|
||||
-- both old Check-in Cover and new Guest Product models. At the moment,
|
||||
-- the data is only provided for the "old" Check-in Cover. Once the Guest Product
|
||||
-- models are in place, we expect to have here a new CTE that is unioned with the
|
||||
-- one above.
|
||||
|
||||
from guest_product_payments_from_verification_flow
|
||||
union all
|
||||
select *
|
||||
from guest_product_payments_from_guest_product_flow
|
||||
|
|
|
|||
|
|
@ -5789,18 +5789,6 @@ models:
|
|||
- unique
|
||||
- not_null
|
||||
|
||||
- name: id_verification_to_payment
|
||||
data_type: bigint
|
||||
description: |
|
||||
Identifier for the relation between the payment verification
|
||||
and the payment. It can be null if the payment is not related
|
||||
to a verification.
|
||||
|
||||
- name: is_refundable
|
||||
data_type: boolean
|
||||
description: |
|
||||
Indicates whether the payment is refundable or not.
|
||||
|
||||
- name: created_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: |
|
||||
|
|
@ -5901,12 +5889,6 @@ models:
|
|||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: id_verification
|
||||
data_type: bigint
|
||||
description: |
|
||||
Unique identifier of the Verification that has a payment.
|
||||
It can be null if the payment is not related to a verification.
|
||||
|
||||
- name: id_verification_request
|
||||
data_type: bigint
|
||||
description: |
|
||||
|
|
@ -5924,6 +5906,7 @@ models:
|
|||
- accepted_values:
|
||||
values:
|
||||
- CHECKINCOVER
|
||||
- STAYDISRUPT
|
||||
|
||||
- name: guest_product_payment_source
|
||||
data_type: character varying
|
||||
|
|
@ -5932,12 +5915,12 @@ models:
|
|||
This helps identify the backend tables that are used to track this
|
||||
payment.
|
||||
It cannot be null.
|
||||
At this stage, it only includes the source "VERIFICATION_PAYMENT".
|
||||
data_tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- VERIFICATION_PAYMENT
|
||||
- GUEST_PRODUCT_PAYMENT
|
||||
|
||||
- name: currency
|
||||
data_type: character varying
|
||||
|
|
@ -6325,6 +6308,7 @@ models:
|
|||
- DEPOSIT
|
||||
- WAIVER
|
||||
- CHECKINCOVER
|
||||
- STAYDISRUPT
|
||||
- UNKNOWN
|
||||
|
||||
- name: id_verification_product_payment
|
||||
|
|
@ -6385,6 +6369,8 @@ models:
|
|||
description: |
|
||||
Indicates whether the payment is refundable or not.
|
||||
This does NOT mean that the payment is actually refunded.
|
||||
At the moment, this is not implemented for Guest Products
|
||||
in the backend.
|
||||
|
||||
- name: created_at_utc
|
||||
data_type: timestamp without time zone
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue