Simplified it

This commit is contained in:
Joaquin Ossa 2024-09-16 16:20:36 +02:00
parent c3e4a07050
commit b21590ab1d
3 changed files with 41 additions and 47 deletions

View file

@ -40,7 +40,7 @@ with
then vp.amount_without_taxes_in_gbp
else null
end
) as deposit_fees_without_taxes_in_gbp,
) as deposit_fees_in_gbp,
sum(
case
when
@ -49,7 +49,7 @@ with
then vp.amount_without_taxes_in_gbp
else null
end
) as waiver_payments_without_taxes_in_gbp,
) as waiver_payments_in_gbp,
sum(
case
when
@ -58,7 +58,7 @@ with
then vp.amount_without_taxes_in_gbp
else null
end
) as checkin_cover_fees_without_taxes_in_gbp
) as checkin_cover_fees_in_gbp
from int_dates_mtd d
inner join
int_core__verification_payments vp
@ -94,21 +94,15 @@ select
d.dimension_value,
d.is_end_of_month,
d.is_current_month,
nullif(gpym.deposit_fees_in_gbp, 0) as deposit_fees_in_gbp,
nullif(gpym.waiver_payments_in_gbp, 0) as waiver_payments_in_gbp,
nullif(gpym.checkin_cover_fees_in_gbp, 0) as checkin_cover_fees_in_gbp,
nullif(
gpym.deposit_fees_without_taxes_in_gbp, 0
) as deposit_fees_without_taxes_in_gbp,
nullif(
gpym.waiver_payments_without_taxes_in_gbp, 0
) as waiver_payments_without_taxes_in_gbp,
nullif(
gpym.checkin_cover_fees_without_taxes_in_gbp, 0
) as checkin_cover_fees_without_taxes_in_gbp,
nullif(
coalesce(gpym.deposit_fees_without_taxes_in_gbp, 0)
+ coalesce(gpym.waiver_payments_without_taxes_in_gbp, 0)
+ coalesce(gpym.checkin_cover_fees_without_taxes_in_gbp, 0),
coalesce(gpym.deposit_fees_in_gbp, 0)
+ coalesce(gpym.waiver_payments_in_gbp, 0)
+ coalesce(gpym.checkin_cover_fees_in_gbp, 0),
0
) as total_guest_payments_without_taxes_in_gbp
) as total_guest_payments_in_gbp
from int_dates_mtd_by_dimension d
left join
guest_payments_year_month gpym