# Description
New model for the purpose of Main KPIs - Overview.
It computes:
* Current MTD value
* Previous Month EOM value
* Previous Year MTD value (12 months ago)
* Current YTD value
* Previous Year YTD value
for the metrics:
* Total Revenue
* Revenue Retained Post-Resolutions
* Guest Revenue
* Invoiced Operator Revenue
* Invoiced APIs Revenue
* Host Resolutions Amount Paid
* Damage Host Waiver Payments
* Billable Bookings
* New Deals
* Churning Deals
* Live Deals (dedicated logic handling)
* Waiver Revenue
Additionally it properly computes the following derived metrics:
* Waiver Payout Rate
* Resolutions Payout Rate
* Operator Revenue per Billable Booking
* Waiver Revenue per Billable Booking
Only for dimension = 'global', though should be easy to extend to other dimensions.
This does not handle (yet) Onboarding MRR nor Revenue Churn Rate, mostly because I need to think how this can be properly attributed in a YTD basis.
This does not compute variations (abs. diff. or rel. diff.) yet.
This does not handle the "hiding" of invoicing metrics due to the invoicing cycle yet.
This does not handle targets... yet!
# Checklist
- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #27609
# Description
Fixed my silly mistake because of a copy/paste
# Checklist
- [x] The edited models and dependants run properly with production data.
- [x] The edited models are sufficiently documented.
- [x] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Silly fix
Related work items: #27178
# Description
Changes:
* On Est. Billable Bookings, keeps previous logic for Old Dash while assuming the first billable service for New Dash
* Adds a Billable Check Out Bookings in Check Out bookings, as defined in the requirements.
# Checklist
- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #27619
# Description
Changes:
* Tags services to be billed (invoiced to host) in the staging models of product_service and protection_plan
* Propagates into booking_service_detail master table. This also computes billable dates.
* Propagates into booking_summary master table. This has the final determination of a booking being billable or not, and when the first and last billing should occur.
# Checklist
- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #27619
# Description
Adds new metric - live deals
# Checklist
- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #27712
# Description
Changes:
* Fixes listings by properly considering the equal or higher sign. I'm very dumb
* Fixes exclusion of new dash billable bookings by properly applying in both monthly and mtd. I'm very dumb x2
# Checklist
- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #27356
# Description
Changes:
* Adapt business_kpis_configuration to include By Business Scope as production dimension.
* Sets in int_mtd_metrics_vs_previous_year the selection of business scope dimension for all KPIs models. This does not affect cross kpis models (churn/mrr). I might need to check later how to adapt Churn to include this dimension, but it's not considered as for this PR. Lastly, Billable Bookings excludes New Dash.
* Adapts condition in int_mtd_metrics_vs_previous_year so MTD values would appear independently of these appearing in the previous year. This is, the model was considering that to show current month MTD values, the dimension needed to exist the year prior. This does not happen with New Dash and I assume we never noticed because in any case, most of our dimensions have quite a long history.
* Adapts int_kpis__agg_dates_main_kpis to include the business scope dimension. By the way it's actually handled, it kind of assumes that a Deal can only be in New or Old Dash (this is correct), but while on New Dash, this deal won't have data for Old Dash (this might not be 100% correct). In any case, the global figure should be ok, and only on the deal + business scope dimensionality this could cause some potential problems. However, this is not being reported anyway at the moment.
* Adapts int_kpis__agg_dates_main_kpis to have a proper variable value for the dimensions, and this is further included in business_kpis_configuration as any other model.
Small changes:
* Adapts Churn metrics to read from dimension_deals rather than core__deals. This should be more accurate anyway.
# Checklist
- [ ] The edited models and dependants run properly with production data.
- [ ] The edited models are sufficiently documented.
- [ ] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Propagates New Dash/Old Dash/APIs split in KPIs as per Business Scope
Related work items: #27356
# Description
Fixed variable call and naming issue
# Checklist
- [x] The edited models and dependants run properly with production data.
- [x] The edited models are sufficiently documented.
- [x] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Fixed variable call and naming
Related work items: #25934
# Description
Changes:
* Adds Business Scope split on Billable Bookings + propagates towards Agg/Metric Monthly/MTD models
This is a temporary modification until the ticket on Billable Bookings for New Dash is handled.
# Checklist
- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #27356
# Description
New Invoice model for S&P
Quite a dense model, it needs to consider some different situations for the different Protection types, verification status and if the user has the `is_protected` flag active for it's bookings.
I leave the documentation for support to better clarify all the possible scenarios and a screenshot of how it is currently looking the model's result.
There are a couple of rename changes on other models, nothing big.
If there are any inquiries let me know.
https://www.notion.so/knowyourguest-superhog/Invoice-Screen-Protect-1610446ff9c980f88de6d6293b4fab03?pvs=4

# Checklist
- [x] The edited models and dependants run properly with production data.
- [x] The edited models are sufficiently documented.
- [x] The edited models contain PK tests, and I've ran and passed them.
- [x] I have checked for DRY opportunities with other models and docs.
- [x] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #25360
# Description
Need opinion on this model, it's not so easy so if needed we can have a quick call
- Since the `int_core__booking_service_detail` has some services combined in one I tried to split them to count separately each service per booking and their statuses. There are also some cases where there are services combined but also separate for the same booking, in those cases I only take in count the status of the service with the most recent `service_detail_updated_at_utc `

So here it takes for the `BASIC DAMAGE DEPOSIT` the status Paid which is more recent but for `WAIVER PLUS` the status Not Paid.
- I created a macro to count all the distinct bookings with each `service_status` that also adds the column name. If there are new statuses being used we would have to add them to the macro as well as calling the new columns on the final select. Might not be the most optimal approach WDYT??
**The PR is not ready to be closed**
# Checklist
- [x] The edited models and dependants run properly with production data.
- [ ] The edited models are sufficiently documented.
- [ ] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Adding booking services status
Related work items: #25934
# Description
Changes:
* Propagates business scope, based on deal, for Deal and Listing metrics. This already handles the daily metric and the daily aggregation.
* Modifies lifecycle_daily_deal to depend on dimension_deals and compute API segmentation.
* Creates new metric: Live Deals, that includes New, Active and Reactivated. This will be needed for YTD/MTD overview.
# Checklist
- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #27356
# Description
Changes:
* **Main change:** exclusion of KYG lite users of the segmentation of Business Scope. These are "freemium" users, kind of demo users, that shouldn't have any real impact in terms of revenue. These are in New Dash, but do not have a deal. The problem is that we don't want to consider them as New Dash, but the current condition was making them appear as Old Dash. This PR fixes this by handling the logic for backend related models. Note that Xero remains unaffected - this is based on Deal, and these users do not have Deal.
* Small data quality fix I noticed while debugging KYG lite cases. It's better to use the "is upgraded service" from the staging original tables rather than the one with the prices. If a user does not have a currency (which can be the case for KYG lite users), then the coalesce would tag any service as not upgraded, which is not true.
# Checklist
- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #27356
# Description
Fixed model error
# Checklist
- [x] The edited models and dependants run properly with production data.
- [x] The edited models are sufficiently documented.
- [x] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Fixed model error
# Description
Fixed model name
# Checklist
- [x] The edited models and dependants run properly with production data.
- [ ] The edited models are sufficiently documented.
- [ ] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
fixed exposures
# Description
Added active and inactive users:
- Active_users: those that are actually using the services in any accommodation of their bundles
- Inactive_users: basically the difference between users with the service and active_users
# Checklist
- [x] The edited models and dependants run properly with production data.
- [x] The edited models are sufficiently documented.
- [x] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
new active_users data
Related work items: #25934
# Description
Included all booking states in the model.
At first I thought I would only show the most relevant but better to show all of them so the total adds up
# Checklist
- [x] The edited models and dependants run properly with production data.
- [x] The edited models are sufficiently documented.
- [x] The edited models contain PK tests, and I've ran and passed them.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #25934
# Description
Changes:
* Business scope is now propagated in Host Resolutions and Invoiced Revenue Monthly/MTD Metric and Aggregated models
# Checklist
- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #27356
# Description
Changes:
* Switches dash_source to business_scope in all kpis models, schema and macro configuration.
# Checklist
- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #27356
# Description
Changes:
* Creation of a deal-based model that contains when a "deal has appeared in new dash". This is tricky because a Deal can still have multiple users, thus it needs to be attributed to a date. I've chosen the first user appearance for the rest of the metrics.
* Adaptation of dimension deals in KPIs to include a client type, that indicates if the deal is from APIs or not (Platform, i.e., Dashboard).
* Xero metrics by Business Scope. This is the previous "dash source" that I need to change in the previously worked models. I decided to include APIs in the segmentation since in most cases we distinguish old dash from new dash by just "anything that is not in new dash". This is very wrong for invoicing metrics, in which we have APIs. So this actually properly computes a client segmentation by scope.
Note that I'll need to handle the monthly/mtd metrics/agg for these 2 metric models (Resolutions + Invoiced revenue) separately.
# Checklist
- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.
# Other
- [ ] Check if a full-refresh is required after this PR is merged.
Related work items: #27356