Calculator changes

This commit is contained in:
Joaquin Ossa 2025-02-28 12:19:24 +01:00
parent eeb47cf6d8
commit b20cb44779
6 changed files with 176 additions and 52 deletions

View file

@ -189,20 +189,27 @@ select
-- Resolutions calculator
i.protection_name,
i.was_overriden,
i.waiver_or_deposit_name,
i.guest_verification_status,
i.lower_protection_limit_usd,
i.upper_protection_limit_usd,
i.calculated_payout_amount_in_txn_currency,
i.calculated_payout_currency,
i.calculated_payout_amount_in_usd,
(i.calculated_payout_amount_in_usd * cer.rate)::decimal(
19, 4
) as calculated_payout_amount_in_gbp,
i.submitted_payout_amount_in_txn_currency,
i.submitted_payout_currency,
(i.submitted_payout_amount_in_usd * cer.rate)::decimal(
19, 4
) as submitted_payout_amount_in_gbp,
i.calculated_guest_charge_amount_in_txn_currency,
i.calculated_guest_charge_currency,
(i.calculated_guest_charge_amount_in_usd * cer.rate)::decimal(
19, 4
) as calculated_guest_charge_amount_in_gbp,
i.submitted_guest_charge_amount_in_txn_currency,
i.submitted_guest_charge_currency,
i.submitted_guest_charge_amount_in_usd,
(i.submitted_guest_charge_amount_in_usd * cer.rate)::decimal(
19, 4
) as submitted_guest_charge_amount_in_gbp,

View file

@ -162,12 +162,6 @@ models:
or asked_repair_amount_in_host_currency > 0
or accepted_amount_in_host_currency > 0"
- name: was_overriden
data_type: boolean
description: |
"Flag to indicate if the proposed settlement value from the
calculator was overridden."
- name: guest_verification_status
data_type: text
description: "Guest verification status for this booking."
@ -203,17 +197,55 @@ models:
- not_null:
where: "calculated_payout_amount_in_txn_currency > 0"
- name: calculated_payout_amount_in_usd
- name: calculated_payout_amount_in_gbp
data_type: numeric
description: "Calculated payout amount in USD."
description: "Calculated payout amount in GBP."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: calculated_payout_amount_in_gbp
- name: submitted_payout_amount_in_txn_currency
data_type: numeric
description: "Calculated payout amount in GBP."
description: "Submitted payout amount in local currency."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: submitted_payout_currency
data_type: text
description: "Currency of the submitted payout amount."
data_tests:
- not_null:
where: "submitted_payout_amount_in_txn_currency > 0"
- name: submitted_payout_amount_in_gbp
data_type: numeric
description: "Submitted payout amount in GBP."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: calculated_guest_charge_amount_in_txn_currency
data_type: numeric
description: "Calculated guest charge amount in local currency."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: calculated_guest_charge_currency
data_type: text
description: "Currency of the calculated guest charge amount."
data_tests:
- not_null:
where: "calculated_guest_charge_amount_in_txn_currency > 0"
- name: calculated_guest_charge_amount_in_gbp
data_type: numeric
description: "Calculated guest charge amount in GBP."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
@ -234,14 +266,6 @@ models:
- not_null:
where: "submitted_guest_charge_amount_in_txn_currency > 0"
- name: submitted_guest_charge_amount_in_usd
data_type: numeric
description: "Submitted guest charge amount in USD."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: submitted_guest_charge_amount_in_gbp
data_type: numeric
description: "Submitted guest charge amount in GBP."

View file

@ -30,7 +30,6 @@ select
accepted_amount_in_gbp as accepted_amount_in_gbp,
host_currency as host_currency,
protection_name as protection_name,
was_overriden as was_overriden,
waiver_or_deposit_name as waiver_or_deposit_name,
guest_verification_status as guest_verification_status,
lower_protection_limit_usd as lower_protection_limit_usd,
@ -38,12 +37,17 @@ select
calculated_payout_amount_in_txn_currency
as calculated_payout_amount_in_txn_currency,
calculated_payout_currency as calculated_payout_currency,
calculated_payout_amount_in_usd as calculated_payout_amount_in_usd,
calculated_payout_amount_in_gbp as calculated_payout_amount_in_gbp,
submitted_payout_amount_in_txn_currency as submitted_payout_amount_in_txn_currency,
submitted_payout_currency as submitted_payout_currency,
submitted_payout_amount_in_gbp as submitted_payout_amount_in_gbp,
calculated_guest_charge_amount_in_txn_currency
as calculated_guest_charge_amount_in_txn_currency,
calculated_guest_charge_currency as calculated_guest_charge_currency,
calculated_guest_charge_amount_in_gbp as calculated_guest_charge_amount_in_gbp,
submitted_guest_charge_amount_in_txn_currency
as submitted_guest_charge_amount_in_txn_currency,
submitted_guest_charge_currency as submitted_guest_charge_currency,
submitted_guest_charge_amount_in_usd as submitted_guest_charge_amount_in_usd,
submitted_guest_charge_amount_in_gbp as submitted_guest_charge_amount_in_gbp,
id_user_host as id_user_host,
host_account_name as host_account_name,

View file

