Merged PR 4438: decimals issue with currency exchange rate

# Description

Fixing decimals issue with currency exchange rate

# 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.

decimals issue with currency exchange rate

Related work items: #27645
This commit is contained in:
Joaquin Ossa 2025-02-18 13:33:03 +00:00
commit 6e26a2a761
3 changed files with 31 additions and 16 deletions

View file

@ -256,6 +256,7 @@ select
vr.id_booking,
vr.id_user_partner,
vr.id_accommodation,
vr.company_name,
vr.is_protected,
vr.protection_type,
vr.protection_basic_amount_in_local_currency,
@ -273,33 +274,39 @@ select
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.nightly_fee_in_local_currency, 0) * vr.number_of_nights
+ coalesce(bbf.booking_fee_in_local_currency, 0)
)
* der.rate
)::decimal(19, 4) 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(bnf.nightly_fee_in_local_currency, 0)
* vr.number_of_nights
* coalesce(bnf.discount_percentage, 0)
/ 100
* der.rate
)::decimal(19, 4) 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.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
)::decimal(19, 4) 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,

View file

@ -378,6 +378,10 @@ models:
data_type: text
description: "Identifier for the accommodation related to the booking."
- name: company_name
data_type: text
description: Name of the company associated with the booking.
- name: is_protected
data_type: boolean
description: "Indicates if the booking is protected or not."

View file

@ -281,6 +281,10 @@ models:
data_type: text
description: "Identifier for the accommodation related to the booking."
- name: company_name
data_type: text
description: Name of the company associated with the booking.
- name: is_protected
data_type: boolean
description: "Indicates if the booking is protected or not."