update booking_fee calculation

This commit is contained in:
Joaquin Ossa 2024-12-20 11:18:52 +01:00
parent 3d2477f8f9
commit 79b408f3d2

View file

@ -49,7 +49,7 @@ with
then 1 then 1
else 0 else 0
end as is_price_increase_active 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 }} where upper(vr.verification_status) in {{ approved_flagged_status }}
), ),
approved_verifications as ( approved_verifications as (
@ -57,7 +57,7 @@ with
vr.id_user_partner, vr.id_user_partner,
date_trunc('month', vr.checkout_date_utc) as verification_month, date_trunc('month', vr.checkout_date_utc) as verification_month,
count(*) as monthly_verifications 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 }} where upper(vr.verification_status) in {{ approved_flagged_status }}
group by vr.id_user_partner, date_trunc('month', vr.checkout_date_utc) group by vr.id_user_partner, date_trunc('month', vr.checkout_date_utc)
), ),
@ -97,11 +97,19 @@ select
then then
bp.long_stay_fee_in_local_currency bp.long_stay_fee_in_local_currency
* vr.number_of_nights * vr.number_of_nights
* (1 + vr.price_increase / 100 * ad.is_price_increase_active)
* ( * (
1 1
- vr.monthly_volume_discount * ad.is_monthly_volume_discount_active - vr.monthly_volume_discount
- vr.monthly_general_discount * ad.is_monthly_general_discount_active / 100
+ vr.price_increase * ad.is_price_increase_active * 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 when
upper(vr.verification_status) in {{ approved_flagged_status }} upper(vr.verification_status) in {{ approved_flagged_status }}
@ -109,11 +117,19 @@ select
then then
bp.short_stay_fee_in_local_currency bp.short_stay_fee_in_local_currency
* vr.number_of_nights * vr.number_of_nights
* (1 + vr.price_increase / 100 * ad.is_price_increase_active)
* ( * (
1 1
- vr.monthly_volume_discount * ad.is_monthly_volume_discount_active - vr.monthly_volume_discount
- vr.monthly_general_discount * ad.is_monthly_general_discount_active / 100
+ vr.price_increase * ad.is_price_increase_active * 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 else 0
end as booking_fee_in_local_currency, end as booking_fee_in_local_currency,