Final update
This commit is contained in:
parent
cfc6971cb4
commit
465bd51ff2
4 changed files with 18 additions and 26 deletions
|
|
@ -125,30 +125,21 @@ with
|
|||
int_daily_currency_exchange_rates cer_gbp
|
||||
on dri.created_date_utc = cer_gbp.rate_date_utc
|
||||
and (cm.corrective_measure ->> 'Currency') = cer_gbp.from_currency
|
||||
and 'GBP' = cer.to_currency
|
||||
and cer.to_currency = 'GBP'
|
||||
group by dri.id_incident, dri.host_currency
|
||||
),
|
||||
guest_amounts_in_gbp as (
|
||||
select
|
||||
i.id_incident,
|
||||
(i.deposit_retained_amount_in_txn_currency * cer_deposit.rate)::decimal(
|
||||
(i.guest_contribution_amount_in_txn_currency * cer.rate)::decimal(
|
||||
19, 4
|
||||
) as deposit_retained_amount_in_gbp,
|
||||
(
|
||||
i.guest_contribution_amount_in_txn_currency * cer_contribution.rate
|
||||
)::decimal(19, 4) as guest_contribution_amount_in_gbp
|
||||
) as guest_contribution_amount_in_gbp
|
||||
from stg_resolutions__incidents i
|
||||
left join logs_timeline lt on i.id_incident = lt.id_incident
|
||||
left join
|
||||
int_daily_currency_exchange_rates cer_deposit
|
||||
on (lt.last_status_at_utc)::date = cer_deposit.rate_date_utc
|
||||
and cer_deposit.from_currency = i.deposit_retained_currency
|
||||
and cer_deposit.to_currency = 'GBP'
|
||||
left join
|
||||
int_daily_currency_exchange_rates cer_contribution
|
||||
on (lt.last_status_at_utc)::date = cer_contribution.rate_date_utc
|
||||
and cer_contribution.from_currency = i.guest_contribution_currency
|
||||
and cer_contribution.to_currency = 'GBP'
|
||||
int_daily_currency_exchange_rates cer
|
||||
on (i.calculation_at_utc)::date = cer.rate_date_utc
|
||||
and cer.from_currency = i.guest_contribution_currency
|
||||
and cer.to_currency = 'GBP'
|
||||
)
|
||||
|
||||
select
|
||||
|
|
@ -232,7 +223,6 @@ select
|
|||
i.is_guest_deposit_collected,
|
||||
i.deposit_retained_amount_in_txn_currency,
|
||||
i.deposit_retained_currency,
|
||||
ga.deposit_retained_amount_in_gbp,
|
||||
|
||||
-- Guest Involvements
|
||||
i.has_guest_contributed_to_cost,
|
||||
|
|
@ -261,6 +251,6 @@ left join damage_report dr on i.id_incident = dr.id_incident
|
|||
left join guest_amounts_in_gbp ga on i.id_incident = ga.id_incident
|
||||
left join
|
||||
int_daily_currency_exchange_rates cer
|
||||
on (lt.last_status_at_utc)::date = cer.rate_date_utc
|
||||
on (i.calculation_at_utc)::date = cer.rate_date_utc
|
||||
and cer.from_currency = 'USD'
|
||||
and cer.to_currency = 'GBP'
|
||||
|
|
|
|||
|
|
@ -328,14 +328,6 @@ models:
|
|||
- not_null:
|
||||
where: "deposit_retained_amount_in_txn_currency > 0"
|
||||
|
||||
- name: deposit_retained_amount_in_gbp
|
||||
data_type: numeric
|
||||
description: "Amount of the deposit retained in GBP."
|
||||
data_tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: false
|
||||
|
||||
- name: has_guest_contributed_to_cost
|
||||
data_type: boolean
|
||||
description: "If the guest has agreed to contribute to the cost
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue