add logic
This commit is contained in:
parent
a20d511b93
commit
136c297683
1 changed files with 18 additions and 3 deletions
|
|
@ -20,17 +20,24 @@ with
|
||||||
stg_seed__guest_services_vat_rates_by_country as (
|
stg_seed__guest_services_vat_rates_by_country as (
|
||||||
select * from {{ ref("stg_seed__guest_services_vat_rates_by_country") }}
|
select * from {{ ref("stg_seed__guest_services_vat_rates_by_country") }}
|
||||||
),
|
),
|
||||||
|
int_core__payaway_per_month_user as (
|
||||||
|
select * from {{ ref("int_core__payaway_per_month_user") }}
|
||||||
|
),
|
||||||
vat_details as (
|
vat_details as (
|
||||||
select
|
select
|
||||||
vtp.id_verification_to_payment,
|
vtp.id_verification_to_payment,
|
||||||
coalesce(vat.vat_rate, 0) as vat_rate,
|
coalesce(vat.vat_rate, 0) as vat_rate,
|
||||||
case
|
case
|
||||||
when vpt.verification_payment_type in {{ vat_applicable_services }}
|
when
|
||||||
|
vpt.verification_payment_type in {{ vat_applicable_services }}
|
||||||
|
and pamu.id_payaway_plan is null -- superhog takes waiver
|
||||||
then true
|
then true
|
||||||
else false
|
else false
|
||||||
end as is_service_subject_to_vat,
|
end as is_service_subject_to_vat,
|
||||||
case
|
case
|
||||||
when vpt.verification_payment_type not in {{ vat_applicable_services }}
|
when
|
||||||
|
vpt.verification_payment_type not in {{ vat_applicable_services }}
|
||||||
|
or pamu.id_payaway_plan is not null -- host takes waiver
|
||||||
then false
|
then false
|
||||||
when vat.vat_rate = 0
|
when vat.vat_rate = 0
|
||||||
then false
|
then false
|
||||||
|
|
@ -69,7 +76,15 @@ with
|
||||||
left join
|
left join
|
||||||
stg_seed__guest_services_vat_rates_by_country vat
|
stg_seed__guest_services_vat_rates_by_country vat
|
||||||
on uu.billing_country_iso_3 = vat.alpha_3
|
on uu.billing_country_iso_3 = vat.alpha_3
|
||||||
|
left join stg_core__verification v on vtp.id_verification = v.id_verification
|
||||||
|
left join
|
||||||
|
stg_core__verification_request vr
|
||||||
|
on v.id_verification_request = vr.id_verification_request
|
||||||
|
left join
|
||||||
|
int_core__payaway_per_month_user pamu
|
||||||
|
on vr.id_user_host = pamu.id_user_host
|
||||||
|
and vtp.payment_due_at_utc
|
||||||
|
between pamu.active_in_month_start_date_utc and active_in_month_end_date_utc
|
||||||
)
|
)
|
||||||
select
|
select
|
||||||
vtp.id_verification_to_payment,
|
vtp.id_verification_to_payment,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue