data-dwh-dbt-project/models/intermediate
Oriol Roqué Paniagua ac73138cf1 Merged PR 5171: First version of Guest Product Payments
# Description

First model for Guest Product Payments. It only contains CIH from Verification Payments (so, the "old" CIH).

Some notes:
* It does not handle taxes computation.
* It converts guest product name to upper case, as the guest product tables are in upper case. I also apply it for payment status, as well as an UNKNOWN status for whenever it's null - we'd need to consider this for the rest of the refactor.
* Computation is placed within a CTE. This is intended since at some point this will include also Guest Product Payments that come from Guest Product related tables.
* Enhanced documentation with respect to Verification Payments V2.

Audit performed:

```
-- THIS GOES INTO AN AUDIT FILE
{% set old_query %}
  select
    *
  from dwh_hybrid.intermediate.int_core__guest_product_payments
{% endset %}

{% set new_query %}
  select
    id_verification_to_payment,
    id_payment,
    is_refundable,
    created_at_utc,
    updated_at_utc,
    payment_due_at_utc,
    payment_due_date_utc,
    payment_paid_at_utc,
    payment_paid_date_utc,
    payment_reference,
    refund_due_at_utc,
    refund_due_date_utc,
    payment_refunded_at_utc,
    payment_refunded_date_utc,
    refund_payment_reference,
    id_user_host,
    id_guest_user as id_user_guest,
    id_verification,
    id_verification_request,
    upper(verification_payment_type) as guest_product_name,
    currency,
    total_amount_in_txn_currency,
    total_amount_in_gbp,
    coalesce(upper(payment_status),'UNKNOWN') as payment_status,
    notes
  from dwh_hybrid.intermediate.int_core__verification_payments_v2
  where verification_payment_type = 'CheckInCover'
{% endset %}

{{
    audit_helper.compare_and_classify_query_results(
        old_query,
        new_query,
        primary_key_columns=["id_verification_to_payment"],
        columns=[
            "id_verification_to_payment",
            "id_payment",
            "is_refundable",
            "created_at_utc",
            "updated_at_utc",
            "payment_due_at_utc",
            "payment_due_date_utc",
            "payment_paid_at_utc",
            "payment_paid_date_utc",
            "payment_reference",
            "refund_due_at_utc",
            "refund_due_date_utc",
            "payment_refunded_at_utc",
            "payment_refunded_date_utc",
            "refund_payment_reference",
            "id_user_host",
            "id_user_guest",
            "id_verification",
            "id_verification_request",
            "guest_product_name",
            "currency",
            "total_amount_in_txn_currency",
            "total_amount_in_gbp",
            "payment_status",
            "notes",
        ],
        sample_limit=10000000,
    )
}}
```

# 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 ...
2025-05-09 10:13:58 +00:00
..
athena Merged PR 5047: First API unified version of Verifications 2025-04-24 12:21:50 +00:00
check_in_hero adding id_deal to api models 2025-03-19 09:23:23 +01:00
core Merged PR 5171: First version of Guest Product Payments 2025-05-09 10:13:58 +00:00
cross Merged PR 5162: Fixes month shift on revenue share and rank 2025-05-08 06:15:44 +00:00
edeposit Addressed comments 2025-03-19 12:06:05 +01:00
hubspot Merged PR 4918: Adds Integration Type from Hubspot Deals 2025-04-04 08:40:38 +00:00
kpis Commit wip 2025-04-28 09:20:59 +02:00
resolutions Calculator changes 2025-02-28 12:19:24 +01:00
screen_and_protect adding id_deal to api models 2025-03-19 09:23:23 +01:00
xero Host Resolution model for report 2025-04-29 11:43:38 +02:00