@ -162,12 +162,6 @@ models:
or asked_repair_amount_in_host_currency > 0
or accepted_amount_in_host_currency > 0"
- name: was_overriden
data_type: boolean
description: |
"Flag to indicate if the proposed settlement value from the
calculator was overridden."
- name: guest_verification_status
data_type: text
description: "Guest verification status for this booking."
@ -203,17 +197,55 @@ models:
- not_null:
where: "calculated_payout_amount_in_txn_currency > 0"
- name: calculated_payout_amount_in_usd
- name: calculated_payout_amount_in_gbp
data_type: numeric
description: "Calculated payout amount in USD."
description: "Calculated payout amount in GBP."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: calculated_payout_amount_in_gbp
- name: submitted_payout_amount_in_txn_currency
data_type: numeric
description: "Calculated payout amount in GBP."
description: "Submitted payout amount in local currency."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: submitted_payout_currency
data_type: text
description: "Currency of the submitted payout amount."
data_tests:
- not_null:
where: "submitted_payout_amount_in_txn_currency > 0"
- name: submitted_payout_amount_in_gbp
data_type: numeric
description: "Submitted payout amount in GBP."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: calculated_guest_charge_amount_in_txn_currency
data_type: numeric
description: "Calculated guest charge amount in local currency."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: calculated_guest_charge_currency
data_type: text
description: "Currency of the calculated guest charge amount."
data_tests:
- not_null:
where: "calculated_guest_charge_amount_in_txn_currency > 0"
- name: calculated_guest_charge_amount_in_gbp
data_type: numeric
description: "Calculated guest charge amount in GBP."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
@ -234,14 +266,6 @@ models:
- not_null:
where: "submitted_guest_charge_amount_in_txn_currency > 0"
- name: submitted_guest_charge_amount_in_usd
data_type: numeric
description: "Submitted guest charge amount in USD."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: submitted_guest_charge_amount_in_gbp
data_type: numeric
description: "Submitted guest charge amount in GBP."

View file

@ -313,11 +313,6 @@ models:
description: "Indicates the selected booking protection plan,
e.g., Damage Protection Plan."
- name: was_overriden
data_type: boolean
description: "Flag to indicate if the proposed settlement value from
the calculator was overriden."
- name: waiver_or_deposit_name
data_type: text
description: "Indicates whether the guest selected Deposit or Waiver as their cover."
@ -365,6 +360,52 @@ models:
min_value: 0
strictly: false
- name: submitted_payout_amount_in_txn_currency
data_type: numeric
description: "Submitted payout amount in local currency."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: submitted_payout_currency
data_type: text
description: "Currency of the submitted payout amount."
data_tests:
- not_null:
where: "submitted_payout_amount_in_txn_currency > 0"
- name: submitted_payout_amount_in_usd
data_type: numeric
description: "Submitted payout amount in USD."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: calculated_guest_charge_amount_in_txn_currency
data_type: numeric
description: "Calculated guest charge amount in local currency."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: calculated_guest_charge_currency
data_type: text
description: "Currency of the calculated guest charge amount."
data_tests:
- not_null:
where: "calculated_guest_charge_amount_in_txn_currency > 0"
- name: calculated_guest_charge_amount_in_usd
data_type: numeric
description: "Calculated guest charge amount in USD."
data_tests:
- dbt_expectations.expect_column_values_to_be_between:
min_value: 0
strictly: false
- name: submitted_guest_charge_amount_in_txn_currency
data_type: numeric
description: "Submitted guest charge amount in local currency."

View file

@ -200,8 +200,6 @@ select
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'ProtectionName' as protection_name,
({{ adapter.quote("documents") }} -> 'SavedCalculation' ->> 'WasOverriden')::boolean
as was_overriden,
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'WaiverOrDepositName' as waiver_or_deposit_name,
@ -221,16 +219,42 @@ select
(
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'SubmittedHostPayoutAmount'
->> 'CalculatedHostPayoutAmountTheirCurrency'
)::numeric as calculated_payout_amount_in_txn_currency,
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'SubmittedHostPayoutCurrency' as calculated_payout_currency,
->> 'CalculatedHostPayoutCurrency' as calculated_payout_currency,
(
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'CalculatedHostPayoutAmountInUsd'
)::numeric as calculated_payout_amount_in_usd,
(
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'SubmittedHostPayoutAmount'
)::numeric as submitted_payout_amount_in_txn_currency,
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'SubmittedHostPayoutCurrency' as submitted_payout_currency,
(
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'SubmittedHostPayoutAmountUsd'
)::numeric as submitted_payout_amount_in_usd,
(
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'CalculatedGuestChargeAmountTheirCurrency'
)::numeric as calculated_guest_charge_amount_in_txn_currency,
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'CalculatedGuestChargeCurrency' as calculated_guest_charge_currency,
(
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'CalculatedGuestChargeAmountInUsd'
)::numeric as calculated_guest_charge_amount_in_usd,
(
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
@ -242,7 +266,7 @@ select
(
{{ adapter.quote("documents") }}
-> 'SavedCalculation'
->> 'SubmittedGuestChargeAmountInUsd'
->> 'SubmittedGuestChargeAmountUsd'
)::numeric as submitted_guest_charge_amount_in_usd,
-- Third Party Compensation Claim