diff --git a/models/intermediate/core/int_core__payments.sql b/models/intermediate/core/int_core__payments.sql index 798e60c..66aad82 100644 --- a/models/intermediate/core/int_core__payments.sql +++ b/models/intermediate/core/int_core__payments.sql @@ -30,8 +30,12 @@ select vp.tax_amount_in_gbp, vp.amount_due_to_host_in_txn_currency, vp.amount_due_to_host_in_gbp, + vp.amount_due_to_host_without_taxes_in_txn_currency, + vp.amount_due_to_host_without_taxes_in_gbp, vp.superhog_fee_in_txn_currency, vp.superhog_fee_in_gbp, + vp.superhog_fee_without_taxes_in_txn_currency, + vp.superhog_fee_without_taxes_in_gbp, vp.currency, der.rate as exchange_rate_to_gbp, uh.id_user_host, diff --git a/models/intermediate/core/int_core__verification_payments_v2.sql b/models/intermediate/core/int_core__verification_payments_v2.sql index 95183fe..be68e70 100644 --- a/models/intermediate/core/int_core__verification_payments_v2.sql +++ b/models/intermediate/core/int_core__verification_payments_v2.sql @@ -243,9 +243,21 @@ select vat.is_service_subject_to_vat, vat.is_vat_taxed, wf.amount_due_to_host_in_txn_currency, + (wf.amount_due_to_host_in_txn_currency / (1 + vat.vat_rate))::decimal( + 19, 4 + ) as amount_due_to_host_without_taxes_in_txn_currency, wf.amount_due_to_host_in_gbp, + (wf.amount_due_to_host_in_gbp / (1 + vat.vat_rate))::decimal( + 19, 4 + ) as amount_due_to_host_without_taxes_in_gbp, wf.superhog_fee_in_txn_currency, + (wf.superhog_fee_in_txn_currency / (1 + vat.vat_rate))::decimal( + 19, 4 + ) as superhog_fee_without_taxes_in_txn_currency, wf.superhog_fee_in_gbp, + (wf.superhog_fee_in_txn_currency / (1 + vat.vat_rate))::decimal( + 19, 4 + ) as superhog_fee_without_taxes_in_gbp, vat.is_missing_user_country, vat.are_user_details_deleted, vat.is_missing_vat_rate_for_country, diff --git a/models/intermediate/core/int_core__waiver_fees.sql b/models/intermediate/core/int_core__waiver_fees.sql index 98e8494..9413e4e 100644 --- a/models/intermediate/core/int_core__waiver_fees.sql +++ b/models/intermediate/core/int_core__waiver_fees.sql @@ -23,6 +23,7 @@ with int_core__payaway as (select * from {{ ref("int_core__payaway") }}) select vtp.id_payment, + uu.billing_country_iso_3, pa.payaway_percentage, pa.payaway_minimum_commission_local_curr * cer.rate as payaway_minimum_commission_local_curr, @@ -51,16 +52,7 @@ select else 0 end as amount_due_to_host_in_gbp, case - when pa.id_payaway_plan is not null and uu.billing_country_iso_3 = 'GBR' - then - ( - greatest( - p.amount * pa.payaway_percentage, - pa.payaway_minimum_commission_local_curr * cer.rate - ) - ) - / (vat.vat_rate + 1) - when pa.id_payaway_plan is not null and uu.billing_country_iso_3 <> 'GBR' + when pa.id_payaway_plan is not null then greatest( p.amount * pa.payaway_percentage, @@ -69,17 +61,7 @@ select else p.amount end as superhog_fee_in_txn_currency, case - when pa.id_payaway_plan is not null and uu.billing_country_iso_3 = 'GBR' - then - ( - greatest( - p.amount * pa.payaway_percentage, - pa.payaway_minimum_commission_local_curr * cer.rate - ) - ) - / (vat.vat_rate + 1) - * ser.rate - when pa.id_payaway_plan is not null and uu.billing_country_iso_3 <> 'GBR' + when pa.id_payaway_plan is not null then ( greatest( diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index 823f79b..3963bb8 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -879,22 +879,42 @@ models: - name: amount_due_to_host_in_txn_currency data_type: numeric description: | - The amount payable to the host, in local currency. + The amount payable to the host with taxes, in local currency. - name: amount_due_to_host_in_gbp data_type: numeric description: | - The amount payable to the host, in GBP. + The amount payable to the host with taxes, in GBP. + + - name: amount_due_to_host_without_taxes_in_txn_currency + data_type: numeric + description: | + The amount payable to the host without taxes, in local currency. + + - name: amount_due_to_host_without_taxes_in_gbp + data_type: numeric + description: | + The amount payable to the host without taxes, in GBP. - name: superhog_fee_in_txn_currency data_type: numeric description: | - The service fee charged by Superhog, in local currency. + The service fee charged by Superhog with taxes, in local currency. - name: superhog_fee_in_gbp data_type: numeric description: | - The service fee charged by Superhog, in GBP. + The service fee charged by Superhog with taxes, in GBP. + + - name: superhog_fee_without_taxes_in_txn_currency + data_type: numeric + description: | + The service fee charged by Superhog without taxes, in local currency. + + - name: superhog_fee_without_taxes_in_gbp + data_type: numeric + description: | + The service fee charged by Superhog without taxes, in GBP. - name: is_missing_user_country data_type: boolean @@ -5395,22 +5415,42 @@ models: - name: amount_due_to_host_in_txn_currency data_type: numeric description: | - The amount payable to the host, in local currency. + The amount payable to the host with taxes, in local currency. - name: amount_due_to_host_in_gbp data_type: numeric description: | - The amount payable to the host, in GBP. + The amount payable to the host with taxes, in GBP. + + - name: amount_due_to_host_without_taxes_in_txn_currency + data_type: numeric + description: | + The amount payable to the host without taxes, in local currency. + + - name: amount_due_to_host_without_taxes_in_gbp + data_type: numeric + description: | + The amount payable to the host without taxes, in GBP. - name: superhog_fee_in_txn_currency data_type: numeric description: | - The service fee charged by Superhog, in local currency. + The service fee charged by Superhog with taxes, in local currency. - name: superhog_fee_in_gbp data_type: numeric description: | - The service fee charged by Superhog, in GBP. + The service fee charged by Superhog with taxes, in GBP. + + - name: superhog_fee_without_taxes_in_txn_currency + data_type: numeric + description: | + The service fee charged by Superhog without taxes, in local currency. + + - name: superhog_fee_without_taxes_in_gbp + data_type: numeric + description: | + The service fee charged by Superhog without taxes, in GBP. - name: currency data_type: text @@ -5536,19 +5576,19 @@ models: - name: amount_due_to_host_in_txn_currency data_type: numeric description: | - The amount payable to the host, in local currency. + The amount payable to the host with taxes, in local currency. - name: amount_due_to_host_in_gbp data_type: numeric description: | - The amount payable to the host, in GBP. + The amount payable to the host with taxes, in GBP. - name: superhog_fee_in_txn_currency data_type: numeric description: | - The service fee charged by Superhog, in local currency. + The service fee charged by Superhog with taxes, in local currency. - name: superhog_fee_in_gbp data_type: numeric description: | - The service fee charged by Superhog, in GBP. + The service fee charged by Superhog with taxes, in GBP. diff --git a/models/reporting/core/core__payments.sql b/models/reporting/core/core__payments.sql index 83c26f4..9715463 100644 --- a/models/reporting/core/core__payments.sql +++ b/models/reporting/core/core__payments.sql @@ -20,8 +20,14 @@ select tax_amount_in_gbp as tax_amount_in_gbp, amount_due_to_host_in_txn_currency as amount_due_to_host_in_txn_currency, amount_due_to_host_in_gbp as amount_due_to_host_in_gbp, + amount_due_to_host_without_taxes_in_txn_currency + as amount_due_to_host_without_taxes_in_txn_currency, + amount_due_to_host_without_taxes_in_gbp as amount_due_to_host_without_taxes_in_gbp, superhog_fee_in_txn_currency as superhog_fee_in_txn_currency, superhog_fee_in_gbp as superhog_fee_in_gbp, + superhog_fee_without_taxes_in_txn_currency + as superhog_fee_without_taxes_in_txn_currency, + superhog_fee_without_taxes_in_gbp as superhog_fee_without_taxes_in_gbp, currency as currency, exchange_rate_to_gbp as exchange_rate_to_gbp, id_user_host as id_user_host, diff --git a/models/reporting/core/schema.yml b/models/reporting/core/schema.yml index 187f8d0..1f30ed7 100644 --- a/models/reporting/core/schema.yml +++ b/models/reporting/core/schema.yml @@ -1753,22 +1753,42 @@ models: - name: amount_due_to_host_in_txn_currency data_type: numeric description: | - The amount payable to the host, in local currency. + The amount payable to the host with taxes, in local currency. - name: amount_due_to_host_in_gbp data_type: numeric description: | - The amount payable to the host, in GBP. + The amount payable to the host with taxes, in GBP. + + - name: amount_due_to_host_without_taxes_in_txn_currency + data_type: numeric + description: | + The amount payable to the host without taxes, in local currency. + + - name: amount_due_to_host_without_taxes_in_gbp + data_type: numeric + description: | + The amount payable to the host without taxes, in GBP. - name: superhog_fee_in_txn_currency data_type: numeric description: | - The service fee charged by Superhog, in local currency. + The service fee charged by Superhog with taxes, in local currency. - name: superhog_fee_in_gbp data_type: numeric description: | - The service fee charged by Superhog, in GBP. + The service fee charged by Superhog with taxes, in GBP. + + - name: superhog_fee_without_taxes_in_txn_currency + data_type: numeric + description: | + The service fee charged by Superhog without taxes, in local currency. + + - name: superhog_fee_without_taxes_in_gbp + data_type: numeric + description: | + The service fee charged by Superhog without taxes, in GBP. - name: currency data_type: text