Merged PR 3896: S&P invoice model

# 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

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

# 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
This commit is contained in:
Joaquin Ossa 2025-02-14 08:18:42 +00:00
commit 4b94d5f70b
7 changed files with 754 additions and 21 deletions

View file

@ -18,19 +18,20 @@ select
then true
else false
end as is_protected,
(au.json_document_user_data ->> 'PriceIncrease')::decimal as price_increase,
(au.json_document_user_data ->> 'PriceIncrease')::decimal
as price_increase_percentage,
(au.json_document_user_data ->> 'PriceIncreaseStartDate')::date
as price_increase_start_date_utc,
(au.json_document_user_data ->> 'MonthlyVolumeDiscount')::decimal
as monthly_volume_discount,
as monthly_volume_discount_percentage,
(au.json_document_user_data ->> 'ThresholdApprovedBookingVolume')::integer
as threshold_approved_booking_volume,
as threshold_approved_or_flagged_booking_volume,
(au.json_document_user_data ->> 'MonthlyVolumeDiscountStartDate')::date
as monthly_volume_discount_start_date_utc,
(au.json_document_user_data ->> 'MonthlyVolumeDiscountEndDate')::date
as monthly_volume_discount_end_date_utc,
(au.json_document_user_data ->> 'MonthlyGeneralDiscount')::decimal
as monthly_general_discount,
as monthly_general_discount_percentage,
(au.json_document_user_data ->> 'MonthlyGeneralDiscountStartDate')::date
as monthly_general_discount_start_date_utc,
(au.json_document_user_data ->> 'MonthlyGeneralDiscountEndDate')::date

View file

@ -4742,7 +4742,7 @@ models:
data_tests:
- not_null
- name: price_increase
- name: price_increase_percentage
data_type: numeric
description: The percentage or value of the price increase
applied to the user's account.
@ -4758,7 +4758,7 @@ models:
data_tests:
- is_first_day_of_month
- name: monthly_volume_discount
- name: monthly_volume_discount_percentage
data_type: numeric
description: The discount percentage or value offered based on the
volume of bookings achieved within a month.
@ -4769,7 +4769,7 @@ models:
max_value: 100
strictly: true
- name: threshold_approved_booking_volume
- name: threshold_approved_or_flagged_booking_volume
data_type: numeric
description: The minimum number of bookings required to qualify for
the monthly volume discount.
@ -4792,7 +4792,7 @@ models:
data_tests:
- is_last_day_of_month
- name: monthly_general_discount
- name: monthly_general_discount_percentage
data_type: numeric
description: The general discount percentage or value applied to all
bookings within the applicable period.