refactoring

This commit is contained in:
Pablo Martin 2024-03-08 18:38:47 +01:00
parent c4b9c42a3c
commit e84294c4b7
7 changed files with 57 additions and 18 deletions

View file

@ -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

View file

@ -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

View file

@ -173,3 +173,7 @@ sources:
identifier: VerificationToPayment
- name: VerificationPaymentType
identifier: VerificationPaymentType
- name: Payment
identifier: Payment
- name: PaymentStatus
identifier: PaymentStatus

View file

@ -0,0 +1,21 @@
with
raw_payment as (select * from {{ source("core", "Payment") }}),
sgt_core__payment as (
select
{{ adapter.quote("Notes") }} as notes,
{{ adapter.quote("Amount") }} as amount,
{{ adapter.quote("PaymentId") }} as id_payment,
{{ adapter.quote("PaymentRef") }} as payment_reference,
{{ adapter.quote("RefundDate") }} as refunded_at_utc,
{{ adapter.quote("CreatedDate") }} as created_at_utc,
{{ adapter.quote("CurrencyIso") }} as currency,
{{ adapter.quote("PaymentDate") }} as paid_at_utc,
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
{{ adapter.quote("PaymentStatusId") }} as id_payment_status,
{{ adapter.quote("RefundPaymentRef") }} as refund_payment_reference,
{{ adapter.quote("PaymentProviderId") }} as id_payment_provider,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_payment
)
select *
from sgt_core__payment

View file

@ -0,0 +1,12 @@
with
raw_payment_status as (select * from {{ source("core", "PaymentStatus") }}),
stg_core__payment_status as (
select
{{ adapter.quote("Id") }} as id_payment_status,
{{ adapter.quote("FullName") }} as payment_status,
{{ adapter.quote("_airbyte_extracted_at") }}dwh_extracted_at_utc
from raw_payment_status
)
select *
from stg_core__payment_status

View file

@ -6,7 +6,7 @@ with
select
{{ adapter.quote("Id") }} as id_verification_payment_type,
{{ adapter.quote("Name") }} as verification_payment_type,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_date_utc
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_verificationpaymenttype
)

View file

@ -11,11 +11,11 @@ with
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
{{ adapter.quote("RefundDueDate") }} as refund_due_at_utc,
{{ adapter.quote("PaymentDueDate") }} as payment_due_at_utc,
{{ adapter.quote("SuperhogUserId") }} as id_superhog_user,
{{ adapter.quote("SuperhogUserId") }} as id_guest_user,
{{ adapter.quote("VerificationId") }} as id_verification,
{{ adapter.quote("VerificationPaymentTypeId") }}
as id_verification_payment_type,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_date_utc
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_verificationtopayment
)