Merged PR 3632: Brings Billing tables into Staging

# Description

Aims to bring the 2 new billing tables in the scope of New Pricing into DWH.
These correspond to a Product Service table and a Protection Plan table.

Further modelling is expected in intermediate. Main goal would be to enrich the tables of `int_core__booking_service_detail` and `int_core__booking_summary`

# 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: #20809
This commit is contained in:
Oriol Roqué Paniagua 2024-11-22 08:34:58 +00:00
parent b0bed479c7
commit aa3261cf9d
4 changed files with 261 additions and 1 deletions

View file

@ -257,3 +257,7 @@ sources:
identifier: BookingView
- name: BookingViewToService
identifier: BookingViewToService
- name: ProductProtectionPlanBillingItem
identifier: ProductProtectionPlanBillingItem
- name: ProductServiceBillingItem
identifier: ProductServiceBillingItem

View file

@ -1081,10 +1081,202 @@ models:
description: |
Timestamp of when this Booking View To Service record was last updated.
- name: updated_date_utc
data_type: Date
data_type: date
description: |
Date of when this Booking View To Service record was last updated.
- name: dwh_extracted_at_utc
data_type: timestamp
description: |
Timestamp of when this data was extracted into DWH.
- name: stg_core__product_service_billing_item
description: |
Provides the Billing Items for Product Services in the scope of
New Dashboard and New Pricing initiative.
columns:
- name: id_product_service_billing_item
data_type: integer
description: |
Identifier of the Product Service Billing Item. Acts as the primary key for this table.
tests:
- unique
- not_null
- name: id_booking
data_type: integer
description: |
Identifier of the booking. Acts as foreign key for the Booking table.
A Booking can have multiple Billing Items applied.
tests:
- not_null
- name: id_booking_state
data_type: integer
description: |
Identifier of the booking state. Acts as foreign key for the Booking State
table.
tests:
- not_null
- name: id_product_service_to_price
data_type: integer
description: |
Identifier of the product service to price. Acts as foreign key for the
Product Service To Price table. Necessary to retrieve the user specs and
the currency in which the Price (amount_local_curr) is applied.
tests:
- not_null
- name: chargeable_at_utc
data_type: timestamp
description: |
Timestamp of when this Product Service Billing Item can be charged.
tests:
- not_null
- name: chargeable_date_utc
data_type: date
description: |
Date of when this Product Service Billing Item can be charged.
tests:
- not_null
- name: amount_local_curr
data_type: decimal
description: |
Price of the Billing Item, in local currency. Could be positive or negative,
depending on if the line aims to add or remove a previously created amount.
tests:
- not_null
- name: created_at_utc
data_type: timestamp
description: |
Timestamp of when this Product Service Billing Item record was created.
tests:
- not_null
- name: created_date_utc
data_type: date
description: |
Date of when this Product Service Billing Item record was created.
tests:
- not_null
- name: updated_at_utc
data_type: timestamp
description: |
Timestamp of when this Product Service Billing Item record was last updated.
tests:
- not_null
- name: updated_date_utc
data_type: date
description: |
Date of when this Product Service Billing Item record was last updated.
tests:
- not_null
- name: dwh_extracted_at_utc
data_type: timestamp
description: |
Timestamp of when this record was extracted into DWH.
- name: stg_core__protection_plan_billing_item
description: |
Provides the Billing Items for Protection Plans in the scope of
New Dashboard and New Pricing initiative. Be aware that the
corresponding table in sync and in the backend includes Product as
a prefix, namely: ProductProtectionPlanBillingItem. Within DWH, we
keep the consistency with the rest of the Protection Plan tables by
removing Product from it.
columns:
- name: id_protection_plan_billing_item
data_type: integer
description: |
Identifier of the Protection Plan Billing Item. Acts as the primary key for this table.
tests:
- unique
- not_null
- name: id_booking
data_type: integer
description: |
Identifier of the booking. Acts as foreign key for the Booking table.
A Booking can have multiple Billing Items applied.
tests:
- not_null
- name: id_booking_state
data_type: integer
description: |
Identifier of the booking state. Acts as foreign key for the Booking State
table.
tests:
- not_null
- name: id_protection_plan_to_price
data_type: integer
description: |
Identifier of the protection plan to price. Acts as foreign key for the
Protection Plan To Price table. Necessary to retrieve the user specs and
the currency in which the Price (amount_local_curr) is applied.
tests:
- not_null
- name: chargeable_at_utc
data_type: timestamp
description: |
Timestamp of when this Protection Plan Billing Item can be charged.
tests:
- not_null
- name: chargeable_date_utc
data_type: date
description: |
Date of when this Protection Plan Billing Item can be charged.
tests:
- not_null
- name: amount_local_curr
data_type: decimal
description: |
Price of the Billing Item, in local currency. Could be positive or negative,
depending on if the line aims to add or remove a previously created amount.
tests:
- not_null
- name: created_at_utc
data_type: timestamp
description: |
Timestamp of when this Protection Plan Billing Item record was created.
tests:
- not_null
- name: created_date_utc
data_type: date
description: |
Date of when this Protection Plan Billing Item record was created.
tests:
- not_null
- name: updated_at_utc
data_type: timestamp
description: |
Timestamp of when this Protection Plan Billing Item record was last updated.
tests:
- not_null
- name: updated_date_utc
data_type: date
description: |
Date of when this Protection Plan Billing Item record was last updated.
tests:
- not_null
- name: dwh_extracted_at_utc
data_type: timestamp
description: |
Timestamp of when this record was extracted into DWH.

View file

@ -0,0 +1,32 @@
{{ config(materialized="incremental", unique_key="id_product_service_billing_item") }}
with
raw_product_service_billing_item as (
select * from {{ source("core", "ProductServiceBillingItem") }}
),
stg_core__product_service_billing_item as (
select
{{ adapter.quote("Id") }} as id_product_service_billing_item,
{{ adapter.quote("BookingId") }} as id_booking,
{{ adapter.quote("BookingStateId") }} as id_booking_state,
{{ adapter.quote("ProductServiceToPriceId") }}
as id_product_service_to_price,
{{ adapter.quote("DateChargeable") }} as chargeable_at_utc,
date({{ adapter.quote("DateChargeable") }}) as chargeable_date_utc,
{{ adapter.quote("Price") }} as amount_local_curr,
{{ adapter.quote("CreatedDate") }} as created_at_utc,
date({{ adapter.quote("CreatedDate") }}) as created_date_utc,
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
date({{ adapter.quote("UpdatedDate") }}) as updated_date_utc,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_product_service_billing_item
)
select *
from stg_core__product_service_billing_item
{% if is_incremental() %}
where
updated_at_utc
>= ((select max(updated_at_utc) from {{ this }}) - interval '7 days')
{% endif %}

View file

@ -0,0 +1,32 @@
{{ config(materialized="incremental", unique_key="id_protection_plan_billing_item") }}
with
raw_protection_plan_billing_item as (
select * from {{ source("core", "ProductProtectionPlanBillingItem") }}
),
stg_core__protection_plan_billing_item as (
select
{{ adapter.quote("Id") }} as id_protection_plan_billing_item,
{{ adapter.quote("BookingId") }} as id_booking,
{{ adapter.quote("BookingStateId") }} as id_booking_state,
{{ adapter.quote("ProtectionPlanToPriceId") }}
as id_protection_plan_to_price,
{{ adapter.quote("DateChargeable") }} as chargeable_at_utc,
date({{ adapter.quote("DateChargeable") }}) as chargeable_date_utc,
{{ adapter.quote("Price") }} as amount_local_curr,
{{ adapter.quote("CreatedDate") }} as created_at_utc,
date({{ adapter.quote("CreatedDate") }}) as created_date_utc,
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
date({{ adapter.quote("UpdatedDate") }}) as updated_date_utc,
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
from raw_protection_plan_billing_item
)
select *
from stg_core__protection_plan_billing_item
{% if is_incremental() %}
where
updated_at_utc
>= ((select max(updated_at_utc) from {{ this }}) - interval '7 days')
{% endif %}