Merged PR 3633: Creates billing models in intermediate
# Description Adds Billing models in intermediate. It's mostly the similar content as for the staging counterparts, but providing useful information such as the currency code and service that this billing line refers to. Same as before, two separate models for Protection Plan and Product Service. # 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:
parent
aa3261cf9d
commit
2ede94370b
3 changed files with 294 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
{{ config(materialized="view", unique_key=["id_product_service_billing_item"]) }}
|
||||
with
|
||||
stg_core__product_service_billing_item as (
|
||||
select * from {{ ref("stg_core__product_service_billing_item") }}
|
||||
),
|
||||
stg_core__booking_state as (select * from {{ ref("stg_core__booking_state") }}),
|
||||
int_core__product_service_to_price as (
|
||||
select * from {{ ref("int_core__product_service_to_price") }}
|
||||
)
|
||||
select
|
||||
psbi.id_product_service_billing_item,
|
||||
psbi.id_booking,
|
||||
psbi.id_product_service_to_price,
|
||||
pstp.id_product_service,
|
||||
pstp.product_service_display_name as service_name,
|
||||
upper(pstp.product_service_price_name) as service_price_name,
|
||||
upper(bs.booking_state) as booking_status,
|
||||
pstp.currency_code,
|
||||
psbi.amount_local_curr,
|
||||
psbi.chargeable_at_utc,
|
||||
psbi.chargeable_date_utc,
|
||||
psbi.created_at_utc,
|
||||
psbi.created_date_utc,
|
||||
psbi.updated_at_utc,
|
||||
psbi.updated_date_utc
|
||||
from stg_core__product_service_billing_item psbi
|
||||
left join stg_core__booking_state bs on psbi.id_booking_state = bs.id_booking_state
|
||||
left join
|
||||
int_core__product_service_to_price pstp
|
||||
on psbi.id_product_service_to_price = pstp.id_product_service_to_price
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
{{ config(materialized="view", unique_key=["id_protection_plan_billing_item"]) }}
|
||||
with
|
||||
stg_core__protection_plan_billing_item as (
|
||||
select * from {{ ref("stg_core__protection_plan_billing_item") }}
|
||||
),
|
||||
stg_core__booking_state as (select * from {{ ref("stg_core__booking_state") }}),
|
||||
int_core__protection_plan_to_price as (
|
||||
select * from {{ ref("int_core__protection_plan_to_price") }}
|
||||
)
|
||||
select
|
||||
psbi.id_protection_plan_billing_item,
|
||||
psbi.id_booking,
|
||||
psbi.id_protection_plan_to_price,
|
||||
pstp.id_protection_plan,
|
||||
pstp.protection_display_name as service_name,
|
||||
upper(pstp.protection_plan_price_name) as service_price_name,
|
||||
upper(bs.booking_state) as booking_status,
|
||||
pstp.currency_code,
|
||||
psbi.amount_local_curr,
|
||||
psbi.chargeable_at_utc,
|
||||
psbi.chargeable_date_utc,
|
||||
psbi.created_at_utc,
|
||||
psbi.created_date_utc,
|
||||
psbi.updated_at_utc,
|
||||
psbi.updated_date_utc
|
||||
from stg_core__protection_plan_billing_item psbi
|
||||
left join stg_core__booking_state bs on psbi.id_booking_state = bs.id_booking_state
|
||||
left join
|
||||
int_core__protection_plan_to_price pstp
|
||||
on psbi.id_protection_plan_to_price = pstp.id_protection_plan_to_price
|
||||
|
|
@ -3857,3 +3857,237 @@ models:
|
|||
description: |
|
||||
Flag to identify if the Host for this booking is missing
|
||||
the currency code or not.
|
||||
|
||||
- name: int_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. Cannot be null.
|
||||
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. Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_product_service
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the product service. Acts as foreign key for the
|
||||
Product Service table. Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: service_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name of the service billed for this booking. Cannot be null.
|
||||
For example: WAIVER PRO.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: service_price_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name given to the price for the service billed for this booking.
|
||||
For example: WAIVER PRO DEFAULT PRICE.
|
||||
|
||||
- name: booking_status
|
||||
data_type: string
|
||||
description: |
|
||||
The current status of the booking. Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: currency_code
|
||||
data_type: string
|
||||
description:
|
||||
Currency iso4217 code. It identifies the currency for the amount stated in
|
||||
amount_local_curr. It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: amount_local_curr
|
||||
data_type: decimal
|
||||
description: |
|
||||
Price of the Billing Item, in local currency. It can be positive or negative,
|
||||
depending on if the line aims to add or remove a previously created amount.
|
||||
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: 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: int_core__protection_plan_billing_item
|
||||
description: |
|
||||
Provides the Billing Items for Protection Plans in the scope of
|
||||
New Dashboard and New Pricing initiative.
|
||||
|
||||
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. Cannot be null.
|
||||
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. Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_protection_plan
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the protection plan. Acts as foreign key for the
|
||||
Protection Plan table. Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: service_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name of the service billed for this booking. Cannot be null.
|
||||
For example: BASIC PROTECTION.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: service_price_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name given to the price for the service billed for this booking.
|
||||
For example: BASIC PROTECTION DEFAULT PRICE.
|
||||
|
||||
- name: booking_status
|
||||
data_type: string
|
||||
description: |
|
||||
The current status of the booking. Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: currency_code
|
||||
data_type: string
|
||||
description:
|
||||
Currency iso4217 code. It identifies the currency for the amount stated in
|
||||
amount_local_curr. It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: amount_local_curr
|
||||
data_type: decimal
|
||||
description: |
|
||||
Price of the Billing Item, in local currency. It can be positive or negative,
|
||||
depending on if the line aims to add or remove a previously created amount.
|
||||
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: created_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this Protection Plane 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue