v1 goes back to original state
This commit is contained in:
parent
bbb9558f62
commit
4efc1ba50f
1 changed files with 2 additions and 42 deletions
|
|
@ -12,11 +12,7 @@ with
|
|||
),
|
||||
stg_core__payment as (select * from {{ ref("stg_core__payment") }}),
|
||||
stg_core__payment_status as (select * from {{ ref("stg_core__payment_status") }}),
|
||||
int_simple_exchange_rates as (select * from {{ ref("int_simple_exchange_rates") }}),
|
||||
int_core__unified_user as (select * from {{ ref("int_core__unified_user") }}),
|
||||
stg_seed__guest_services_vat_rates_by_country as (
|
||||
select * from {{ ref("stg_seed__guest_services_vat_rates_by_country") }}
|
||||
)
|
||||
int_simple_exchange_rates as (select * from {{ ref("int_simple_exchange_rates") }})
|
||||
select
|
||||
vtp.id_verification_to_payment,
|
||||
vtp.id_payment,
|
||||
|
|
@ -36,46 +32,14 @@ select
|
|||
-- Host User identifier is included to speed up
|
||||
-- KPIs execution, even though the host itself
|
||||
-- has nothing to do with the guest payments.
|
||||
-- ---------------------------------------------
|
||||
-- Pablo here, I promise I'll find a way to improve performance and get rid
|
||||
-- of this uglyness. Oh god, it hurts.
|
||||
vr.id_user_host,
|
||||
vtp.id_guest_user,
|
||||
vtp.id_verification,
|
||||
v.id_verification_request,
|
||||
vpt.verification_payment_type,
|
||||
p.currency,
|
||||
p.amount as amount_in_txn_currency,
|
||||
p.currency,
|
||||
(p.amount * r.rate) as amount_in_gbp,
|
||||
p.amount as payment_amount_in_txn_currency,
|
||||
(p.amount * r.rate) as payment_amount_in_gbp,
|
||||
p.amount as total_amount_in_txn_currency,
|
||||
(p.amount * r.rate) as total_amount_in_in_gbp,
|
||||
/*
|
||||
Helping comment for logic below.
|
||||
Given that guest payments are tax inclusive, the tax (column
|
||||
tax_amount_in_txn_currency) is calculated as:
|
||||
paid by guest
|
||||
tax = paid by guest - ( ------------- )
|
||||
1 + VAT Rate
|
||||
|
||||
The amount without tax (column amount_without_taxes_in_txn_currency) gets
|
||||
calculated as:
|
||||
paid by guest
|
||||
amount without tax = ( ------------- )
|
||||
1 + VAT Rate
|
||||
*/
|
||||
(p.amount - (p.amount / (1 + vat.vat_rates))) as tax_amount_in_txn_currency,
|
||||
(p.amount - (p.amount / (1 + vat.vat_rates))) * r.rate as tax_amount_in_gbp,
|
||||
(p.amount / (1 + vat.vat_rates)) as amount_without_taxes_in_txn_currency,
|
||||
(p.amount / (1 + vat.vat_rates)) * r.rate as amount_without_taxes_in_gbp,
|
||||
vat.vat_rate as applicable_vat_tax_rate,
|
||||
case
|
||||
when vat.vat_rate = 0
|
||||
then false
|
||||
when vat.vat_rate < 1 and vat.vat_rate > 0
|
||||
then true
|
||||
end as is_vat_taxed,
|
||||
ps.payment_status,
|
||||
p.notes
|
||||
from stg_core__verification_to_payment vtp
|
||||
|
|
@ -93,7 +57,3 @@ left join
|
|||
left join
|
||||
stg_core__verification_request vr
|
||||
on v.id_verification_request = vr.id_verification_request
|
||||
left join int_core__unified_user uu on vtp.id_guest_user == uu.id_user
|
||||
left join
|
||||
stg_seed__guest_services_vat_rates_by_country vat
|
||||
on uu.billing_country_iso_3 == vat.alpha_3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue