Merged PR 2469: Included the exchange rate to GBP in the model
# Description Included the exchange rate to GBP in the model instead of joining the data inside the PBI report, for both understanding and easier joining # 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. - [X] I have checked for DRY opportunities with other models and docs. - [X] I've picked the right materialization for the affected models. # Other - [X] Check if a full-refresh is required after this PR is merged. Included the exchange rate to GBP in the model Related work items: #18875
This commit is contained in:
commit
7fe2d779e2
4 changed files with 23 additions and 5 deletions
|
|
@ -7,7 +7,8 @@ with
|
||||||
int_core__duplicate_bookings as (
|
int_core__duplicate_bookings as (
|
||||||
select * from {{ ref("int_core__duplicate_bookings") }}
|
select * from {{ ref("int_core__duplicate_bookings") }}
|
||||||
),
|
),
|
||||||
int_core__unified_user as (select * from {{ ref("int_core__unified_user") }})
|
int_core__unified_user as (select * from {{ ref("int_core__unified_user") }}),
|
||||||
|
int_simple_exchange_rates as (select * from {{ ref("int_simple_exchange_rates") }})
|
||||||
select
|
select
|
||||||
b.id_booking,
|
b.id_booking,
|
||||||
b.id_user_guest,
|
b.id_user_guest,
|
||||||
|
|
@ -17,14 +18,22 @@ select
|
||||||
coalesce(db.is_duplicate_booking, false) as is_duplicate_booking,
|
coalesce(db.is_duplicate_booking, false) as is_duplicate_booking,
|
||||||
bce.booking_fee_local,
|
bce.booking_fee_local,
|
||||||
uu.account_currency_iso4217,
|
uu.account_currency_iso4217,
|
||||||
|
coalesce(
|
||||||
|
ser.rate * bce.booking_fee_local, bce.booking_fee_local
|
||||||
|
) as booking_fee_in_gbp,
|
||||||
bce.booking_fee_charge_at_utc,
|
bce.booking_fee_charge_at_utc,
|
||||||
bce.booking_fee_charge_date_utc
|
bce.booking_fee_charge_date_utc
|
||||||
from stg_core__booking b
|
from stg_core__booking b
|
||||||
left join int_core__booking_charge_events bce on b.id_booking = bce.id_booking
|
left join int_core__booking_charge_events bce on b.id_booking = bce.id_booking
|
||||||
left join stg_core__booking_state bs on b.id_booking_state = bs.id_booking_state
|
left join stg_core__booking_state bs on b.id_booking_state = bs.id_booking_state
|
||||||
left join int_core__duplicate_bookings db on b.id_booking = db.id_booking
|
left join int_core__duplicate_bookings db on b.id_booking = db.id_booking
|
||||||
|
left join int_core__unified_user uu on lower(b.id_user_host) = lower(uu.id_user)
|
||||||
|
-- We user 'lower' because the id_user_host can be found in capital letters or not
|
||||||
|
-- depending on the table and Postgres is case sensitive
|
||||||
left join
|
left join
|
||||||
int_core__unified_user uu on lower(b.id_user_host) = lower(uu.id_user)
|
int_simple_exchange_rates ser
|
||||||
-- We user 'lower' because the id_user_host can be found in capital letters or not
|
on (
|
||||||
-- depending on the table and Postgres is case sensitive
|
ser.from_currency = uu.account_currency_iso4217
|
||||||
|
and ser.rate_date_utc = bce.booking_fee_charge_date_utc
|
||||||
|
and ser.to_currency = 'GBP'
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -1643,6 +1643,10 @@ models:
|
||||||
data_type: character varying
|
data_type: character varying
|
||||||
description: "Currency used by host/pm/platform users."
|
description: "Currency used by host/pm/platform users."
|
||||||
|
|
||||||
|
- name: booking_fee_in_gbp
|
||||||
|
data_type: numeric
|
||||||
|
description: "The fee to apply to the booking, in GBP"
|
||||||
|
|
||||||
- name: booking_fee_charge_at_utc
|
- name: booking_fee_charge_at_utc
|
||||||
data_type: timestamp without time zone
|
data_type: timestamp without time zone
|
||||||
description: |
|
description: |
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ select
|
||||||
is_duplicate_booking as is_duplicate_booking,
|
is_duplicate_booking as is_duplicate_booking,
|
||||||
booking_fee_local as booking_fee_local,
|
booking_fee_local as booking_fee_local,
|
||||||
account_currency_iso4217 as account_currency_iso4217,
|
account_currency_iso4217 as account_currency_iso4217,
|
||||||
|
booking_fee_in_gbp as booking_fee_in_gbp,
|
||||||
booking_fee_charge_at_utc as booking_fee_charge_at_utc,
|
booking_fee_charge_at_utc as booking_fee_charge_at_utc,
|
||||||
booking_fee_charge_date_utc as booking_fee_charge_date_utc
|
booking_fee_charge_date_utc as booking_fee_charge_date_utc
|
||||||
from int_core__host_booking_fees
|
from int_core__host_booking_fees
|
||||||
|
|
|
||||||
|
|
@ -1045,6 +1045,10 @@ models:
|
||||||
data_type: character varying
|
data_type: character varying
|
||||||
description: "Currency used by host/pm/platform users."
|
description: "Currency used by host/pm/platform users."
|
||||||
|
|
||||||
|
- name: booking_fee_in_gbp
|
||||||
|
data_type: numeric
|
||||||
|
description: "The fee to apply to the booking, in GBP"
|
||||||
|
|
||||||
- name: booking_fee_charge_at_utc
|
- name: booking_fee_charge_at_utc
|
||||||
data_type: timestamp without time zone
|
data_type: timestamp without time zone
|
||||||
description: |
|
description: |
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue