Merged PR 2971: Fix no tax bug

# Description

Fixes a bug introduced by PR: https://guardhog.visualstudio.com/Data/_git/data-pbi-reports/pullrequest/2962

The previous PR made non-waiver services become tax free if the host had an active payaway setting at the payment timestamp, which makes no sense because payaway only relates to waiver and not to other services.

# 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.

Related work items: #20043
This commit is contained in:
Pablo Martín 2024-09-25 14:24:35 +00:00
commit a280f79d18

View file

@ -1,7 +1,5 @@
{{ config(materialized="table") }}
{% set vat_applicable_services = "('Waiver', 'Fee', 'CheckInCover')" %}
with
stg_core__verification_to_payment as (
select * from {{ ref("stg_core__verification_to_payment") }}
@ -29,15 +27,21 @@ with
coalesce(vat.vat_rate, 0) as vat_rate,
case
when
vpt.verification_payment_type in {{ vat_applicable_services }}
vpt.verification_payment_type = 'Waiver'
and pamu.id_payaway_plan is null -- superhog takes waiver
then true
when vpt.verification_payment_type in ('Fee', 'CheckInCover')
then true
else false
end as is_service_subject_to_vat,
case
when
vpt.verification_payment_type not in {{ vat_applicable_services }}
or pamu.id_payaway_plan is not null -- host takes waiver
vpt.verification_payment_type
not in ('Waiver', 'Fee', 'CheckInCover')
then false
when
vpt.verification_payment_type = 'Waiver'
and pamu.id_payaway_plan is not null -- host takes waiver
then false
when vat.vat_rate = 0
then false