Model for Bookings report in Legacy
This commit is contained in:
parent
f76e49a75c
commit
ff296ec75d
4 changed files with 492 additions and 0 deletions
104
models/intermediate/core/int_core__booking_details.sql
Normal file
104
models/intermediate/core/int_core__booking_details.sql
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
{% set waiver = "Payment Validation: Waiver" %}
|
||||
{% set fee = "Payment Validation: Fee" %}
|
||||
{% set fee_with_deposit = "Payment Validation: FeeWithDeposit" %}
|
||||
{% set no_cover = "Payment Validation: NoCover" %}
|
||||
{% set checkin_cover = "CheckInCover" %}
|
||||
|
||||
with
|
||||
stg_core__verification as (select * from {{ ref("stg_core__verification") }}),
|
||||
int_core__verification_requests as (
|
||||
select * from {{ ref("int_core__verification_requests") }}
|
||||
),
|
||||
int_core__bookings as (select * from {{ ref("int_core__bookings") }}),
|
||||
int_core__accommodation as (select * from {{ ref("int_core__accommodation") }}),
|
||||
int_core__user_host as (select * from {{ ref("int_core__user_host") }}),
|
||||
int_core__unified_user as (select * from {{ ref("int_core__unified_user") }}),
|
||||
int_core__verification_payments as (
|
||||
select * from {{ ref("dwh_dbt", "int_core__verification_payments", v="2") }}
|
||||
),
|
||||
payment_validation as (
|
||||
select
|
||||
v.id_verification_request,
|
||||
cast(
|
||||
max(
|
||||
case
|
||||
when verification_value = '{{ fee_with_deposit }}' then 1 else 0
|
||||
end
|
||||
) as boolean
|
||||
) as chose_deposit,
|
||||
cast(
|
||||
max(
|
||||
case when verification_value = '{{ fee }}' then 1 else 0 end
|
||||
) as boolean
|
||||
) as chose_fee,
|
||||
cast(
|
||||
max(
|
||||
case when verification_value = '{{ waiver }}' then 1 else 0 end
|
||||
) as boolean
|
||||
) as chose_waiver,
|
||||
cast(
|
||||
max(
|
||||
case when verification_value = '{{ no_cover }}' then 1 else 0 end
|
||||
) as boolean
|
||||
) as chose_no_cover
|
||||
from stg_core__verification v
|
||||
where verification = 'PaymentValidation'
|
||||
group by v.id_verification_request
|
||||
),
|
||||
check_in_cover_payments as (
|
||||
select
|
||||
id_verification_request,
|
||||
case
|
||||
when total_amount_in_txn_currency is not null then true else false
|
||||
end as chose_checkin_cover
|
||||
from int_core__verification_payments
|
||||
where
|
||||
verification_payment_type = '{{ checkin_cover }}'
|
||||
and payment_status in ('Paid', 'Refunded')
|
||||
)
|
||||
select
|
||||
b.id_booking,
|
||||
b.id_user_host,
|
||||
uh.id_deal,
|
||||
b.id_user_guest,
|
||||
b.id_accommodation,
|
||||
b.id_verification_request,
|
||||
b.booking_state,
|
||||
a.is_active as is_accommodation_active,
|
||||
b.check_in_date_utc as checkin_date_utc,
|
||||
b.check_out_date_utc as checkout_date_utc,
|
||||
b.check_out_date_utc - b.check_in_date_utc as booking_nights,
|
||||
b.created_date_utc,
|
||||
uh.first_name as host_first_name,
|
||||
uh.last_name as host_last_name,
|
||||
uh.email as host_email,
|
||||
uh.company_name,
|
||||
b.guest_first_name,
|
||||
b.guest_last_name,
|
||||
b.guest_email,
|
||||
uu.billing_country_name as guest_billing_country,
|
||||
uu.billing_town as guest_billing_town,
|
||||
a.country_name as accommodation_country,
|
||||
a.address_line_1 as accommodation_address,
|
||||
vr.is_verification_request_complete,
|
||||
vr.verification_estimated_started_date_utc,
|
||||
vr.verification_estimated_completed_date_utc,
|
||||
vr.link_used_date_utc,
|
||||
b.verification_request_booking_source,
|
||||
pv.chose_deposit,
|
||||
pv.chose_fee,
|
||||
pv.chose_waiver,
|
||||
pv.chose_no_cover,
|
||||
p.chose_checkin_cover
|
||||
from int_core__bookings b
|
||||
left join int_core__accommodation a on a.id_accommodation = b.id_accommodation
|
||||
left join
|
||||
int_core__verification_requests vr
|
||||
on vr.id_verification_request = b.id_verification_request
|
||||
left join int_core__user_host uh on uh.id_user_host = b.id_user_host
|
||||
left join int_core__unified_user uu on uu.id_user = b.id_user_guest
|
||||
left join
|
||||
payment_validation pv on pv.id_verification_request = vr.id_verification_request
|
||||
left join
|
||||
check_in_cover_payments p on p.id_verification_request = vr.id_verification_request
|
||||
where b.is_duplicate_booking is false
|
||||
|
|
@ -4982,3 +4982,178 @@ models:
|
|||
- name: total_bookings
|
||||
data_type: bigint
|
||||
description: "The total number of bookings for this accommodation."
|
||||
|
||||
- name: int_core__booking_details
|
||||
description: |
|
||||
"Contains detailed information about each booking, including host
|
||||
and guest details, accommodation, and verification request data."
|
||||
|
||||
columns:
|
||||
- name: id_booking
|
||||
data_type: bigint
|
||||
description: "The unique, Superhog generated id for this booking."
|
||||
data_tests:
|
||||
- unique
|
||||
- not_null
|
||||
|
||||
- name: id_user_host
|
||||
data_type: text
|
||||
description: "The unique user ID for the Host."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: id_deal
|
||||
data_type: character varying
|
||||
description:
|
||||
"The ID of the deal of the user. It only applies to client accounts.
|
||||
Can be null."
|
||||
|
||||
- name: id_user_guest
|
||||
data_type: text
|
||||
description: "The unique, Superhog generated id for the guest"
|
||||
|
||||
- name: id_accommodation
|
||||
data_type: bigint
|
||||
description: "Id of the accommodation or listing."
|
||||
|
||||
- name: id_verification_request
|
||||
data_type: bigint
|
||||
description: |
|
||||
The identifier of the verification request. It acts as Foreign Key to
|
||||
Verification Request table. It can be null.
|
||||
|
||||
- name: booking_state
|
||||
data_type: character varying
|
||||
description:
|
||||
"State in which the booking is, could be either of the following:
|
||||
- Approved
|
||||
- NotApproved
|
||||
- Cancelled
|
||||
- Rejected
|
||||
- NoFlags
|
||||
- Flagged
|
||||
- IncompleteInformation"
|
||||
data_tests:
|
||||
- accepted_values:
|
||||
values:
|
||||
- "Approved"
|
||||
- "NotApproved"
|
||||
- "Cancelled"
|
||||
- "Rejected"
|
||||
- "NoFlags"
|
||||
- "Flagged"
|
||||
- "IncompleteInformation"
|
||||
|
||||
- name: is_accommodation_active
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the accommodation is active."
|
||||
|
||||
- name: checkin_date_utc
|
||||
data_type: date
|
||||
description: "Date of check-in of the booking."
|
||||
|
||||
- name: checkout_date_utc
|
||||
data_type: date
|
||||
description: "Date of check-out of the booking."
|
||||
|
||||
- name: booking_nights
|
||||
data_type: integer
|
||||
description: "Number of nights of the booking."
|
||||
|
||||
- name: created_date_utc
|
||||
data_type: timestamp without time zone
|
||||
description: "Date when the booking was created."
|
||||
|
||||
- name: host_first_name
|
||||
data_type: character varying
|
||||
description: "First name of the host."
|
||||
|
||||
- name: host_last_name
|
||||
data_type: character varying
|
||||
description: "Last name of the host."
|
||||
|
||||
- name: host_email
|
||||
data_type: character varying
|
||||
description: "Email of the host."
|
||||
|
||||
- name: company_name
|
||||
data_type: character varying
|
||||
description: "The company name."
|
||||
|
||||
- name: guest_first_name
|
||||
data_type: character varying
|
||||
description: "First name of the guest."
|
||||
|
||||
- name: guest_last_name
|
||||
data_type: character varying
|
||||
description: "Last name of the guest."
|
||||
|
||||
- name: guest_email
|
||||
data_type: character varying
|
||||
description: "Email of the guest."
|
||||
|
||||
- name: guest_billing_country
|
||||
data_type: character varying
|
||||
description: "Billing country of the guest."
|
||||
|
||||
- name: guest_billing_town
|
||||
data_type: character varying
|
||||
description: "Billing town of the guest."
|
||||
|
||||
- name: accommodation_country
|
||||
data_type: character varying
|
||||
description: "Country of the listing"
|
||||
|
||||
- name: accommodation_address
|
||||
data_type: character varying
|
||||
description: "Address of the listing"
|
||||
|
||||
- name: is_verification_request_complete
|
||||
data_type: boolean
|
||||
description: "True if the verification request is considered complete,
|
||||
AKA the guest has finished the full guest journey."
|
||||
|
||||
- name: verification_estimated_started_date_utc
|
||||
data_type: date
|
||||
description: "The estimated date on which the guest started the guest journey."
|
||||
|
||||
- name: verification_estimated_completed_date_utc
|
||||
data_type: date
|
||||
description: "The estimated date on which the guest finished the guest journey."
|
||||
|
||||
- name: link_used_date_utc
|
||||
data_type: date
|
||||
description: "The date on which the guest used the link for the verification."
|
||||
|
||||
- name: verification_request_booking_source
|
||||
data_type: text
|
||||
description: Source type of host of the booking, this could be either;
|
||||
- PMS
|
||||
- OSL
|
||||
- API/MANUAL
|
||||
data_tests:
|
||||
- accepted_values:
|
||||
values:
|
||||
- "PMS"
|
||||
- "OSL"
|
||||
- "API/MANUAL"
|
||||
|
||||
- name: chose_deposit
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose Deposit payment validation."
|
||||
|
||||
- name: chose_fee
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose Fee payment validation."
|
||||
|
||||
- name: chose_waiver
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose Waiver payment validation."
|
||||
|
||||
- name: chose_no_cover
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose No Cover payment validation."
|
||||
|
||||
- name: chose_checkin_cover
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose CheckIn Cover."
|
||||
|
|
|
|||
38
models/reporting/core/core__booking_details.sql
Normal file
38
models/reporting/core/core__booking_details.sql
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
with
|
||||
int_core__bookings_details as (select * from {{ ref("int_core__booking_details") }})
|
||||
select
|
||||
id_booking as id_booking,
|
||||
id_user_host as id_user_host,
|
||||
id_deal as id_deal,
|
||||
id_user_guest as id_user_guest,
|
||||
id_accommodation as id_accommodation,
|
||||
id_verification_request as id_verification_request,
|
||||
booking_state as booking_state,
|
||||
is_accommodation_active as is_accommodation_active,
|
||||
checkin_date_utc as checkin_date_utc,
|
||||
checkout_date_utc as checkout_date_utc,
|
||||
booking_nights as booking_nights,
|
||||
created_date_utc as created_date_utc,
|
||||
host_first_name as host_first_name,
|
||||
host_last_name as host_last_name,
|
||||
host_email as host_email,
|
||||
company_name as company_name,
|
||||
guest_first_name as guest_first_name,
|
||||
guest_last_name as guest_last_name,
|
||||
guest_email as guest_email,
|
||||
guest_billing_country as guest_billing_country,
|
||||
guest_billing_town as guest_billing_town,
|
||||
accommodation_country as accommodation_country,
|
||||
accommodation_address as accommodation_address,
|
||||
is_verification_request_complete as is_verification_request_complete,
|
||||
verification_estimated_started_date_utc as verification_estimated_started_date_utc,
|
||||
verification_estimated_completed_date_utc
|
||||
as verification_estimated_completed_date_utc,
|
||||
link_used_date_utc as link_used_date_utc,
|
||||
verification_request_booking_source as verification_request_booking_source,
|
||||
chose_deposit as chose_deposit,
|
||||
chose_fee as chose_fee,
|
||||
chose_waiver as chose_waiver,
|
||||
chose_no_cover as chose_no_cover,
|
||||
chose_checkin_cover as chose_checkin_cover
|
||||
from int_core__bookings_details
|
||||
|
|
@ -1384,3 +1384,178 @@ models:
|
|||
- name: total_bookings
|
||||
data_type: bigint
|
||||
description: "The total number of bookings for this accommodation."
|
||||
|
||||
- name: core__booking_details
|
||||
description: |
|
||||
"Contains detailed information about each booking, including host
|
||||
and guest details, accommodation, and verification request data."
|
||||
|
||||
columns:
|
||||
- name: id_booking
|
||||
data_type: bigint
|
||||
description: "The unique, Superhog generated id for this booking."
|
||||
data_tests:
|
||||
- unique
|
||||
- not_null
|
||||
|
||||
- name: id_user_host
|
||||
data_type: text
|
||||
description: "The unique user ID for the Host."
|
||||
data_tests:
|
||||
- not_null
|
||||
|
||||
- name: id_deal
|
||||
data_type: character varying
|
||||
description:
|
||||
"The ID of the deal of the user. It only applies to client accounts.
|
||||
Can be null."
|
||||
|
||||
- name: id_user_guest
|
||||
data_type: text
|
||||
description: "The unique, Superhog generated id for the guest"
|
||||
|
||||
- name: id_accommodation
|
||||
data_type: bigint
|
||||
description: "Id of the accommodation or listing."
|
||||
|
||||
- name: id_verification_request
|
||||
data_type: bigint
|
||||
description: |
|
||||
The identifier of the verification request. It acts as Foreign Key to
|
||||
Verification Request table. It can be null.
|
||||
|
||||
- name: booking_state
|
||||
data_type: character varying
|
||||
description:
|
||||
"State in which the booking is, could be either of the following:
|
||||
- Approved
|
||||
- NotApproved
|
||||
- Cancelled
|
||||
- Rejected
|
||||
- NoFlags
|
||||
- Flagged
|
||||
- IncompleteInformation"
|
||||
data_tests:
|
||||
- accepted_values:
|
||||
values:
|
||||
- "Approved"
|
||||
- "NotApproved"
|
||||
- "Cancelled"
|
||||
- "Rejected"
|
||||
- "NoFlags"
|
||||
- "Flagged"
|
||||
- "IncompleteInformation"
|
||||
|
||||
- name: is_accommodation_active
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the accommodation is active."
|
||||
|
||||
- name: checkin_date_utc
|
||||
data_type: date
|
||||
description: "Date of check-in of the booking."
|
||||
|
||||
- name: checkout_date_utc
|
||||
data_type: date
|
||||
description: "Date of check-out of the booking."
|
||||
|
||||
- name: booking_nights
|
||||
data_type: integer
|
||||
description: "Number of nights of the booking."
|
||||
|
||||
- name: created_date_utc
|
||||
data_type: timestamp without time zone
|
||||
description: "Date when the booking was created."
|
||||
|
||||
- name: host_first_name
|
||||
data_type: character varying
|
||||
description: "First name of the host."
|
||||
|
||||
- name: host_last_name
|
||||
data_type: character varying
|
||||
description: "Last name of the host."
|
||||
|
||||
- name: host_email
|
||||
data_type: character varying
|
||||
description: "Email of the host."
|
||||
|
||||
- name: company_name
|
||||
data_type: character varying
|
||||
description: "The company name."
|
||||
|
||||
- name: guest_first_name
|
||||
data_type: character varying
|
||||
description: "First name of the guest."
|
||||
|
||||
- name: guest_last_name
|
||||
data_type: character varying
|
||||
description: "Last name of the guest."
|
||||
|
||||
- name: guest_email
|
||||
data_type: character varying
|
||||
description: "Email of the guest."
|
||||
|
||||
- name: guest_billing_country
|
||||
data_type: character varying
|
||||
description: "Billing country of the guest."
|
||||
|
||||
- name: guest_billing_town
|
||||
data_type: character varying
|
||||
description: "Billing town of the guest."
|
||||
|
||||
- name: accommodation_country
|
||||
data_type: character varying
|
||||
description: "Country of the listing"
|
||||
|
||||
- name: accommodation_address
|
||||
data_type: character varying
|
||||
description: "Address of the listing"
|
||||
|
||||
- name: is_verification_request_complete
|
||||
data_type: boolean
|
||||
description: "True if the verification request is considered complete,
|
||||
AKA the guest has finished the full guest journey."
|
||||
|
||||
- name: verification_estimated_started_date_utc
|
||||
data_type: date
|
||||
description: "The estimated date on which the guest started the guest journey."
|
||||
|
||||
- name: verification_estimated_completed_date_utc
|
||||
data_type: date
|
||||
description: "The estimated date on which the guest finished the guest journey."
|
||||
|
||||
- name: link_used_date_utc
|
||||
data_type: date
|
||||
description: "The date on which the guest used the link for the verification."
|
||||
|
||||
- name: verification_request_booking_source
|
||||
data_type: text
|
||||
description: Source type of host of the booking, this could be either;
|
||||
- PMS
|
||||
- OSL
|
||||
- API/MANUAL
|
||||
data_tests:
|
||||
- accepted_values:
|
||||
values:
|
||||
- "PMS"
|
||||
- "OSL"
|
||||
- "API/MANUAL"
|
||||
|
||||
- name: chose_deposit
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose Deposit payment validation."
|
||||
|
||||
- name: chose_fee
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose Fee payment validation."
|
||||
|
||||
- name: chose_waiver
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose Waiver payment validation."
|
||||
|
||||
- name: chose_no_cover
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose No Cover payment validation."
|
||||
|
||||
- name: chose_checkin_cover
|
||||
data_type: boolean
|
||||
description: "Boolean value indicating if the guest chose CheckIn Cover."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue