Merged PR 2354: Main KPIs batch 2 exposure

This PR exposes the following metrics to the Main KPIs business overview report, for both Global + By Deal view:
- Total Revenue
- Total Revenue per Booking Created
- Total Revenue per Guest Journey Created
- Total Revenue per Deals Booked in Month (does not apply on the by deal view)
- Total Revenue per Listings Booked in Month
- Invoiced Operator Revenue
- Host Resolution Payment Count
- Host Resolution Amount Paid

Keep in mind Global view will be displaying these metrics once this is merged. I also changed a bit the order of the metric display.
Note that Billable Bookings are not included.

I recommend to review by 1) checking the first commit. This is almost the same as the previous abandoned PR that @<Joaquin Ossa> you already checked on Tuesday. I added a second commit, to be checked later, which basically fixes some stupid issues that if one of the source of revenue is null, then total revenue is null. This is specially critical for the view by deal, since most of them do not have revenue from APIs - thus all total revenue figures were null...

Related work items: #18108, #18109, #18110, #18719
This commit is contained in:
Oriol Roqué Paniagua 2024-07-19 09:14:30 +00:00
parent 361ad31299
commit ee13eda5f3
7 changed files with 207 additions and 80 deletions

View file

@ -23,7 +23,7 @@ from int_mtd_aggregated_metrics
The following where condition is applied to avoid displaying revenue metrics
in the MTD for the current month and the previous month. The main reason is
that we have a time delay between when the guest does a payment vs. when we
invoice or credit hosts (Xero).
invoice or credit hosts (Xero). Same applies for Host Resolutions.
This is specially tricky for the Host-takes-waiver revenue: guests payments
happen in a timely fashion, and we get all waiver money from the guests. Once
the month is finished, Finance will start to invoice hosts, and in this case,
@ -37,10 +37,9 @@ from int_mtd_aggregated_metrics
*/
where
(
-- Not show current + previous month if revenue metric
-- we need to pass +1 day to date since it's the last day of the month
lower(metric) like '%revenue%'
-- Not show current + previous month if revenue metric or resolution
(lower(metric) like '%revenue%' or lower(metric) like '%resolutions%')
and {{ is_date_before_previous_month("date") }}
)
-- Keep all history for the rest of metrics
or (lower(metric) not like '%revenue%')
or not (lower(metric) like '%revenue%' or lower(metric) like '%resolutions%')