deprecate old version
This commit is contained in:
parent
f199bbd105
commit
f20d7a49ab
2 changed files with 1 additions and 145 deletions
|
|
@ -1,144 +0,0 @@
|
||||||
{% set check_in_cover_as_id_verification_payment = "5" %}
|
|
||||||
{% set cut_off_date_check_in_cover_as_id_verification_payment = "'2025-06-08'" %}
|
|
||||||
|
|
||||||
{{ config(materialized="table") }}
|
|
||||||
with
|
|
||||||
stg_core__verification_to_payment as (
|
|
||||||
select * from {{ ref("stg_core__verification_to_payment") }}
|
|
||||||
),
|
|
||||||
stg_core__verification_payment_type as (
|
|
||||||
select * from {{ ref("stg_core__verification_payment_type") }}
|
|
||||||
),
|
|
||||||
stg_core__verification as (select * from {{ ref("stg_core__verification") }}),
|
|
||||||
stg_core__verification_request as (
|
|
||||||
select * from {{ ref("stg_core__verification_request") }}
|
|
||||||
),
|
|
||||||
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") }}),
|
|
||||||
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.created_at_utc,
|
|
||||||
vtp.updated_at_utc,
|
|
||||||
vtp.payment_due_at_utc,
|
|
||||||
vtp.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,
|
|
||||||
vtp.refund_due_at_utc,
|
|
||||||
vtp.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,
|
|
||||||
vtp.id_guest_user as id_user_guest,
|
|
||||||
v.id_verification_request,
|
|
||||||
upper(vpt.verification_payment_type) as guest_product_name,
|
|
||||||
'VERIFICATION_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_to_payment vtp
|
|
||||||
inner join
|
|
||||||
stg_core__verification_payment_type vpt
|
|
||||||
on vtp.id_verification_payment_type = vpt.id_verification_payment_type
|
|
||||||
left join stg_core__payment p on vtp.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
|
|
||||||
on vtp.payment_due_date_utc = r.rate_date_utc
|
|
||||||
and p.currency = r.from_currency
|
|
||||||
and r.to_currency = 'GBP'
|
|
||||||
left join stg_core__verification v on vtp.id_verification = v.id_verification
|
|
||||||
left join
|
|
||||||
stg_core__verification_request vr
|
|
||||||
on v.id_verification_request = vr.id_verification_request
|
|
||||||
where
|
|
||||||
vtp.id_verification_payment_type
|
|
||||||
= {{ check_in_cover_as_id_verification_payment }}
|
|
||||||
-- Following is to enhance the performance of the query once Guest Product
|
|
||||||
-- payment data follows exclusively the dedicated Guest Product models
|
|
||||||
and v.created_date_utc
|
|
||||||
<= date({{ cut_off_date_check_in_cover_as_id_verification_payment }})
|
|
||||||
and vtp.created_date_utc
|
|
||||||
<= date({{ cut_off_date_check_in_cover_as_id_verification_payment }})
|
|
||||||
and p.created_date_utc
|
|
||||||
<= 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_flow
|
|
||||||
union all
|
|
||||||
select *
|
|
||||||
from guest_product_payments_from_guest_product_flow
|
|
||||||
|
|
@ -5798,7 +5798,7 @@ models:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
||||||
- name: int_core__guest_product_payments
|
- name: int_core__guest_product_payments
|
||||||
latest_version: 1
|
latest_version: 2
|
||||||
description: |
|
description: |
|
||||||
A model that holds guest products payments with details around
|
A model that holds guest products payments with details around
|
||||||
when they happen, what service was being paid, what was the related
|
when they happen, what service was being paid, what was the related
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue