refactoring
This commit is contained in:
parent
c4b9c42a3c
commit
e84294c4b7
7 changed files with 57 additions and 18 deletions
|
|
@ -1,19 +1,11 @@
|
|||
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") }}
|
||||
),
|
||||
int_core__verification_payments as (
|
||||
select * from {{ ref("int_core__verification_payments") }}
|
||||
),
|
||||
monster_payment_join as (
|
||||
select vp.*, p.*, ps."Name"
|
||||
select vp.*
|
||||
from int_core__verification_payments vp
|
||||
left join sync_core."Payment" p on vp.id_payment = p."PaymentId"
|
||||
left join sync_core."PaymentStatus" ps on p."PaymentStatusId" = ps."Id"
|
||||
where vp.verification_payment_type = 'Fee'
|
||||
where vp.verification_payment_type = 'Fee' and vp.payment_status = 'Paid'
|
||||
)
|
||||
select *
|
||||
from monster_payment_join
|
||||
|
|
|
|||
|
|
@ -4,20 +4,30 @@ with
|
|||
),
|
||||
stg_core__verification_payment_type as (
|
||||
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") }})
|
||||
select
|
||||
vtp.id_verification_to_payment,
|
||||
vtp.id_payment,
|
||||
vtp.is_refundable,
|
||||
vtp.created_at_utc,
|
||||
vtp.updated_at_utc,
|
||||
vtp.refund_due_at_utc,
|
||||
vtp.payment_due_at_utc,
|
||||
vtp.id_superhog_user,
|
||||
p.paid_at_utc as payment_paid_at_utc,
|
||||
p.payment_reference,
|
||||
vtp.refund_due_at_utc,
|
||||
p.refunded_at_utc as payment_refunded_at_utc,
|
||||
p.refund_payment_reference,
|
||||
vtp.id_guest_user,
|
||||
vtp.id_verification,
|
||||
vpt.verification_payment_type
|
||||
vpt.verification_payment_type,
|
||||
p.amount,
|
||||
p.currency,
|
||||
ps.payment_status
|
||||
from stg_core__verification_to_payment vtp
|
||||
left join stg_core__payment p on vtp.id_payment = p.id_payment
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue