commit wip

This commit is contained in:
Joaquin Ossa 2025-02-13 15:28:54 +01:00
parent c01d09d9f6
commit 67bf836621
2 changed files with 237 additions and 0 deletions

View file

@ -248,3 +248,205 @@ models:
Date of when the verification request was created in Cosmos DB.
data_tests:
- not_null
- name: screen_and_protect__verification_fees
description: |
This table contains all records for verification requests
from the Screen and Protect API and their fees.
It tracks financial details such as booking fees, discounts and
some booking-related metadata.
Documentation:
https://www.notion.so/knowyourguest-superhog/Invoice-Screen-Protect-1610446ff9c980f88de6d6293b4fab03?pvs=4
columns:
- name: id_verification
data_type: text
description: "Unique identifier for the verification request."
tests:
- not_null
- unique
- name: id_booking
data_type: text
description: "Unique identifier for the booking associated with the verification."
tests:
- not_null
- name: id_user_partner
data_type: text
description: "Identifier for the partner user initiating the verification."
tests:
- not_null
- name: id_accommodation
data_type: text
description: "Identifier for the accommodation related to the booking."
- name: is_protected
data_type: boolean
description: "Indicates if the booking is protected or not."
- name: protection_type
data_type: text
description: "Specific protection type for the request."
tests:
- not_null
- accepted_values:
values:
- "SCREEN & PROTECT"
- "BASIC PROTECTION"
- "STANDALONE PROTECTION"
- "DAMAGE WAIVER"
- "PET PROTECTION"
- name: protection_starting_amount_in_local_currency
data_type: numeric
description: Field used for protection type "STANDALONE PROTECTION" to
indicate the starting level of protection.
In local currency.
tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
max_value: 100000
strictly: true
- name: protection_basic_amount_in_local_currency
data_type: numeric
description: Field used for protection type "SCREEN & PROTECT",
"BASIC PROTECTION" or "DAMAGE WAIVER" to show the basic amount of protection.
In local currency.
tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
max_value: 100000
strictly: true
- name: protection_extended_amount_in_local_currency
data_type: numeric
description: Field used for protection type "SCREEN & PROTECT",
or "STANDALONE PROTECTION" to show the basic amount of protection.
In local currency.
tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
max_value: 50000000
strictly: true
- name: pet_protection
data_type: boolean
description: Indicates if pet protection was included.
- name: verification_status
data_type: text
description: Outcome of the verification process.
tests:
- not_null
- accepted_values:
values:
- "APPROVED"
- "FLAGGED"
- "REJECTED"
- name: id_currency
data_type: bigint
description: "Id of the currency, works as a foreign key to the
currency table"
tests:
- not_null
- relationships:
to: ref('stg_core__currency')
field: id_currency
- name: checkin_date_utc
data_type: date
description: "Check-in date for the booking."
tests:
- not_null
- name: checkout_date_utc
data_type: date
description: "Check-out date for the booking."
tests:
- not_null
- name: number_of_nights
data_type: integer
description: Number of nights for the reservation.
tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 1
- name: is_cancelled
data_type: boolean
description: "Indicates if the booking was canceled."
- name: cancelled_at_utc
data_type: timestamp without time zone
description: "Timestamp when the booking was canceled."
- name: cancelled_date_utc
data_type: date
description: "Date when the booking was canceled."
- name: total_fee_in_local_currency
data_type: numeric
description: "Total fee in local currency, inclusive of all charges."
tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
max_value: 10000000
strictly: true
- not_null
- name: discount_percentage
data_type: numeric
description: "Percentage of discount applied to the booking."
tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
max_value: 99
strictly: false
- not_null
- name: discount_amount_in_local_currency
data_type: numeric
description: "Amount of discount in local currency applied to the booking."
tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
max_value: 10000000
strictly: false
- not_null
- name: total_fee_after_discount_in_local_currency
data_type: numeric
description: "Total fee in local currency after applying the discount."
tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
max_value: 10000000
strictly: true
- not_null
- name: invoice_date_utc
data_type: date
description: "Date to consider for the invoice."
tests:
- not_null
- name: creation_at_utc
data_type: timestamp without time zone
description: "Timestamp of when the reservation was created."
tests:
- not_null
- name: creation_date_utc
data_type: date
description: "Date of when the reservation was created."
tests:
- not_null
- name: cosmos_created_date_utc
data_type: date
description: "Date of when the verification request was created in Cosmos DB."
tests:
- not_null

View file

@ -0,0 +1,35 @@
with
int_screen_and_protect__verification_fees as (
select * from {{ ref("int_screen_and_protect__verification_fees") }}
)
select
id_verification as id_verification,
id_booking as id_booking,
id_user_partner as id_user_partner,
id_accommodation as id_accommodation,
is_protected as is_protected,
protection_type as protection_type,
protection_basic_amount_in_local_currency
as protection_basic_amount_in_local_currency,
protection_starting_amount_in_local_currency
as protection_starting_amount_in_local_currency,
protection_extended_amount_in_local_currency
as protection_extended_amount_in_local_currency,
verification_status as verification_status,
id_currency as id_currency,
checkin_date_utc as checkin_date_utc,
checkout_date_utc as checkout_date_utc,
number_of_nights as number_of_nights,
is_cancelled as is_cancelled,
cancelled_at_utc as cancelled_at_utc,
cancelled_date_utc as cancelled_date_utc,
total_fee_in_local_currency as total_fee_in_local_currency,
discount_percentage as discount_percentage,
discount_amount_in_local_currency as discount_amount_in_local_currency,
total_fee_after_discount_in_local_currency
as total_fee_after_discount_in_local_currency,
invoice_date_utc as invoice_date_utc,
creation_at_utc as creation_at_utc,
creation_date_utc as creation_date_utc,
cosmos_created_date_utc as cosmos_created_date_utc
from int_screen_and_protect__verification_fees