This commit is contained in:
Pablo Martin 2025-05-19 15:44:06 +02:00
parent 8c7c3e84cf
commit 92c8331ae4

View file

@ -4,12 +4,24 @@
{{ config(materialized="table") }} {{ config(materialized="table") }}
with with
stg_core__verification_to_payment as ( stg_core__verification_to_payment as (
select * from {{ ref("stg_core__verification_to_payment") }} select *
from {{ ref("stg_core__verification_to_payment") }}
where
created_date_utc
<= date({{ cut_off_date_check_in_cover_as_id_verification_payment }})
and id_verification_payment_type
= {{ check_in_cover_as_id_verification_payment }}
), ),
stg_core__verification_payment_type as ( stg_core__verification_payment_type as (
select * from {{ ref("stg_core__verification_payment_type") }} select * from {{ ref("stg_core__verification_payment_type") }}
), ),
stg_core__verification as (select * from {{ ref("stg_core__verification") }}), stg_core__verification as (
select *
from {{ ref("stg_core__verification") }}
where
created_date_utc
<= date({{ cut_off_date_check_in_cover_as_id_verification_payment }})
),
stg_core__verification_request as ( stg_core__verification_request as (
select * from {{ ref("stg_core__verification_request") }} select * from {{ ref("stg_core__verification_request") }}
), ),
@ -54,6 +66,7 @@ with
upper(coalesce(ps.payment_status, 'UNKNOWN')) as payment_status, upper(coalesce(ps.payment_status, 'UNKNOWN')) as payment_status,
p.notes p.notes
from stg_core__verification_to_payment vtp from stg_core__verification_to_payment vtp
left join stg_core__verification v on vtp.id_verification = v.id_verification
inner join inner join
stg_core__verification_payment_type vpt stg_core__verification_payment_type vpt
on vtp.id_verification_payment_type = vpt.id_verification_payment_type on vtp.id_verification_payment_type = vpt.id_verification_payment_type
@ -65,23 +78,9 @@ with
on vtp.payment_due_date_utc = r.rate_date_utc on vtp.payment_due_date_utc = r.rate_date_utc
and p.currency = r.from_currency and p.currency = r.from_currency
and r.to_currency = 'GBP' and r.to_currency = 'GBP'
left join stg_core__verification v on vtp.id_verification = v.id_verification
left join left join
stg_core__verification_request vr stg_core__verification_request vr
on v.id_verification_request = vr.id_verification_request 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 ( guest_product_payments_from_guest_product_flow as (
select select