Modified filter and table used

This commit is contained in:
Joaquin Ossa 2024-08-01 14:32:45 +02:00
parent 0281e6e72e
commit 25e657014a
4 changed files with 11 additions and 13 deletions

View file

@ -8,9 +8,7 @@ with
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_daily_currency_exchange_rates as ( int_simple_exchange_rates as (select * from {{ ref("int_simple_exchange_rates") }})
select * from {{ ref("int_daily_currency_exchange_rates") }}
)
select select
b.id_booking, b.id_booking,
b.id_user_guest, b.id_user_guest,
@ -20,7 +18,7 @@ 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,
dcer.rate as rate_to_gbp, ser.rate * 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
@ -31,9 +29,9 @@ 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 -- 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 -- depending on the table and Postgres is case sensitive
left join left join
int_daily_currency_exchange_rates dcer int_simple_exchange_rates ser
on ( on (
dcer.from_currency = uu.account_currency_iso4217 ser.from_currency = uu.account_currency_iso4217
and dcer.rate_date_utc = bce.booking_fee_charge_date_utc and ser.rate_date_utc = bce.booking_fee_charge_date_utc
and ser.to_currency = 'GBP'
) )
where dcer.to_currency = 'GBP'

View file

@ -1643,9 +1643,9 @@ 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: rate_to_gbp - name: booking_fee_in_gbp
data_type: numeric data_type: numeric
description: "Exchange rate of the used currency to GBP on the charged date" 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

View file

@ -11,7 +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,
rate_to_gbp as rate_to_gbp, 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

View file

@ -1045,9 +1045,9 @@ 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: rate_to_gbp - name: booking_fee_in_gbp
data_type: numeric data_type: numeric
description: "Exchange rate of the used currency to GBP on the charged date" 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