lot of things, should have committed way earlier

This commit is contained in:
Pablo Martin 2024-03-13 10:11:46 +01:00
parent 8b2dca174f
commit 89aed285db
8 changed files with 52 additions and 21 deletions

View file

@ -1,8 +0,0 @@
with
int_core__verification_payments as (
select * from {{ ref("int_core__verification_payments") }}
)
select vp.*
from int_core__verification_payments vp
where vp.verification_payment_type = 'Fee' and vp.payment_status = 'Paid'

View file

@ -6,7 +6,10 @@ with
select * from {{ ref("stg_core__verification_payment_type") }}
),
stg_core__payment as (select * from {{ ref("stg_core__payment") }}),
stg_core__payment_status as (select * from {{ ref("stg_core__payment_status") }})
stg_core__payment_status as (select * from {{ ref("stg_core__payment_status") }}),
int_hardcoded_historical_currency_rates as (
select * from {{ ref("int_hardcoded_historical_currency_rates") }}
)
select
vtp.id_verification_to_payment,
vtp.id_payment,
@ -14,16 +17,21 @@ select
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,
vtp.id_guest_user,
vtp.id_verification,
vpt.verification_payment_type,
p.amount,
p.amount as amount_in_txn_currency,
p.currency,
(p.amount * r.rate) as amount_in_gbp,
ps.payment_status,
p.notes
from stg_core__verification_to_payment vtp
@ -32,4 +40,8 @@ left join
stg_core__verification_payment_type vpt
on vtp.id_verification_payment_type = vpt.id_verification_payment_type
left join stg_core__payment_status ps on p.id_payment_status = ps.id_payment_status
where vtp.updated_at_utc > '2024-01-01'
left join
int_hardcoded_historical_currency_rates r
on p.paid_date_utc = r.rate_date
and p.currency = r.from_currency
and r.to_currency = 'GBP'

View file

@ -1,7 +1,7 @@
with
hardcoded_rates as (select * from {{ ref("stg_seed__hardcoded_currency_rates") }}),
dates as (select * from {{ ref("int_dates") }})
select d.date_day, r.*
select d.date_day as rate_date, r.*
from dates d
cross join hardcoded_rates r
where d.date_day between '2020-01-01' and '2025-12-31'