data-dwh-dbt-project/models/intermediate/edeposit/int_edeposit__guesty_verifications.sql
2024-09-04 17:24:55 +02:00

19 lines
571 B
SQL

{% set cost_per_night = 2 %}
-- 2GBP/booked night if booking is approved, to be charged on checkout
with
int_edeposit__verifications as (
select * from {{ ref("int_edeposit__verifications") }}
)
select
v.id_verification,
v.id_booking,
v.is_cancelled,
v.number_nights * {{ cost_per_night }} as total_revenue,
v.created_date_utc,
v.checkout_date_utc
from int_edeposit__verifications v
where
v.verification_source = 'Guesty'
and v.verification_status = 'Approved'
and v.id_booking is not null
and v.number_nights > 0