Merged PR 4428: Adding fees in gbp
# Description Added fees in GBP for reporting purposes # Checklist - [x] The edited models and dependants run properly with production data. - [x] The edited models are sufficiently documented. - [x] The edited models contain PK tests, and I've ran and passed them. - [ ] I have checked for DRY opportunities with other models and docs. - [ ] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Adding fees in gbp Related work items: #27645
This commit is contained in:
commit
f41719a5bf
4 changed files with 99 additions and 12 deletions
|
|
@ -20,6 +20,10 @@ with
|
|||
stg_core__standalone_protection as (
|
||||
select * from {{ ref("stg_core__standalone_protection") }}
|
||||
),
|
||||
stg_core__currency as (select * from {{ ref("stg_core__currency") }}),
|
||||
int_daily_currency_exchange_rates as (
|
||||
select * from {{ ref("int_daily_currency_exchange_rates") }}
|
||||
),
|
||||
active_discount_timeframe as (
|
||||
select distinct
|
||||
vr.id_user_partner,
|
||||
|
|
@ -259,6 +263,7 @@ select
|
|||
vr.protection_extended_amount_in_local_currency,
|
||||
vr.verification_status,
|
||||
vr.id_currency,
|
||||
c.iso4217_code as currency_code,
|
||||
vr.checkin_date_utc,
|
||||
vr.checkout_date_utc,
|
||||
vr.number_of_nights,
|
||||
|
|
@ -267,16 +272,34 @@ select
|
|||
vr.cancelled_date_utc,
|
||||
coalesce(bnf.nightly_fee_in_local_currency, 0) * vr.number_of_nights
|
||||
+ coalesce(bbf.booking_fee_in_local_currency, 0) as total_fee_in_local_currency,
|
||||
(
|
||||
coalesce(bnf.nightly_fee_in_local_currency, 0) * vr.number_of_nights
|
||||
+ coalesce(bbf.booking_fee_in_local_currency, 0)
|
||||
)
|
||||
* der.rate as total_fee_in_gbp,
|
||||
coalesce(bnf.discount_percentage, 0) as discount_percentage,
|
||||
coalesce(bnf.nightly_fee_in_local_currency, 0)
|
||||
* vr.number_of_nights
|
||||
* coalesce(bnf.discount_percentage, 0)
|
||||
/ 100 as discount_amount_in_local_currency,
|
||||
coalesce(bnf.nightly_fee_in_local_currency, 0)
|
||||
* vr.number_of_nights
|
||||
* coalesce(bnf.discount_percentage, 0)
|
||||
/ 100
|
||||
* der.rate as discount_amount_in_gbp,
|
||||
coalesce(bbf.booking_fee_in_local_currency, 0)
|
||||
+ coalesce(bnf.nightly_fee_in_local_currency, 0)
|
||||
* vr.number_of_nights
|
||||
* (100 - coalesce(bnf.discount_percentage, 0))
|
||||
/ 100 as total_fee_after_discount_in_local_currency,
|
||||
(
|
||||
coalesce(bbf.booking_fee_in_local_currency, 0)
|
||||
+ coalesce(bnf.nightly_fee_in_local_currency, 0)
|
||||
* vr.number_of_nights
|
||||
* (100 - coalesce(bnf.discount_percentage, 0))
|
||||
/ 100
|
||||
)
|
||||
* der.rate as total_fee_after_discount_in_gbp,
|
||||
coalesce(bbf.invoice_date_utc, bnf.invoice_date_utc) as invoice_date_utc,
|
||||
vr.creation_at_utc,
|
||||
vr.creation_date_utc,
|
||||
|
|
@ -284,3 +307,9 @@ select
|
|||
from int_screen_and_protect__verification_requests vr
|
||||
left join bookings_with_booking_fee bbf on vr.id_verification = bbf.id_verification
|
||||
left join bookings_with_nightly_fee bnf on vr.id_verification = bnf.id_verification
|
||||
left join stg_core__currency c on vr.id_currency = c.id_currency
|
||||
left join
|
||||
int_daily_currency_exchange_rates der
|
||||
on c.iso4217_code = der.from_currency
|
||||
and coalesce(bbf.invoice_date_utc, bnf.invoice_date_utc) = der.rate_date_utc
|
||||
and der.to_currency = 'GBP'
|
||||
|
|
|
|||
|
|
@ -403,7 +403,6 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 100000
|
||||
strictly: true
|
||||
|
||||
- name: protection_basic_amount_in_local_currency
|
||||
|
|
@ -414,7 +413,6 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 100000
|
||||
strictly: true
|
||||
|
||||
- name: protection_extended_amount_in_local_currency
|
||||
|
|
@ -425,7 +423,6 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 50000000
|
||||
strictly: true
|
||||
|
||||
- name: pet_protection
|
||||
|
|
@ -453,6 +450,12 @@ models:
|
|||
to: ref('stg_core__currency')
|
||||
field: id_currency
|
||||
|
||||
- name: currency_code
|
||||
data_type: text
|
||||
description: "ISO 4217 code of local currency."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: checkin_date_utc
|
||||
data_type: date
|
||||
description: "Check-in date for the booking."
|
||||
|
|
@ -490,7 +493,15 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 10000000
|
||||
strictly: true
|
||||
- not_null
|
||||
|
||||
- name: total_fee_in_gbp
|
||||
data_type: numeric
|
||||
description: "Total fee in GBP, inclusive of all charges."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: true
|
||||
- not_null
|
||||
|
||||
|
|
@ -510,7 +521,15 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 10000000
|
||||
strictly: false
|
||||
- not_null
|
||||
|
||||
- name: discount_amount_in_gbp
|
||||
data_type: numeric
|
||||
description: "Amount of discount in GBP applied to the booking."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
- not_null
|
||||
|
||||
|
|
@ -520,7 +539,15 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 10000000
|
||||
strictly: true
|
||||
- not_null
|
||||
|
||||
- name: total_fee_after_discount_in_gbp
|
||||
data_type: numeric
|
||||
description: "Total fee in GBP after applying the discount."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: true
|
||||
- not_null
|
||||
|
||||
|
|
|
|||
|
|
@ -306,7 +306,6 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 100000
|
||||
strictly: true
|
||||
|
||||
- name: protection_basic_amount_in_local_currency
|
||||
|
|
@ -317,7 +316,6 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 100000
|
||||
strictly: true
|
||||
|
||||
- name: protection_extended_amount_in_local_currency
|
||||
|
|
@ -328,7 +326,6 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 50000000
|
||||
strictly: true
|
||||
|
||||
- name: pet_protection
|
||||
|
|
@ -356,6 +353,12 @@ models:
|
|||
to: ref('stg_core__currency')
|
||||
field: id_currency
|
||||
|
||||
- name: currency_code
|
||||
data_type: text
|
||||
description: "ISO 4217 code of local currency."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: checkin_date_utc
|
||||
data_type: date
|
||||
description: "Check-in date for the booking."
|
||||
|
|
@ -393,7 +396,15 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 10000000
|
||||
strictly: true
|
||||
- not_null
|
||||
|
||||
- name: total_fee_in_gbp
|
||||
data_type: numeric
|
||||
description: "Total fee in GBP, inclusive of all charges."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: true
|
||||
- not_null
|
||||
|
||||
|
|
@ -413,7 +424,15 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 10000000
|
||||
strictly: false
|
||||
- not_null
|
||||
|
||||
- name: discount_amount_in_gbp
|
||||
data_type: numeric
|
||||
description: "Amount of discount in GBP applied to the booking."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
- not_null
|
||||
|
||||
|
|
@ -423,7 +442,15 @@ models:
|
|||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 10000000
|
||||
strictly: true
|
||||
- not_null
|
||||
|
||||
- name: total_fee_after_discount_in_gbp
|
||||
data_type: numeric
|
||||
description: "Total fee in GBP after applying the discount."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: true
|
||||
- not_null
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ select
|
|||
as protection_extended_amount_in_local_currency,
|
||||
verification_status as verification_status,
|
||||
id_currency as id_currency,
|
||||
currency_code as currency_code,
|
||||
checkin_date_utc as checkin_date_utc,
|
||||
checkout_date_utc as checkout_date_utc,
|
||||
number_of_nights as number_of_nights,
|
||||
|
|
@ -24,10 +25,13 @@ select
|
|||
cancelled_at_utc as cancelled_at_utc,
|
||||
cancelled_date_utc as cancelled_date_utc,
|
||||
total_fee_in_local_currency as total_fee_in_local_currency,
|
||||
total_fee_in_gbp as total_fee_in_gbp,
|
||||
discount_percentage as discount_percentage,
|
||||
discount_amount_in_local_currency as discount_amount_in_local_currency,
|
||||
discount_amount_in_gbp as discount_amount_in_gbp,
|
||||
total_fee_after_discount_in_local_currency
|
||||
as total_fee_after_discount_in_local_currency,
|
||||
total_fee_after_discount_in_gbp as total_fee_after_discount_in_gbp,
|
||||
invoice_date_utc as invoice_date_utc,
|
||||
creation_at_utc as creation_at_utc,
|
||||
creation_date_utc as creation_date_utc,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue