Commit graph

531 commits

Author SHA1 Message Date
Joaquin Ossa
4d5af3ba21 Added verification_request_booking_source to int_core__guest_satisfaction_responses model 2024-07-12 12:38:52 +02:00
Oriol Roqué Paniagua
2130226939 Merged PR 2284: KPIs: computing invoicing metrics from Xero
This PR creates 2 new models on intermediate, xero:
- int_xero__mtd_invoicing_metrics (global view)
- int_xero__monthly_invoicing_history_by_deal (by deal view)

This allows for the computation of host metrics (operators), as well as host resolution payments. This will enable in the future to compute total revenue and weighted revenue metrics.
The data displayed from the previous months in the mtd_invoicing_metrics is consistent with 1) revenue figures displayed in business overview for Host tab, as well as Guest tab for Waiver Payments; and 2) host payment figures displayed in the accounting reports.

**Note 1**: the variables at this stage are reused in these models, as well as many other Xero models. We still need to handle the refactor ticket on Xero related reports. This is not under the scope of this PR.

**Note 2**: we noticed that the strategy for mtd models to do a double year, month extraction join is badly performant. Actually, resolution payments subquery was not performing at all with this logic. So it has been changed to a date_trunc('month', related_date)::date = d.first_day_month strategy which works much faster. I'll add a standalone PR to refactor the remaining mtd models separately later

Related work items: #18108, #18110
2024-07-12 10:05:49 +00:00
Joaquin Ossa
725dadd0a3 Merged PR 2275: Created model int_core__verification_request_booking_source to have easier ac...
Created model int_core__verification_request_booking_source to have easier access to host category type in different models

Related work items: #17200
2024-07-12 09:12:28 +00:00
Joaquin Ossa
cf467145d0 Fixed schema names 2024-07-12 11:06:09 +02:00
Joaquin Ossa
3001db919a Added models in schema for intermediate 2024-07-12 10:11:51 +02:00
Joaquin Ossa
2bfe3ccf3c Added the new field to int_core__bookings and to int_core__verification_requests 2024-07-11 17:16:51 +02:00
Joaquin Ossa
70c2c5f6bf Removed guests_id and modified query structure 2024-07-11 16:49:24 +02:00
Joaquin Ossa
00502b1597 Removed bookings_id so we have unique values for id_verification_request, added details as to how we classify the hosts 2024-07-11 16:26:41 +02:00
Joaquin Ossa
db04615039 Removed bookings_id so we have unique values for id_verification_request, added details as to how we classify the hosts 2024-07-11 16:19:33 +02:00
Joaquin Ossa
5efd91dfbb Created model int_core__verification_request_booking_source to have easier access to host category type in different models 2024-07-11 15:36:32 +02:00
Oriol Roqué Paniagua
0c1535b150 Merged PR 2267: Business KPIs refactor - cleaning
This PR cleans the unused models in reporting that keep the "core" wrong convention. Also drops schema documentation for these.
Lastly, exposures have been updated to point towards the new production models.

- This is the last PR for the refactor! ![dbt-dag (2).png](https://guardhog.visualstudio.com/4148d95f-4b6d-4205-bcff-e9c8e0d2ca65/_apis/git/repositories/54ac356f-aad7-46d2-b62c-e8c5b3bb8ebf/pullRequests/2267/attachments/dbt-dag%20%282%29.png)

Refactor documentation: https://www.notion.so/knowyourguest-superhog/Refactoring-Business-KPIs-5deb6aadddb34884ae90339402ac16e3

Related work items: #18202
2024-07-11 09:17:44 +00:00
Joaquin Ossa
b4a7089070 Merged PR 2266: Added report to exposure.yaml
Added Guest Satisfaction report to exposure.yaml
2024-07-11 07:53:45 +00:00
Joaquin Ossa
9a74e21783 Fixed description 2024-07-11 09:53:01 +02:00
Joaquin Ossa
f96587dc33 Added report to exposure.yaml 2024-07-11 09:07:22 +02:00
Oriol Roqué Paniagua
859b0f7573 Merged PR 2264: Remove (GBP) from metric name
Remove (GBP) from metric name

Related work items: #18107
2024-07-10 16:10:07 +00:00
Oriol Roqué Paniagua
3b75d9eefb Merged PR 2257: Expose guest revenue and guest journey payment metrics
This PR aims to expose the new metrics to the business KPIs report.
The new metrics exposed are, for the global and the by deal view:
- Guest Revenue
- Guest Revenue per Guest Journey Completed
- Guest Revenue per Guest Journey with Payment
- Guest Payments
- Guest Payments per Guest Journey Completed
- Guest Payments per Guest Journey with Payment
- Guest Journey with Payment
- Guest Journey Payment Rate

Changes:
- Silly change on the naming in the by deal view of `payment_rate_guest_journey` to be consistent with the global view.
- Silly change that I miss some GJ payment metric for the view by deal id.
- Added a new number format called `currency_gbp` - only for monetary metrics, available in the schema files
- Usual procedure to publish metrics: for global metrics, add them in the `int_mtd_aggregated_metrics`. I also changed the order of display.
- **Important**: to avoid displaying revenue figures until Xero invoicing is handled, I created a macro called `is_date_before_previous_month` that is called in the reporting equivalent models: `mtd_aggregated_metrics` in the where section and in the `monthly_aggregated_metrics_history_by_deal` as a case-when.

This should allow to expose all new metrics, and enable the publishing of a new update of the business kpis!

Related work items: #18107
2024-07-10 14:17:05 +00:00
Oriol Roqué Paniagua
d39bc02ae1 Merged PR 2252: Propagate guest revenue metrics to intermediate
This PR aims to propagate the computation of guest revenue model into the aggregated models.
Changes:
- I changed the logic on `int_mtd_guest_revenue_metrics` since it was still using the old computation of the relative increment within the same model. Basically, I removed it (last part of the query). The rest of changes in this model are just formatting.
- I also applied the formatting in the int_mtd_vs_previous_year_metrics, mainly changing the macro calls from **'**xyz**'** to **"**xyz**"**.

What's new:
- `int_mtd_guest_revenue_metrics` into `int_mtd_vs_previous_year_metrics`, by adding `total_guest_revenue_in_gbp` and `total_guest_payments_in_gbp`. Additionally, with the new logic, for the first time we're able to compute **weighted metrics** coming from different sources. Specifically, it computes the weighted measures per guest journey completed and guest journey with payment.
- Similar behavior on the 'by deal', adding `int_monthly_guest_revenue_history_by_deal` into `int_monthly_aggregated_metrics` and similar computation

This model does not affect the exposing logic still, meaning these metrics won't be exposed in the report. This will come in a separated PR.

Related work items: #18107
2024-07-10 08:52:19 +00:00
Oriol Roqué Paniagua
20e7220ffe Merged PR 2246: KPIs refactor: naming convention and PBI sources replication
Changing naming to follow convention.
This PR has the following changes:
- the model `int_core__mtd_aggregated_metrics` has been moved to cross and changed the name to `int_mtd_aggregated_metrics`
- the model `int_core__monthly_aggregated_metrics_history_by_deal` has been moved to cross and changed the name to `int_monthly_aggregated_metrics_history_by_deal`
- the reporting models `core__mtd_aggregated_metrics` and `core__monthly_aggregated_metrics_history_by_deal` now source the `int_mtd_aggregated_metrics` and `int_monthly_aggregated_metrics_history_by_deal` to avoid breaking the production dashboard
- the reporting models have been duplicated from core into general with the correct names, i.e., `mtd_aggregated_metrics` and `monthly_aggregated_metrics_history_by_deal`
- Documentation has been moved in intermediate and replicated in reporting, adding comments on the currently in use models that are going to die soon.

This will allow for a transition of the PBI dashboard from one source to another. Exposures file still not touched since technically the report is still sourcing the 'legacy' models. Documentation of the refactor here: https://www.notion.so/knowyourguest-superhog/Refactoring-Business-KPIs-5deb6aadddb34884ae90339402ac16e3

Related work items: #18202
2024-07-09 15:14:50 +00:00
Pablo Martín
976ac70949 Merged PR 2245: Xero Sales Mart to reporting
Simply brings the Xero intermediate sales mart model to reporting, as is.

Related work items: #17550
2024-07-09 13:43:59 +00:00
Pablo Martin
1d63e187c2 model and docs 2024-07-09 15:31:47 +02:00
Oriol Roqué Paniagua
ca8334f1da Merged PR 2236: Refactor of already exposed metrics: listings, deals and guest journeys
Following yesterday's refactor of booking metrics, this PR provides a refactor of already exposed metrics: listings, deals and guest journeys.
-> Data is consistent with values already exposed.

Changes:
- for `int_core__mtd_listing_metrics`, `int_core__mtd_deal_metrics` and `int_core__mtd_guest_journey_metrics`:
1. remove the computation of the previous year metric value and the relative increment (last part of the query)
2. re-apply the formatting
- for `int_mtd_vs_previous_year_metrics`:
1. Reference listings, deals and GJ models
2. Include the metrics for these types in the `plain_kpi_combination` CTE
3. Add the computation of previous year and relative increment using the macro
- for `int_core__mtd_aggregated_metrics`
1. Remove and "hardcode" sources since all metrics now depend exclusively of `int_mtd_vs_previous_year_metrics`

This PR does not alter the exposed metrics in the production report. It does not aim to change the name of the reporting/intermediate models that expose the information, it will be done in a separated PR.
Documentation: https://www.notion.so/knowyourguest-superhog/Refactoring-Business-KPIs-5deb6aadddb34884ae90339402ac16e3

Related work items: #18202
2024-07-09 13:00:43 +00:00
Oriol Roqué Paniagua
409ac47591 Merged PR 2232: KPI refactor - 1st step, bookings
First step on refactor of kpis:
- Remove relative incremental vs. previous year computation from the source model (`mtd_booking_metrics`, in this case)
- Aggregate the source mtd global metrics models into a single model: `int_mtd_vs_previous_year_metrics` (to enable multi-source weighted metric computation) and compute previous year value and relative increment. Now this logic is encapsulated into a macro `calculate_safe_relative_increment`, easing readability and providing a bit more robustness.
- End-to-end continuity to not break the existing dashboard display in `int_core__mtd_aggregated_metrics`

This is a substep of the global change. All info can be found in the documentation [here](https://www.notion.so/knowyourguest-superhog/Refactoring-Business-KPIs-5deb6aadddb34884ae90339402ac16e3)

Related work items: #18202
2024-07-08 15:58:36 +00:00
Pablo Martín
62ad19ea9e Merged PR 2231: Xero Sales Mart
This PR implements a denormalized view of Xero invoice and credit notes data.

This is done because this shaped of data will both enable very simple reporting on some accounting reports, as well as easier modeling in some of the KPIs effort.

I also included a tiny change on dates and times in the invoice models.

Related work items: #17550
2024-07-08 15:52:24 +00:00
Pablo Martin
fad85691f3 typo in docs 2024-07-08 17:52:15 +02:00
Pablo Martin
00b7940c25 more schema, more tests 2024-07-08 17:26:10 +02:00
Pablo Martin
003c7cd185 remove duplicated currency field 2024-07-08 17:26:02 +02:00
Pablo Martin
6fcc9fde16 schema 2024-07-08 17:06:23 +02:00
Pablo Martin
a79288a657 add contact data 2024-07-08 16:55:46 +02:00
Pablo Martin
42811b6c7e propagate field in reporting layer 2024-07-08 16:48:39 +02:00
Pablo Martin
da7b931e8e include header data 2024-07-08 16:47:44 +02:00
Pablo Martin
ff09b2d7a4 propagate field to int 2024-07-08 16:31:53 +02:00
Pablo Martin
43a7ead6d3 missing field in stg 2024-07-08 16:29:35 +02:00
Pablo Martin
7fb5bc90d8 join credit notes 2024-07-08 16:17:20 +02:00
Pablo Martin
0b05f8cb62 join invoices 2024-07-08 16:16:21 +02:00
Pablo Martin
b08695795d line item level 2024-07-08 16:13:37 +02:00
Oriol Roqué Paniagua
d2b0afdca6 Merged PR 2221: Computes (paid) guest revenue metric - fixed
IMPORTANT: this PR was merged and reverted. The division by 0 error has been fixed in the last commit

Adds the following metrics:
- Guest Revenue

by both visions (global and by deal id)
It creates 2 new models:
- int_mtd_guest_revenue_metrics
- int_monthly_guest_revenue_history_by_deal

the approaches are similar in the sense that we retrieve the information from the int_core__verification_payments and a filter by a PAID status. I checked and the aggregated volumes of the figures correspond to the decimal as what is reported to the guest_payments dashboard (aggregating the information from the currency tab)

Same as last PR, this one does not exposes the data since a refactor of how the code is structured will follow shortly.

Related work items: #18107
2024-07-08 11:02:02 +00:00
Joaquin Ossa
e214641b9f Merged PR 2218: Fixed join on model taking id_verification instead of id_verification_request
Fixed join on model taking id_verification instead of id_verification_request

Related work items: #16947
2024-07-05 15:41:55 +00:00
Joaquin Ossa
03dbe60b38 Fixed join on model taking id_verification instead of id_verification_request 2024-07-05 17:24:06 +02:00
Oriol Roqué Paniagua
49a3c39b82 Merged PR 2217: Revert 'Computes (paid) guest revenue metric'
Adds the following metrics:

- Guest Revenue
by both visions (global and by deal id)

It creates 2 new models:
- int_core__mtd_guest_revenue_metrics
- int_core__monthly_guest_revenue_history_by_deal

the approaches are similar in the sense that we retrieve the information from the int_core__verification_payments and a filter by a PAID status. I checked and the aggregated volumes of the figures correspond to the decimal as what is reported to the guest_payments dashboard (aggregating the information from the currency tab)

Same as last PR, this one does not exposes the data since a refactor of how the code is structured will follow shortly.

Reverts !2199

Related work items: #18107
2024-07-05 15:19:35 +00:00
Joaquin Ossa
34df8a7ef9 Merged PR 2201: Fixing errors raised by texts
Tiny PR to fix errors raised by texts
2024-07-05 15:12:04 +00:00
Oriol Roqué Paniagua
d1362bb1db Merged PR 2199: Computes (paid) guest revenue metric
Adds the following metrics:

- Guest Revenue
by both visions (global and by deal id)

It creates 2 new models:
- int_core__mtd_guest_revenue_metrics
- int_core__monthly_guest_revenue_history_by_deal

the approaches are similar in the sense that we retrieve the information from the int_core__verification_payments and a filter by a PAID status. I checked and the aggregated volumes of the figures correspond to the decimal as what is reported to the guest_payments dashboard (aggregating the information from the currency tab)

Same as last PR, this one does not exposes the data since a refactor of how the code is structured will follow shortly.

Related work items: #18107
2024-07-05 15:01:21 +00:00
Joaquin Ossa
2738c8617d Fixing errors raised by texts 2024-07-04 16:41:41 +02:00
Joaquin Ossa
2efc1d8b65 Merged PR 2178: New model for guests satisfaction report
New model for guests satisfaction report, I included columns to check what is the guest paying for that might be helpful for analysis as well

Related work items: #16947
2024-07-04 10:13:11 +00:00
Joaquin Ossa
2c366414ce Merged PR 2188: Added date of adaptation
Added date of adaptation when hosts first started using check-in cover
2024-07-04 10:08:13 +00:00
Oriol Roqué Paniagua
1781031c9d Merged PR 2195: Computes GJ with Payment and GJ Payment Rate metrics
Adds the following metrics:
- Guest Journey with Payment
- Guest Journey Payment Rate

by both visions (global and by deal id)

**Important**: it does not expose these metrics to the dashboard, this will be done after we have feedback from Ben R. on the paid GJ without GJ completeness. Missing steps to make them appear is to adapt `int_core__mtd_aggregated_metrics` and `int_core__monthly_aggregated_metrics_history_by_deal` and the respective reporting counterparts.

It adapts:
- `int_core__mtd_guest_journey_metrics`
- `int_core__monthly_guest_journey_history_by_deal`

the approaches are similar in the sense that we join with `int_core__verification_payments` and filter by a PAID status, that has been defined in the `dbt_project.yml` in a similar manner as we did with cancelled bookings. It can happen that the same verification request has multiple payments (see screenshot), which in this case we keep the first date in which the paid payment happens. The volume is quite low anyway.

![image.png](https://guardhog.visualstudio.com/4148d95f-4b6d-4205-bcff-e9c8e0d2ca65/_apis/git/repositories/54ac356f-aad7-46d2-b62c-e8c5b3bb8ebf/pullRequests/2195/attachments/image.png)
code for the screenshot:

```
with pre as (
select
	id_verification_request,
	count(distinct icvp.id_payment) as total_paid_payments
from intermediate.int_core__verification_payments icvp
where icvp.payment_status = 'Paid'
group by 1
)
select
	case when total_paid_payments > 2 then 'more than 2'
	when total_paid_payments = 2 then '2'
	when total_paid_payments = 1 then '1'
	end as payment_volume_category,
	count(1) as vr_volume
from pre
group by 1
order by 2 desc
```

I also added a missing reference in `schema.yaml` int about `int_core__mtd_guest_journey_metrics`

Related work items: #18105
2024-07-04 09:54:41 +00:00
Joaquin Ossa
205bc6534d Modified date name to stick to convention 2024-07-04 08:24:23 +02:00
Joaquin Ossa
6bc26a66ff Changed date name to check_in_cover_added_date and included model in reporting 2024-07-03 17:43:27 +02:00
Joaquin Ossa
5bd6a2c254 Changed case to coalesce 2024-07-03 17:38:00 +02:00
Joaquin Ossa
3b22832d8b Created model in reporting as well with schema 2024-07-03 16:34:33 +02:00
Joaquin Ossa
fb61c69714 Changed names of types of payments for better clarity 2024-07-03 16:23:52 +02:00