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'

View file

@ -0,0 +1,27 @@
with
int_core__verification_payments as (
select * from {{ ref("int_core__verification_payments") }}
)
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

View file

@ -0,0 +1 @@
with dates as (select * from {{ ref("int_dates") }}) select * from dates

View file

@ -1,9 +0,0 @@
with
date_master as (select * from {{ ref("int_dates") }}),
fee_txns as (select * from {{ ref("int_core__guest_fee_txns") }})
select date_master.date_day as date, coalesce(sum(fee_txns.amount), 0)
from date_master
left join fee_txns on date_master.date_day = fee_txns.payment_due_at_utc
where date_day between '2022-01-01' and '2024-12-31'
group by date_master.date_day
order by 2 desc

View file

@ -7,10 +7,14 @@ with
{{ adapter.quote("PaymentId") }} as id_payment,
{{ adapter.quote("PaymentRef") }} as payment_reference,
{{ adapter.quote("RefundDate") }} as refunded_at_utc,
cast({{ adapter.quote("RefundDate") }} as date) as refunded_date_utc,
{{ adapter.quote("CreatedDate") }} as created_at_utc,
cast({{ adapter.quote("CreatedDate") }} as date) as created_date_utc,
{{ adapter.quote("CurrencyIso") }} as currency,
{{ adapter.quote("PaymentDate") }} as paid_at_utc,
cast({{ adapter.quote("PaymentDate") }} as date) as paid_date_utc,
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
cast({{ adapter.quote("UpdatedDate") }} as date) as updated_date_utc,
{{ adapter.quote("PaymentStatusId") }} as id_payment_status,
{{ adapter.quote("RefundPaymentRef") }} as refund_payment_reference,
{{ adapter.quote("PaymentProviderId") }} as id_payment_provider,

View file

@ -8,9 +8,13 @@ with
{{ adapter.quote("PaymentId") }} as id_payment,
{{ adapter.quote("Refundable") }} as is_refundable,
{{ adapter.quote("CreatedDate") }} as created_at_utc,
cast({{ adapter.quote("CreatedDate") }} as date) as created_date_utc,
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
cast({{ adapter.quote("UpdatedDate") }} as date) as updated_date_utc,
{{ adapter.quote("RefundDueDate") }} as refund_due_at_utc,
cast({{ adapter.quote("RefundDueDate") }} as date) as refund_due_date_utc,
{{ adapter.quote("PaymentDueDate") }} as payment_due_at_utc,
cast({{ adapter.quote("PaymentDueDate") }} as date) as payment_due_date_utc,
{{ adapter.quote("SuperhogUserId") }} as id_guest_user,
{{ adapter.quote("VerificationId") }} as id_verification,
{{ adapter.quote("VerificationPaymentTypeId") }}