From 79b408f3d2ae3de282299badfd3887828e73f817 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Fri, 20 Dec 2024 11:18:52 +0100 Subject: [PATCH] update booking_fee calculation --- .../int_screen_and_protect__invoice.sql | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/models/intermediate/screen_and_protect/int_screen_and_protect__invoice.sql b/models/intermediate/screen_and_protect/int_screen_and_protect__invoice.sql index 63fa2d8..c1edd20 100644 --- a/models/intermediate/screen_and_protect/int_screen_and_protect__invoice.sql +++ b/models/intermediate/screen_and_protect/int_screen_and_protect__invoice.sql @@ -49,7 +49,7 @@ with then 1 else 0 end as is_price_increase_active - from intermediate.int_screen_and_protect__verification_requests vr + from int_screen_and_protect__verification_requests vr where upper(vr.verification_status) in {{ approved_flagged_status }} ), approved_verifications as ( @@ -57,7 +57,7 @@ with vr.id_user_partner, date_trunc('month', vr.checkout_date_utc) as verification_month, count(*) as monthly_verifications - from intermediate.int_screen_and_protect__verification_requests vr + from int_screen_and_protect__verification_requests vr where upper(vr.verification_status) in {{ approved_flagged_status }} group by vr.id_user_partner, date_trunc('month', vr.checkout_date_utc) ), @@ -97,11 +97,19 @@ select then bp.long_stay_fee_in_local_currency * vr.number_of_nights + * (1 + vr.price_increase / 100 * ad.is_price_increase_active) * ( 1 - - vr.monthly_volume_discount * ad.is_monthly_volume_discount_active - - vr.monthly_general_discount * ad.is_monthly_general_discount_active - + vr.price_increase * ad.is_price_increase_active + - vr.monthly_volume_discount + / 100 + * ad.is_monthly_volume_discount_active + ) + * ( + 1 + - vr.monthly_general_discount + / 100 + * ad.is_monthly_general_discount_active + + vr.price_increase / 100 * ad.is_price_increase_active ) when upper(vr.verification_status) in {{ approved_flagged_status }} @@ -109,11 +117,19 @@ select then bp.short_stay_fee_in_local_currency * vr.number_of_nights + * (1 + vr.price_increase / 100 * ad.is_price_increase_active) * ( 1 - - vr.monthly_volume_discount * ad.is_monthly_volume_discount_active - - vr.monthly_general_discount * ad.is_monthly_general_discount_active - + vr.price_increase * ad.is_price_increase_active + - vr.monthly_volume_discount + / 100 + * ad.is_monthly_volume_discount_active + ) + * ( + 1 + - vr.monthly_general_discount + / 100 + * ad.is_monthly_general_discount_active + + vr.price_increase / 100 * ad.is_price_increase_active ) else 0 end as booking_fee_in_local_currency,