e-deposit verifications data to intermediate
This commit is contained in:
parent
7786f2e770
commit
a1e3174700
2 changed files with 56 additions and 19 deletions
|
|
@ -4,30 +4,13 @@ with
|
|||
),
|
||||
edeposit_records as (
|
||||
select
|
||||
id_booking,
|
||||
cancelled_at_utc,
|
||||
is_cancelled,
|
||||
channel,
|
||||
cast(checkin_at_utc as date) as checkin_date_utc,
|
||||
cast(checkout_at_utc as date) as checkout_date_utc,
|
||||
property_manager_name,
|
||||
created_at_utc,
|
||||
creation_at_utc,
|
||||
id_listing,
|
||||
listing_country,
|
||||
listing_town,
|
||||
cast(checkout_at_utc as date) - cast(checkin_at_utc as date) as nights,
|
||||
cast(nightly_fee_local as float) as nightly_fee_local,
|
||||
verification_status,
|
||||
status_updated_at_utc,
|
||||
updated_at_utc,
|
||||
id_user,
|
||||
id as verification_id,
|
||||
case
|
||||
when verification_status = 'Approved' or verification_status = 'Flagged'
|
||||
then cast(nightly_fee_local as float)
|
||||
else 0
|
||||
end as ok_status_night_fee,
|
||||
case
|
||||
when verification_status = 'Approved' or verification_status = 'Flagged'
|
||||
then
|
||||
|
|
@ -39,8 +22,7 @@ with
|
|||
when verification_status = 'Rejected' then 0.25 else 0
|
||||
end as rejected_fee,
|
||||
to_char(creation_at_utc, 'YYYY-MM') as year_month_created,
|
||||
to_char(checkout_at_utc, 'YYYY-MM') as year_month_checkout,
|
||||
"version"
|
||||
to_char(checkout_at_utc, 'YYYY-MM') as year_month_checkout
|
||||
from {{ ref("stg_edeposit__verifications") }} -- Use ref() to reference other dbt models
|
||||
where version = 'V2'
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2767,3 +2767,58 @@ models:
|
|||
data_type: integer
|
||||
description: |
|
||||
Integer-based flag version of total_bookings_with_product_bundle_with_paid_service.
|
||||
- name: int_core__edeposit_verifications
|
||||
description:
|
||||
"This table holds detailed data on revenue generated through e-deposit verifications.
|
||||
Each record provides insights into booking activities per user, including the number
|
||||
of bookings, cancellations, and associated fees within specific months. Each record
|
||||
captures data for bookings created in a particular month along with their corresponding
|
||||
checkout month, allowing for a comprehensive view of the booking lifecycle and associated
|
||||
revenues within those periods."
|
||||
tests:
|
||||
- dbt_utils.unique_combination_of_columns:
|
||||
combination_of_columns:
|
||||
- year_month_created
|
||||
- year_month_checkout
|
||||
- id_user
|
||||
columns:
|
||||
- name: year_month_created
|
||||
data_type: text
|
||||
description: "first day of month of created date"
|
||||
|
||||
- name: year_month_checkout
|
||||
data_type: text
|
||||
description: "first day of month of check-out date"
|
||||
|
||||
- name: id_user
|
||||
data_type: text
|
||||
description: "unique id value for user"
|
||||
|
||||
- name: bookings_per_month
|
||||
data_type: bigint
|
||||
description: "total number of bookings"
|
||||
|
||||
- name: cancelled_per_month
|
||||
data_type: bigint
|
||||
description: "number of cancelled bookings"
|
||||
|
||||
- name: cancelled_ratio
|
||||
data_type: numeric
|
||||
description: "ratio of cancelled bookings over total bookings"
|
||||
|
||||
- name: sum_cancelled_fee
|
||||
data_type: numeric
|
||||
description: "sum of fees charged for cancelled bookings"
|
||||
|
||||
- name: ok_status_fee_sum
|
||||
data_type: double precision
|
||||
description: |
|
||||
"sum of fees charged for bookings with status 'Approved' or 'Flagged'"
|
||||
|
||||
- name: rejected_fee_sum
|
||||
data_type: numeric
|
||||
description: "sum of fees charged for rejected bookings"
|
||||
|
||||
- name: total_revenue
|
||||
data_type: double precision
|
||||
description: "total sum of fees charged"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue