refactoring
This commit is contained in:
parent
c4b9c42a3c
commit
e84294c4b7
7 changed files with 57 additions and 18 deletions
|
|
@ -1,19 +1,11 @@
|
||||||
with
|
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 (
|
int_core__verification_payments as (
|
||||||
select * from {{ ref("int_core__verification_payments") }}
|
select * from {{ ref("int_core__verification_payments") }}
|
||||||
),
|
),
|
||||||
monster_payment_join as (
|
monster_payment_join as (
|
||||||
select vp.*, p.*, ps."Name"
|
select vp.*
|
||||||
from int_core__verification_payments vp
|
from int_core__verification_payments vp
|
||||||
left join sync_core."Payment" p on vp.id_payment = p."PaymentId"
|
where vp.verification_payment_type = 'Fee' and vp.payment_status = 'Paid'
|
||||||
left join sync_core."PaymentStatus" ps on p."PaymentStatusId" = ps."Id"
|
|
||||||
where vp.verification_payment_type = 'Fee'
|
|
||||||
)
|
)
|
||||||
select *
|
select *
|
||||||
from monster_payment_join
|
from monster_payment_join
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,30 @@ with
|
||||||
),
|
),
|
||||||
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__payment as (select * from {{ ref("stg_core__payment") }}),
|
||||||
|
stg_core__payment_status as (select * from {{ ref("stg_core__payment_status") }})
|
||||||
select
|
select
|
||||||
vtp.id_verification_to_payment,
|
vtp.id_verification_to_payment,
|
||||||
vtp.id_payment,
|
vtp.id_payment,
|
||||||
vtp.is_refundable,
|
vtp.is_refundable,
|
||||||
vtp.created_at_utc,
|
vtp.created_at_utc,
|
||||||
vtp.updated_at_utc,
|
vtp.updated_at_utc,
|
||||||
vtp.refund_due_at_utc,
|
|
||||||
vtp.payment_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,
|
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
|
from stg_core__verification_to_payment vtp
|
||||||
|
left join stg_core__payment p on vtp.id_payment = p.id_payment
|
||||||
left join
|
left 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
|
||||||
|
left join stg_core__payment_status ps on p.id_payment_status = ps.id_payment_status
|
||||||
|
|
|
||||||
|
|
@ -173,3 +173,7 @@ sources:
|
||||||
identifier: VerificationToPayment
|
identifier: VerificationToPayment
|
||||||
- name: VerificationPaymentType
|
- name: VerificationPaymentType
|
||||||
identifier: VerificationPaymentType
|
identifier: VerificationPaymentType
|
||||||
|
- name: Payment
|
||||||
|
identifier: Payment
|
||||||
|
- name: PaymentStatus
|
||||||
|
identifier: PaymentStatus
|
||||||
|
|
|
||||||
21
models/staging/core/stg_core__payment.sql
Normal file
21
models/staging/core/stg_core__payment.sql
Normal 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
|
||||||
12
models/staging/core/stg_core__payment_status.sql
Normal file
12
models/staging/core/stg_core__payment_status.sql
Normal 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
|
||||||
|
|
@ -6,7 +6,7 @@ with
|
||||||
select
|
select
|
||||||
{{ adapter.quote("Id") }} as id_verification_payment_type,
|
{{ adapter.quote("Id") }} as id_verification_payment_type,
|
||||||
{{ adapter.quote("Name") }} as 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
|
from raw_verificationpaymenttype
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@ with
|
||||||
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
|
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
|
||||||
{{ adapter.quote("RefundDueDate") }} as refund_due_at_utc,
|
{{ adapter.quote("RefundDueDate") }} as refund_due_at_utc,
|
||||||
{{ adapter.quote("PaymentDueDate") }} as payment_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("VerificationId") }} as id_verification,
|
||||||
{{ adapter.quote("VerificationPaymentTypeId") }}
|
{{ adapter.quote("VerificationPaymentTypeId") }}
|
||||||
as id_verification_payment_type,
|
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
|
from raw_verificationtopayment
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue