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