Creation of host_booking_fees
This commit is contained in:
parent
7ec5d91c6a
commit
00e7554300
2 changed files with 116 additions and 1 deletions
30
models/intermediate/core/int_core__host_booking_fees.sql
Normal file
30
models/intermediate/core/int_core__host_booking_fees.sql
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
with
|
||||
stg_core__booking as (select * from {{ ref("stg_core__booking") }}),
|
||||
stg_core__booking_state as (select * from {{ ref("stg_core__booking_state") }}),
|
||||
int_core__booking_charge_events as (
|
||||
select * from {{ ref("int_core__booking_charge_events") }}
|
||||
),
|
||||
int_core__duplicate_bookings as (
|
||||
select * from {{ ref("int_core__duplicate_bookings") }}
|
||||
),
|
||||
int_core__unified_user as (select * from {{ ref("int_core__unified_user") }})
|
||||
select
|
||||
b.id_booking,
|
||||
b.id_user_guest,
|
||||
b.id_user_host,
|
||||
b.id_accommodation,
|
||||
bs.booking_state,
|
||||
db.is_duplicate_booking,
|
||||
bce.booking_fee_local,
|
||||
uu.account_currency_iso4217,
|
||||
bce.booking_fee_charge_at_utc,
|
||||
bce.booking_fee_charge_date_utc
|
||||
from stg_core__booking b
|
||||
left join int_core__booking_charge_events bce on b.id_booking = bce.id_booking
|
||||
left join stg_core__booking_state bs on b.id_booking_state = bs.id_booking_state
|
||||
left join int_core__duplicate_bookings db on b.id_booking = db.id_booking
|
||||
left join
|
||||
int_core__unified_user uu on lower(b.id_user_host) = lower(uu.id_user)
|
||||
-- We user 'lower' because the id_user_host can be found in capital letters or not
|
||||
-- depending on the table and Postgres is case sensitive
|
||||
|
||||
|
|
@ -1572,4 +1572,89 @@ models:
|
|||
data_type: bigint
|
||||
description:
|
||||
"Count of how many Check-in covers have been
|
||||
purchased for this accommodation"
|
||||
purchased for this accommodation"
|
||||
|
||||
- name: int_core__host_booking_fees
|
||||
description:
|
||||
Bookings that have been processed by the Superhog backend.
|
||||
Each record matches one booking and has information on host
|
||||
booking fees, when they were charged and the currency used by
|
||||
the host.
|
||||
|
||||
columns:
|
||||
- name: id_booking
|
||||
data_type: bigint
|
||||
description: "The unique, Superhog generated id for this booking."
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
|
||||
- name: id_user_guest
|
||||
data_type: character varying
|
||||
description: The UUID of the Superhog user playing the guest role in the booking.
|
||||
|
||||
- name: id_user_host
|
||||
data_type: character varying
|
||||
description: The UUID of the Superhog user playing the host role in the booking.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_accommodation
|
||||
data_type: bigint
|
||||
description: The ID of the booked listing.
|
||||
|
||||
- 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"
|
||||
tests:
|
||||
- accepted_values:
|
||||
values:
|
||||
- 'Approved'
|
||||
- 'NotApproved'
|
||||
- 'Cancelled'
|
||||
- 'Rejected'
|
||||
- 'NoFlags'
|
||||
- 'Flagged'
|
||||
- 'IncompleteInformation'
|
||||
|
||||
- name: is_duplicate_booking
|
||||
data_type: boolean
|
||||
description: |
|
||||
A flag that identifies whether the booking is a duplicate.
|
||||
A booking is considered a duplicate if there's an older booking with the same user,
|
||||
accomodation and check-in date. If there are two or more bookings with the same user,
|
||||
accomodation and check-in date, the oldest one will have False as a value in this field,
|
||||
and the other ones will have True as a value in this Failed."
|
||||
Put simply, if you don't want to receive duplicates, filter this field to False.
|
||||
|
||||
- name: booking_fee_local
|
||||
data_type: numeric
|
||||
description: "The fee to apply to the booking, in host currency."
|
||||
|
||||
- name: account_currency_iso4217
|
||||
data_type: character varying
|
||||
description: "Currency used by host/pm/platform users."
|
||||
|
||||
- name: booking_fee_charge_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: |
|
||||
The point in time in which the booking should be invoiced.
|
||||
|
||||
This could be the check-in date of the booking or the date in which the guest verification
|
||||
started, depending on the billing settings of the host.
|
||||
|
||||
- name: booking_fee_charge_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
The date in which the booking should be invoiced.
|
||||
|
||||
This could be the check-in date of the booking or the date in which the guest verification
|
||||
started, depending on the billing settings of the host.
|
||||
Loading…
Add table
Add a link
Reference in a new issue