Merged PR 2865: Propagate tax exclusive check in hero payments

# Description

This PR propagates tax exclusive check in hero payments for the reporting of Check in Hero.
Additionally, it keeps propagating the amounts with tax inclusiveness in case, at some point, we need them. These are with the new naming convention.

In order not to break anything, the previous amounts are duplicated and aliased in reporting.

Lastly, I spent some time adding some clarifications and documenting payments set to currency and the dependant used for check in hero.

# Checklist

- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

Related work items: #20046
This commit is contained in:
Oriol Roqué Paniagua 2024-09-17 07:25:09 +00:00
parent cc837ecd7a
commit 7b9ba021c1
5 changed files with 144 additions and 15 deletions

View file

@ -4,7 +4,9 @@ with
)
select
pvttoc.local_currency_iso_4217,
-- The following fee is tax inclusive
pvttoc.checkin_cover_guest_fee_local_curr,
-- The cover limit is a protection thus the concept of taxes does not make sense
pvttoc.checkin_cover_limit_amount_local_curr
from stg_core__payment_validation_set_to_currency pvttoc
group by

View file

@ -13,12 +13,14 @@ with
check_in_cover_payments as (
select
id_verification_request,
amount_in_txn_currency,
currency,
amount_in_gbp,
payment_status,
payment_paid_date_utc
from {{ ref("int_core__verification_payments") }}
payment_paid_date_utc,
total_amount_in_txn_currency,
amount_without_taxes_in_txn_currency,
total_amount_in_gbp,
amount_without_taxes_in_gbp
from {{ ref("dwh_dbt", "int_core__verification_payments", v="2") }}
where
verification_payment_type = 'CheckInCover' -- 5 is check-in cover
and payment_status in ('Paid', 'Refunded')
@ -38,18 +40,18 @@ select
b.id_accommodation,
vr.is_verification_request_complete,
(
p.amount_in_txn_currency is not null and not b.check_in_sits_in_future
p.total_amount_in_txn_currency is not null and not b.check_in_sits_in_future
) as is_past_check_in,
(
p.amount_in_txn_currency is not null
p.total_amount_in_txn_currency is not null
and b.check_in_sits_in_future
and vr.is_verification_request_complete
) as is_awaiting_check_in,
p.amount_in_txn_currency is not null as cover_was_purchased,
p.total_amount_in_txn_currency is not null as cover_was_purchased,
av.validation_passed as address_validation_passed,
av.notes as address_validation_notes,
(
p.amount_in_txn_currency is null and vr.is_verification_request_complete
p.total_amount_in_txn_currency is null and vr.is_verification_request_complete
) as cover_was_rejected,
vr.verification_url,
vr.callback_url,
@ -88,15 +90,17 @@ select
vr.updated_at_utc,
vr.updated_date_utc,
vr.dwh_extracted_at_utc,
p.amount_in_txn_currency,
p.currency,
p.amount_in_gbp,
p.payment_status,
p.payment_paid_date_utc,
p.total_amount_in_txn_currency,
p.amount_without_taxes_in_txn_currency,
p.total_amount_in_gbp,
p.amount_without_taxes_in_gbp,
ccp.checkin_cover_limit_amount_local_curr,
(
ccp.checkin_cover_limit_amount_local_curr
* (p.amount_in_gbp / p.amount_in_txn_currency)
* (p.total_amount_in_gbp / p.total_amount_in_txn_currency)
)::numeric(18, 4) as checkin_cover_limit_amount_in_gbp
from int_core__verification_requests vr
left join int_core__bookings b on vr.id_verification_request = b.id_verification_request

View file

@ -159,7 +159,8 @@ models:
data_type: numeric
description: |
The fee that the guest user must pay if he wants to purchase the
cover.
cover. This fee is tax inclusive if happen in a country in which
taxes are to be applied
- name: checkin_cover_cover_amount_local_curr
data_type: numeric

View file

@ -27,11 +27,16 @@ select
verification_start_date_utc as verification_start_date_utc,
verification_end_at_utc as verification_end_at_utc,
verification_end_date_utc as verification_end_date_utc,
amount_in_txn_currency as amount_in_txn_currency,
currency as currency,
amount_in_gbp as amount_in_gbp,
payment_status as payment_status,
payment_paid_date_utc as payment_paid_date_utc,
total_amount_in_txn_currency as total_amount_in_txn_currency,
amount_without_taxes_in_txn_currency as amount_without_taxes_in_txn_currency,
total_amount_in_gbp as total_amount_in_gbp,
amount_without_taxes_in_gbp as amount_without_taxes_in_gbp,
total_amount_in_txn_currency as amount_in_txn_currency, -- LEGACY
total_amount_in_gbp as amount_in_gbp, -- LEGACY
checkin_cover_limit_amount_local_curr as checkin_cover_limit_amount_local_curr,
checkin_cover_limit_amount_in_gbp as checkin_cover_limit_amount_in_gbp
from core__vr_check_in_cover

View file

@ -98,7 +98,7 @@ models:
data_type: date
description: "{{ doc('dwh_extracted_date_utc_desc')}}"
- name: stg_core_superhog_user
- name: stg_core__superhog_user
description: "The staging version of Core's SuperhogUser table. Do not confuse with User."
columns:
- name: id_superhoguser
@ -274,3 +274,120 @@ models:
- name: dwh_extracted_at_utc
data_type: timestamp with time zone
description: "Timestamp of when data was extracted to DWH"
- name: stg_core__payment_validation_set_to_currency
description: |
This table contains the prices to be applied for each
host among the different payment services that will apply
to guests.
Each host can have multiple currencies with a different price
set per service. These prices are therefore in the local currency,
not necessarily in GBP. Be aware that services prices are tax
inclusive to those countries in which taxes apply. Lastly, cover
options, understood as protection, do not have taxes because of
the nature of it.
Important note: at this stage, it's not known how are we able to
determine which payment validation set, and therefore, the prices linked
to it for a given verification request.
columns:
- name: id_payment_validation_set_to_currency
data_type: bigint
description: Record id for this table
tests:
- unique
- not_null
- name: id_payment_validation_set
data_type: bigint
description: |
Identifier of the user payment validation set. This id will
appear as many times as different currencies are set per
validation set.
- name: guest_fee_local_curr
data_type: numeric
description: |
The deposit fee to be paid by the guest. This fee gets not refunded.
Tax inclusive in local currency.
- name: deposit_amount_local_curr
data_type: numeric
description: |
The deposit amount that Superhog takes and pays back if there has been no issues.
In local currency.
- name: waiver_guest_fee_amount_local_curr
data_type: numeric
description: |
The waiver fee to be paid by the guest. This fee gets not refunded.
Tax inclusive in local currency.
- name: waiver_protection_amount_local_curr
data_type: numeric
description: |
The protection amount per waiver.
In local currency.
- name: checkin_cover_guest_fee_local_curr
data_type: numeric
description: |
The check in hero fee to be paid by the guest. This fee gets not refunded.
Tax inclusive in local currency.
- name: checkin_cover_limit_amount_local_curr
data_type: numeric
description: |
The cover amount for check in hero.
In local currency.
- name: local_currency_iso_4217
data_type: char(3)
description: |
Three-letter ISO code assigned to the currency used by user.
- name: is_fee_refundable
data_type: boolean
description: |
Whether a fee is refundable or not.
- name: disabled_validation_options
data_type: integer
description: |
Integer corresponding to the sum of services that are disabled.
This is a very tricky field. The way to know which services are
configured is as follows:
CASE WHEN disabled_validation_options & 1 > 0 THEN 0 ELSE 1 END AS [Fee(1)],
CASE WHEN disabled_validation_options & 2 > 0 THEN 0 ELSE 1 END AS [Membership(2)],
CASE WHEN disabled_validation_options & 4 > 0 THEN 0 ELSE 1 END AS [FeeWithDeposit(4)],
CASE WHEN disabled_validation_options & 8 > 0 THEN 0 ELSE 1 END AS [Waiver(8)],
CASE WHEN disabled_validation_options & 16 > 0 THEN 0 ELSE 1 END AS [NoCover(16)]
Note that membership is a legacy validation that no longer exists.
- name: created_at_utc
data_type: timestamp
description: |
Timestamp of when the payment validation set to currency was created
- name: created_date_utc
data_type: date
description: |
Date of when the payment validation set to currency was created
- name: updated_at_utc
data_type: timestamp
description: |
Timestamp of when the payment validation set to currency was last updated
- name: updated_date_utc
data_type: date
description: |
Date of when the payment validation set to currency was last updated
- name: dwh_extracted_at_utc
data_type: timestamp
description: |
Timestamp of when this data was extracted into DWH.