Modified model to only have fees
This commit is contained in:
parent
906bccce0e
commit
a99d4f622f
2 changed files with 96 additions and 23 deletions
|
|
@ -7,25 +7,47 @@ with
|
||||||
int_edeposit__verifications as (
|
int_edeposit__verifications as (
|
||||||
select * from {{ ref("int_edeposit__verifications") }}
|
select * from {{ ref("int_edeposit__verifications") }}
|
||||||
),
|
),
|
||||||
|
stg_core__edeposit_users as (select * from {{ ref("stg_core__edeposit_users") }}),
|
||||||
|
stg_xedotcom__exchange_rates as (
|
||||||
|
select * from {{ ref("stg_xedotcom__exchange_rates") }}
|
||||||
|
),
|
||||||
edeposit_records as (
|
edeposit_records as (
|
||||||
select
|
select
|
||||||
id_verification,
|
v.id_verification,
|
||||||
id_user_partner,
|
v.id_user_partner,
|
||||||
id_booking,
|
v.id_booking,
|
||||||
is_cancelled,
|
v.currency,
|
||||||
creation_at_utc,
|
er.rate,
|
||||||
|
v.is_cancelled,
|
||||||
|
v.creation_at_utc,
|
||||||
case
|
case
|
||||||
when verification_status in {{ ok_status }}
|
when v.verification_status in {{ ok_status }}
|
||||||
then nightly_fee_local * number_nights
|
then v.nightly_fee_local * v.number_nights
|
||||||
else 0
|
else 0
|
||||||
end as ok_status_fee,
|
end as ok_status_fee_in_txn_currency,
|
||||||
case
|
case
|
||||||
when verification_status = '{{ rejected_status }}'
|
when v.verification_status in {{ ok_status }}
|
||||||
|
then er.rate * v.nightly_fee_local * v.number_nights
|
||||||
|
else 0
|
||||||
|
end as ok_status_fee_in_gbp,
|
||||||
|
case
|
||||||
|
when v.verification_status = '{{ rejected_status }}'
|
||||||
then {{ rejected_fee }}
|
then {{ rejected_fee }}
|
||||||
else 0
|
else 0
|
||||||
end as rejected_fee,
|
end as rejected_fee_in_txn_currency,
|
||||||
to_char(checkout_at_utc, 'YYYY-MM') as year_month_checkout
|
case
|
||||||
from int_edeposit__verifications
|
when v.verification_status = '{{ rejected_status }}'
|
||||||
|
then er.rate * {{ rejected_fee }}
|
||||||
|
else 0
|
||||||
|
end as rejected_fee_in_gbp,
|
||||||
|
to_char(v.checkout_at_utc, 'YYYY-MM') as year_month_checkout
|
||||||
|
from int_edeposit__verifications v
|
||||||
|
inner join stg_core__edeposit_users eu on v.id_user_partner = eu.id_user_partner
|
||||||
|
inner join
|
||||||
|
stg_xedotcom__exchange_rates er
|
||||||
|
on er.from_currency = eu.currency
|
||||||
|
and er.rate_date_utc = v.checkout_date_utc
|
||||||
|
and er.to_currency = 'GBP'
|
||||||
where version = 'V2'
|
where version = 'V2'
|
||||||
),
|
),
|
||||||
monthly_cancellation_threshold as (
|
monthly_cancellation_threshold as (
|
||||||
|
|
@ -44,13 +66,21 @@ with
|
||||||
)
|
)
|
||||||
select
|
select
|
||||||
id_verification,
|
id_verification,
|
||||||
ok_status_fee,
|
currency,
|
||||||
rejected_fee,
|
ok_status_fee_in_txn_currency,
|
||||||
|
ok_status_fee_in_gbp,
|
||||||
|
rejected_fee_in_txn_currency,
|
||||||
|
rejected_fee_in_gbp,
|
||||||
case
|
case
|
||||||
when ct.is_cancellation_threshold_surpassed is true
|
when ct.is_cancellation_threshold_surpassed is true
|
||||||
then {{ cancellation_fee }}
|
then {{ cancellation_fee }}
|
||||||
else 0
|
else 0
|
||||||
end as cancelled_fee
|
end as cancelled_fee_in_txn_currency,
|
||||||
|
case
|
||||||
|
when ct.is_cancellation_threshold_surpassed is true
|
||||||
|
then rate * {{ cancellation_fee }}
|
||||||
|
else 0
|
||||||
|
end as cancelled_fee_in_gbp
|
||||||
from edeposit_records er
|
from edeposit_records er
|
||||||
left join
|
left join
|
||||||
monthly_cancellation_threshold ct
|
monthly_cancellation_threshold ct
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,8 @@ models:
|
||||||
"This table shows all fee charges per verification for E-deposit.
|
"This table shows all fee charges per verification for E-deposit.
|
||||||
Cancellation fee is charged when the monthly rate of cancelled bookings over
|
Cancellation fee is charged when the monthly rate of cancelled bookings over
|
||||||
total booking of the partner surpasses the threshold (currently set at 0.05).
|
total booking of the partner surpasses the threshold (currently set at 0.05).
|
||||||
Both cancellation and rejection fees are set to 0.25 though it might change"
|
Both cancellation and rejection fees are set to 0.25 though it might change.
|
||||||
|
Fees are both in the currency used by the user and in GBP"
|
||||||
columns:
|
columns:
|
||||||
- name: id_verification
|
- name: id_verification
|
||||||
data_type: text
|
data_type: text
|
||||||
|
|
@ -220,20 +221,62 @@ models:
|
||||||
- unique
|
- unique
|
||||||
- not_null
|
- not_null
|
||||||
|
|
||||||
- name: ok_status_fee
|
- name: currency
|
||||||
data_type: numeric
|
data_type: text
|
||||||
description: "fee charged for approved or flagged verifications"
|
description: "currency in which the transaction actually happened"
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
||||||
- name: rejected_fee
|
- name: ok_status_fee_in_txn_currency
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged for rejected verifications"
|
description: "fee charged in used currency for approved or flagged verifications"
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
- dbt_expectations.expect_column_values_to_be_between:
|
||||||
|
min_value: 0
|
||||||
|
strictly: false
|
||||||
|
|
||||||
- name: cancelled_fee
|
- name: ok_status_fee_in_gbp
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged for cancelled verifications"
|
description: "fee charged in gbp for approved or flagged verifications"
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
- dbt_expectations.expect_column_values_to_be_between:
|
||||||
|
min_value: 0
|
||||||
|
strictly: false
|
||||||
|
|
||||||
|
- name: rejected_fee_in_txn_currency
|
||||||
|
data_type: numeric
|
||||||
|
description: "fee charged in used currency for rejected verifications"
|
||||||
|
tests:
|
||||||
|
- not_null
|
||||||
|
- dbt_expectations.expect_column_values_to_be_between:
|
||||||
|
min_value: 0
|
||||||
|
strictly: false
|
||||||
|
|
||||||
|
- name: rejected_fee_in_gbp
|
||||||
|
data_type: numeric
|
||||||
|
description: "fee charged in gbp for rejected verifications"
|
||||||
|
tests:
|
||||||
|
- not_null
|
||||||
|
- dbt_expectations.expect_column_values_to_be_between:
|
||||||
|
min_value: 0
|
||||||
|
strictly: false
|
||||||
|
|
||||||
|
- name: cancelled_fee_in_txn_currency
|
||||||
|
data_type: numeric
|
||||||
|
description: "fee charged in used currency for cancelled verifications"
|
||||||
|
tests:
|
||||||
|
- not_null
|
||||||
|
- dbt_expectations.expect_column_values_to_be_between:
|
||||||
|
min_value: 0
|
||||||
|
strictly: false
|
||||||
|
|
||||||
|
- name: cancelled_fee_in_gbp
|
||||||
|
data_type: numeric
|
||||||
|
description: "fee charged in gbp for cancelled verifications"
|
||||||
|
tests:
|
||||||
|
- not_null
|
||||||
|
- dbt_expectations.expect_column_values_to_be_between:
|
||||||
|
min_value: 0
|
||||||
|
strictly: false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue