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,
|
listings_booked_in_12_months as listings_booked_in_12_months,
|
||||||
-- Avoid displaying revenue figures until invoicing period finishes
|
-- Avoid displaying revenue figures until invoicing period finishes
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then total_revenue_in_gbp
|
then total_revenue_in_gbp
|
||||||
else null
|
else null
|
||||||
end as total_revenue_in_gbp,
|
end as total_revenue_in_gbp,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then total_revenue_per_created_booking
|
then total_revenue_per_created_booking
|
||||||
else null
|
else null
|
||||||
end as total_revenue_per_created_booking,
|
end as total_revenue_per_created_booking,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then total_revenue_per_created_guest_journey
|
then total_revenue_per_created_guest_journey
|
||||||
else null
|
else null
|
||||||
end as total_revenue_per_created_guest_journey,
|
end as total_revenue_per_created_guest_journey,
|
||||||
case
|
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
|
then total_revenue_per_listings_booked_in_month
|
||||||
else null
|
else null
|
||||||
end as total_revenue_per_listings_booked_in_month,
|
end as total_revenue_per_listings_booked_in_month,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then xero_operator_net_fees_in_gbp
|
then xero_operator_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_operator_net_fees_in_gbp,
|
end as xero_operator_net_fees_in_gbp,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then xero_apis_net_fees_in_gbp
|
then xero_apis_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_apis_net_fees_in_gbp,
|
end as xero_apis_net_fees_in_gbp,
|
||||||
|
|
@ -66,92 +66,92 @@ select
|
||||||
as guest_revenue_per_completed_guest_journey,
|
as guest_revenue_per_completed_guest_journey,
|
||||||
guest_payments_per_paid_guest_journey as guest_revenue_per_paid_guest_journey,
|
guest_payments_per_paid_guest_journey as guest_revenue_per_paid_guest_journey,
|
||||||
case
|
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
|
then xero_host_resolution_amount_paid_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_host_resolution_amount_paid_in_gbp,
|
end as xero_host_resolution_amount_paid_in_gbp,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then xero_host_resolution_payment_count
|
then xero_host_resolution_payment_count
|
||||||
else null
|
else null
|
||||||
end as xero_host_resolution_payment_count,
|
end as xero_host_resolution_payment_count,
|
||||||
case
|
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
|
then host_resolution_amount_paid_per_created_booking
|
||||||
else null
|
else null
|
||||||
end as host_resolution_amount_paid_per_created_booking,
|
end as host_resolution_amount_paid_per_created_booking,
|
||||||
case
|
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
|
then host_resolution_payment_per_created_booking_ratio
|
||||||
else null
|
else null
|
||||||
end as host_resolution_payment_per_created_booking_ratio,
|
end as host_resolution_payment_per_created_booking_ratio,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then xero_booking_net_fees_in_gbp
|
then xero_booking_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_booking_net_fees_in_gbp,
|
end as xero_booking_net_fees_in_gbp,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then xero_listing_net_fees_in_gbp
|
then xero_listing_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_listing_net_fees_in_gbp,
|
end as xero_listing_net_fees_in_gbp,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then xero_verification_net_fees_in_gbp
|
then xero_verification_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_verification_net_fees_in_gbp,
|
end as xero_verification_net_fees_in_gbp,
|
||||||
case
|
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
|
then xero_basic_protection_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_basic_protection_net_fees_in_gbp,
|
end as xero_basic_protection_net_fees_in_gbp,
|
||||||
case
|
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
|
then xero_waiver_pro_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_waiver_pro_net_fees_in_gbp,
|
end as xero_waiver_pro_net_fees_in_gbp,
|
||||||
case
|
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
|
then xero_id_verification_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_id_verification_net_fees_in_gbp,
|
end as xero_id_verification_net_fees_in_gbp,
|
||||||
case
|
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
|
then xero_protection_plus_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_protection_plus_net_fees_in_gbp,
|
end as xero_protection_plus_net_fees_in_gbp,
|
||||||
case
|
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
|
then xero_screening_plus_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_screening_plus_net_fees_in_gbp,
|
end as xero_screening_plus_net_fees_in_gbp,
|
||||||
case
|
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
|
then xero_sex_offenders_check_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_sex_offenders_check_net_fees_in_gbp,
|
end as xero_sex_offenders_check_net_fees_in_gbp,
|
||||||
case
|
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
|
then xero_protection_pro_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_protection_pro_net_fees_in_gbp,
|
end as xero_protection_pro_net_fees_in_gbp,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then xero_guesty_net_fees_in_gbp
|
then xero_guesty_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_guesty_net_fees_in_gbp,
|
end as xero_guesty_net_fees_in_gbp,
|
||||||
case
|
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
|
then xero_e_deposit_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_e_deposit_net_fees_in_gbp,
|
end as xero_e_deposit_net_fees_in_gbp,
|
||||||
case
|
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
|
then xero_waiver_paid_back_to_host_in_gbp
|
||||||
else null
|
else null
|
||||||
end as xero_waiver_paid_back_to_host_in_gbp,
|
end as xero_waiver_paid_back_to_host_in_gbp,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then waiver_net_fees_in_gbp
|
then waiver_net_fees_in_gbp
|
||||||
else null
|
else null
|
||||||
end as waiver_net_fees_in_gbp,
|
end as waiver_net_fees_in_gbp,
|
||||||
|
|
@ -159,22 +159,22 @@ select
|
||||||
waiver_payments_in_gbp as waiver_payments_in_gbp,
|
waiver_payments_in_gbp as waiver_payments_in_gbp,
|
||||||
checkin_cover_fees_in_gbp as checkin_cover_fees_in_gbp,
|
checkin_cover_fees_in_gbp as checkin_cover_fees_in_gbp,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then revenue_retained_in_gbp
|
then revenue_retained_in_gbp
|
||||||
else null
|
else null
|
||||||
end as revenue_retained_in_gbp,
|
end as revenue_retained_in_gbp,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then revenue_retained_ratio
|
then revenue_retained_ratio
|
||||||
else null
|
else null
|
||||||
end as revenue_retained_ratio,
|
end as revenue_retained_ratio,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then revenue_retained_post_resolutions_in_gbp
|
then revenue_retained_post_resolutions_in_gbp
|
||||||
else null
|
else null
|
||||||
end as revenue_retained_post_resolutions_in_gbp,
|
end as revenue_retained_post_resolutions_in_gbp,
|
||||||
case
|
case
|
||||||
when {{ is_date_before_previous_month("date") }}
|
when {{ is_date_before_20th_of_previous_month("date") }}
|
||||||
then revenue_retained_post_resolutions_ratio
|
then revenue_retained_post_resolutions_ratio
|
||||||
else null
|
else null
|
||||||
end as revenue_retained_post_resolutions_ratio
|
end as revenue_retained_post_resolutions_ratio
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue