Addressed comments
This commit is contained in:
parent
60ebb13f1d
commit
c01d09d9f6
2 changed files with 31 additions and 122 deletions
|
|
@ -121,16 +121,6 @@ with
|
|||
upper(vr.protection_type) = '{{ damage_waiver }}'
|
||||
and upper(vr.verification_status) <> '{{ rejected_status }}'
|
||||
),
|
||||
bookings_with_booking_fee as (
|
||||
select *
|
||||
from rejected_bookings
|
||||
union all
|
||||
select *
|
||||
from cancelled_bookings
|
||||
union all
|
||||
select *
|
||||
from damage_waiver_bookings
|
||||
),
|
||||
-- Basic Protection bookings that have been approved or flagged and are not
|
||||
-- cancelled.
|
||||
approved_or_flagged_basic_protection_bookings as (
|
||||
|
|
@ -237,6 +227,16 @@ with
|
|||
and vr.is_cancelled is false
|
||||
and vr.is_protected is true
|
||||
),
|
||||
bookings_with_booking_fee as (
|
||||
select *
|
||||
from rejected_bookings
|
||||
union all
|
||||
select *
|
||||
from cancelled_bookings
|
||||
union all
|
||||
select *
|
||||
from damage_waiver_bookings
|
||||
),
|
||||
bookings_with_nightly_fee as (
|
||||
select *
|
||||
from approved_or_flagged_basic_protection_bookings
|
||||
|
|
@ -265,34 +265,19 @@ select
|
|||
vr.is_cancelled,
|
||||
vr.cancelled_at_utc,
|
||||
vr.cancelled_date_utc,
|
||||
bbf.booking_fee_in_local_currency,
|
||||
bnf.nightly_fee_in_local_currency,
|
||||
bnf.nightly_fee_in_local_currency
|
||||
* vr.number_of_nights as total_fee_in_local_currency,
|
||||
bnf.discount_percentage,
|
||||
bnf.nightly_fee_in_local_currency
|
||||
coalesce(bnf.nightly_fee_in_local_currency, 0) * vr.number_of_nights
|
||||
+ coalesce(bbf.booking_fee_in_local_currency, 0) as total_fee_in_local_currency,
|
||||
coalesce(bnf.discount_percentage, 0) as discount_percentage,
|
||||
coalesce(bnf.nightly_fee_in_local_currency, 0)
|
||||
* vr.number_of_nights
|
||||
* bnf.discount_percentage
|
||||
* coalesce(bnf.discount_percentage, 0)
|
||||
/ 100 as discount_amount_in_local_currency,
|
||||
bnf.nightly_fee_in_local_currency
|
||||
coalesce(bbf.booking_fee_in_local_currency, 0)
|
||||
+ coalesce(bnf.nightly_fee_in_local_currency, 0)
|
||||
* vr.number_of_nights
|
||||
* (100 - bnf.discount_percentage)
|
||||
/ 100 as fee_after_discount_in_local_currency,
|
||||
* (100 - coalesce(bnf.discount_percentage, 0))
|
||||
/ 100 as total_fee_after_discount_in_local_currency,
|
||||
coalesce(bbf.invoice_date_utc, bnf.invoice_date_utc) as invoice_date_utc,
|
||||
vr.user_email,
|
||||
vr.company_name,
|
||||
vr.property_manager_name,
|
||||
vr.property_manager_email,
|
||||
vr.listing_name,
|
||||
vr.listing_address,
|
||||
vr.listing_town,
|
||||
vr.listing_country,
|
||||
vr.listing_postcode,
|
||||
vr.pets_allowed,
|
||||
vr.status_updated_at_utc,
|
||||
vr.status_updated_date_utc,
|
||||
vr.updated_at_utc,
|
||||
vr.updated_date_utc,
|
||||
vr.creation_at_utc,
|
||||
vr.creation_date_utc,
|
||||
vr.cosmos_created_date_utc
|
||||
|
|
@ -346,12 +346,14 @@ models:
|
|||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: int_screen_and_protect__invoices
|
||||
- name: int_screen_and_protect__verification_fees
|
||||
description: |
|
||||
This table contains records of invoices related to verification requests
|
||||
from the Screen and Protect API.
|
||||
It tracks financial details such as fees, discounts, and booking-related
|
||||
metadata.
|
||||
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
|
||||
|
|
@ -482,24 +484,6 @@ models:
|
|||
data_type: date
|
||||
description: "Date when the booking was canceled."
|
||||
|
||||
- name: booking_fee_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Fee in local currency associated with the booking."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 10000
|
||||
strictly: true
|
||||
|
||||
- name: nightly_fee_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Nightly fee in local currency for the booking."
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
max_value: 10000
|
||||
strictly: true
|
||||
|
||||
- name: total_fee_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Total fee in local currency, inclusive of all charges."
|
||||
|
|
@ -508,6 +492,7 @@ models:
|
|||
min_value: 0
|
||||
max_value: 10000000
|
||||
strictly: true
|
||||
- not_null
|
||||
|
||||
- name: discount_percentage
|
||||
data_type: numeric
|
||||
|
|
@ -517,6 +502,7 @@ models:
|
|||
min_value: 0
|
||||
max_value: 99
|
||||
strictly: false
|
||||
- not_null
|
||||
|
||||
- name: discount_amount_in_local_currency
|
||||
data_type: numeric
|
||||
|
|
@ -526,8 +512,9 @@ models:
|
|||
min_value: 0
|
||||
max_value: 10000000
|
||||
strictly: false
|
||||
- not_null
|
||||
|
||||
- name: fee_after_discount_in_local_currency
|
||||
- name: total_fee_after_discount_in_local_currency
|
||||
data_type: numeric
|
||||
description: "Total fee in local currency after applying the discount."
|
||||
tests:
|
||||
|
|
@ -535,6 +522,7 @@ models:
|
|||
min_value: 0
|
||||
max_value: 10000000
|
||||
strictly: true
|
||||
- not_null
|
||||
|
||||
- name: invoice_date_utc
|
||||
data_type: date
|
||||
|
|
@ -542,70 +530,6 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: user_email
|
||||
data_type: text
|
||||
description: "Email address of the user associated with the booking."
|
||||
|
||||
- name: company_name
|
||||
data_type: text
|
||||
description: "Name of the company associated with the booking."
|
||||
|
||||
- name: property_manager_name
|
||||
data_type: text
|
||||
description: "Name of the property manager."
|
||||
|
||||
- name: property_manager_email
|
||||
data_type: text
|
||||
description: "Email address of the property manager."
|
||||
|
||||
- name: listing_name
|
||||
data_type: text
|
||||
description: "Name of the listing."
|
||||
|
||||
- name: listing_address
|
||||
data_type: text
|
||||
description: "Address of the listing."
|
||||
|
||||
- name: listing_town
|
||||
data_type: text
|
||||
description: "Town where the listing is located."
|
||||
|
||||
- name: listing_country
|
||||
data_type: text
|
||||
description: "Country code where the listing is located."
|
||||
|
||||
- name: listing_postcode
|
||||
data_type: text
|
||||
description: "Postcode of the listing."
|
||||
|
||||
- name: pets_allowed
|
||||
data_type: boolean
|
||||
description: "Indicates if pets are allowed at the listing."
|
||||
|
||||
- name: status_updated_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: "Timestamp of the last status update for the verification."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: status_updated_date_utc
|
||||
data_type: date
|
||||
description: "Date of the last status update for the verification."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: updated_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: "Timestamp of the last update to the record."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: updated_date_utc
|
||||
data_type: date
|
||||
description: "Date of the last update to the record."
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: creation_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: "Timestamp of when the reservation was created."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue