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