Update mtd_aggregated_metrics

This commit is contained in:
Joaquin Ossa 2024-09-16 16:01:49 +02:00
parent 60ea19f5ef
commit c3e4a07050
3 changed files with 47 additions and 41 deletions

View file

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