updated monthly_aggregated_metrics_history_by_deal
This commit is contained in:
parent
1e37d04f72
commit
696ac24e35
2 changed files with 28 additions and 46 deletions
|
|
@ -1,18 +0,0 @@
|
|||
/*
|
||||
This macro provides a boolean answer to the question:
|
||||
- Is this date before the previous month?
|
||||
The computation is based on the current date by using now()
|
||||
|
||||
Inputs:
|
||||
- date: the date from which you want to check
|
||||
Output:
|
||||
- boolean; true for is before the previous month
|
||||
false for is not before the previous month
|
||||
*/
|
||||
{% macro is_date_before_previous_month(date) %}
|
||||
(
|
||||
date_trunc('month', ({{ date }})::date)::date
|
||||
+ interval '1 month'
|
||||
)::date
|
||||
< date_trunc('month', now())::date
|
||||
{% endmacro %}
|
||||
|
|
@ -32,32 +32,32 @@ select
|
|||
listings_booked_in_12_months as listings_booked_in_12_months,
|
||||
-- Avoid displaying revenue figures until invoicing period finishes
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then total_revenue_in_gbp
|
||||
else null
|
||||
end as total_revenue_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then total_revenue_per_created_booking
|
||||
else null
|
||||
end as total_revenue_per_created_booking,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then total_revenue_per_created_guest_journey
|
||||
else null
|
||||
end as total_revenue_per_created_guest_journey,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then total_revenue_per_listings_booked_in_month
|
||||
else null
|
||||
end as total_revenue_per_listings_booked_in_month,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_operator_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_operator_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_apis_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_apis_net_fees_in_gbp,
|
||||
|
|
@ -66,92 +66,92 @@ select
|
|||
as guest_revenue_per_completed_guest_journey,
|
||||
guest_payments_per_paid_guest_journey as guest_revenue_per_paid_guest_journey,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_host_resolution_amount_paid_in_gbp
|
||||
else null
|
||||
end as xero_host_resolution_amount_paid_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_host_resolution_payment_count
|
||||
else null
|
||||
end as xero_host_resolution_payment_count,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then host_resolution_amount_paid_per_created_booking
|
||||
else null
|
||||
end as host_resolution_amount_paid_per_created_booking,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then host_resolution_payment_per_created_booking_ratio
|
||||
else null
|
||||
end as host_resolution_payment_per_created_booking_ratio,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_booking_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_booking_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_listing_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_listing_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_verification_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_verification_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_basic_protection_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_basic_protection_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_waiver_pro_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_waiver_pro_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_id_verification_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_id_verification_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_protection_plus_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_protection_plus_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_screening_plus_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_screening_plus_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_sex_offenders_check_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_sex_offenders_check_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_protection_pro_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_protection_pro_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_guesty_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_guesty_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_e_deposit_net_fees_in_gbp
|
||||
else null
|
||||
end as xero_e_deposit_net_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then xero_waiver_paid_back_to_host_in_gbp
|
||||
else null
|
||||
end as xero_waiver_paid_back_to_host_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then waiver_net_fees_in_gbp
|
||||
else null
|
||||
end as waiver_net_fees_in_gbp,
|
||||
|
|
@ -159,22 +159,22 @@ select
|
|||
waiver_payments_in_gbp as waiver_payments_in_gbp,
|
||||
checkin_cover_fees_in_gbp as checkin_cover_fees_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then revenue_retained_in_gbp
|
||||
else null
|
||||
end as revenue_retained_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then revenue_retained_ratio
|
||||
else null
|
||||
end as revenue_retained_ratio,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then revenue_retained_post_resolutions_in_gbp
|
||||
else null
|
||||
end as revenue_retained_post_resolutions_in_gbp,
|
||||
case
|
||||
when {{ is_date_before_previous_month("date") }}
|
||||
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||
then revenue_retained_post_resolutions_ratio
|
||||
else null
|
||||
end as revenue_retained_post_resolutions_ratio
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue