From ae410b4dc562860fb22426f051e1256d9c0f443b Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 18 Feb 2025 14:25:56 +0100 Subject: [PATCH] decimals issue with currency exchange rate --- ..._screen_and_protect__verification_fees.sql | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/models/intermediate/screen_and_protect/int_screen_and_protect__verification_fees.sql b/models/intermediate/screen_and_protect/int_screen_and_protect__verification_fees.sql index f781140..bd24592 100644 --- a/models/intermediate/screen_and_protect/int_screen_and_protect__verification_fees.sql +++ b/models/intermediate/screen_and_protect/int_screen_and_protect__verification_fees.sql @@ -273,33 +273,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,