From ae410b4dc562860fb22426f051e1256d9c0f443b Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 18 Feb 2025 14:25:56 +0100 Subject: [PATCH 1/2] 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, From b3739ec95324140369d946cc71f6d8594246a1f8 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 18 Feb 2025 14:31:57 +0100 Subject: [PATCH 2/2] Added company_name --- .../int_screen_and_protect__verification_fees.sql | 1 + models/intermediate/screen_and_protect/schema.yml | 4 ++++ models/reporting/screen_and_protect/schema.yml | 4 ++++ 3 files changed, 9 insertions(+) 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 bd24592..a5629e2 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 @@ -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, diff --git a/models/intermediate/screen_and_protect/schema.yml b/models/intermediate/screen_and_protect/schema.yml index 496c155..ab2eff2 100644 --- a/models/intermediate/screen_and_protect/schema.yml +++ b/models/intermediate/screen_and_protect/schema.yml @@ -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." diff --git a/models/reporting/screen_and_protect/schema.yml b/models/reporting/screen_and_protect/schema.yml index d994c4f..24da229 100644 --- a/models/reporting/screen_and_protect/schema.yml +++ b/models/reporting/screen_and_protect/schema.yml @@ -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."