commit wip
This commit is contained in:
parent
b6bc19269d
commit
0d11302a20
1 changed files with 12 additions and 14 deletions
|
|
@ -1,5 +1,3 @@
|
|||
{% set uk_tax = 1.2 %}
|
||||
|
||||
with
|
||||
int_core__verification_payments as (
|
||||
select * from {{ ref("int_core__verification_payments") }}
|
||||
|
|
@ -11,6 +9,9 @@ with
|
|||
int_daily_currency_exchange_rates as (
|
||||
select * from {{ ref("int_daily_currency_exchange_rates") }}
|
||||
),
|
||||
stg_seed__guest_services_vat_rates_by_country as (
|
||||
select * from {{ ref("stg_seed__guest_services_vat_rates_by_country") }}
|
||||
),
|
||||
-- CTE to obtain amount due to host and superhog fee.
|
||||
-- This depends on their payaway plan at the moment of the payment.
|
||||
-- If they don't have a payaway plan, then superhog is taking the risk.
|
||||
|
|
@ -47,9 +48,7 @@ with
|
|||
else 0
|
||||
end as amount_due_to_host_in_gbp,
|
||||
case
|
||||
when
|
||||
pa.id_payaway_plan is not null
|
||||
and uh.billing_country_name = 'United Kingdom'
|
||||
when pa.id_payaway_plan is not null and uh.billing_country_iso_3 = 'GBR'
|
||||
then
|
||||
(
|
||||
greatest(
|
||||
|
|
@ -57,10 +56,9 @@ with
|
|||
pa.payaway_minimum_commission_local_curr * cer.rate
|
||||
)
|
||||
)
|
||||
/ {{ uk_tax }}
|
||||
/ (vat.vat_rate + 1)
|
||||
when
|
||||
pa.id_payaway_plan is not null
|
||||
and uh.billing_country_name <> 'United Kingdom'
|
||||
pa.id_payaway_plan is not null and uh.billing_country_iso_3 <> 'GBR'
|
||||
then
|
||||
greatest(
|
||||
vp.total_amount_in_txn_currency * pa.payaway_percentage,
|
||||
|
|
@ -69,9 +67,7 @@ with
|
|||
else vp.amount_without_taxes_in_txn_currency
|
||||
end as superhog_fee_in_txn_currency,
|
||||
case
|
||||
when
|
||||
pa.id_payaway_plan is not null
|
||||
and uh.billing_country_name = 'United Kingdom'
|
||||
when pa.id_payaway_plan is not null and uh.billing_country_iso_3 = 'GBR'
|
||||
then
|
||||
(
|
||||
greatest(
|
||||
|
|
@ -79,11 +75,10 @@ with
|
|||
pa.payaway_minimum_commission_local_curr * cer.rate
|
||||
)
|
||||
)
|
||||
/ {{ uk_tax }}
|
||||
/ (vat.vat_rate + 1)
|
||||
* der.rate
|
||||
when
|
||||
pa.id_payaway_plan is not null
|
||||
and uh.billing_country_name <> 'United Kingdom'
|
||||
pa.id_payaway_plan is not null and uh.billing_country_iso_3 <> 'GBR'
|
||||
then
|
||||
(
|
||||
greatest(
|
||||
|
|
@ -113,6 +108,9 @@ with
|
|||
on vp.payment_paid_date_utc = cer.rate_date_utc
|
||||
and cer.from_currency = uh.account_currency_iso4217
|
||||
and cer.to_currency = vp.currency
|
||||
left join
|
||||
stg_seed__guest_services_vat_rates_by_country vat
|
||||
on uh.billing_country_iso_3 = vat.alpha_3
|
||||
where upper(vp.verification_payment_type) = 'WAIVER'
|
||||
)
|
||||
select
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue