Merged PR 2888: No taxes for host takes risk waivers
# Description This PR modifies the V2 of `int_core__verification_payments` to make sure that taxes are not computed for waivers where the host takes the risk (in line with our guest taxes guidelines: https://www.notion.so/knowyourguest-superhog/Guest-Services-Taxes-How-to-calculate-a5ab4c049d61427fafab669dbbffb3a2?pvs=4#323e230365ed496cad6a65b5659895ea). The PR changes the intermediate column `is_service_subject_to_vat`, making it `false` in the cases where there was no active payaway plan during the month where the payment was generated. This cascades in the main body of the model, because if `is_service_subject_to_vat` is `false`, then the tax amounts get turned into zero. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [X] I have checked for DRY opportunities with other models and docs. - [X] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. add logic Related work items: #20043
This commit is contained in:
commit
260b46171c
1 changed files with 18 additions and 3 deletions
|
|
@ -20,17 +20,24 @@ with
|
|||
stg_seed__guest_services_vat_rates_by_country as (
|
||||
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 (
|
||||
select
|
||||
vtp.id_verification_to_payment,
|
||||
coalesce(vat.vat_rate, 0) as vat_rate,
|
||||
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
|
||||
else false
|
||||
end as is_service_subject_to_vat,
|
||||
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
|
||||
when vat.vat_rate = 0
|
||||
then false
|
||||
|
|
@ -69,7 +76,15 @@ with
|
|||
left join
|
||||
stg_seed__guest_services_vat_rates_by_country vat
|
||||
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
|
||||
vtp.id_verification_to_payment,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue