Merged PR 2874: Add Payaway table to intermediate
# Description Brings the Payaway table from staging to intermediate. The only significant change is that we change the internal Superhog currency id for the iso4217 code. # 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: #20043
This commit is contained in:
commit
140da0a75d
2 changed files with 105 additions and 0 deletions
19
models/intermediate/core/int_core__payaway.sql
Normal file
19
models/intermediate/core/int_core__payaway.sql
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
with
|
||||||
|
stg_core__payaway as (select * from {{ ref("stg_core__payaway") }}),
|
||||||
|
stg_core__currency as (select * from {{ ref("stg_core__currency") }})
|
||||||
|
|
||||||
|
-- replace currency
|
||||||
|
select
|
||||||
|
pa.id_payaway_plan,
|
||||||
|
pa.id_user_host,
|
||||||
|
pa.start_at_utc,
|
||||||
|
pa.end_at_utc,
|
||||||
|
pa.has_no_end_date,
|
||||||
|
pa.payaway_percentage,
|
||||||
|
pa.payaway_minimum_commission_local_curr,
|
||||||
|
c.iso4217_code as currency,
|
||||||
|
pa.created_at_utc,
|
||||||
|
pa.updated_at_utc,
|
||||||
|
pa.dwh_extracted_at_utc
|
||||||
|
from stg_core__payaway pa
|
||||||
|
left join stg_core__currency c on pa.id_currency = c.id_currency
|
||||||
|
|
@ -3252,3 +3252,89 @@ models:
|
||||||
description: |
|
description: |
|
||||||
Informative field of how many different billing countries are
|
Informative field of how many different billing countries are
|
||||||
associated to this Deal based on the user account configuration.
|
associated to this Deal based on the user account configuration.
|
||||||
|
- name: int_core__payaway
|
||||||
|
description: |
|
||||||
|
Contains all the PayAway plans, which are basically the settings for
|
||||||
|
host-takes-waiver plans with our host customers. All plans have a start
|
||||||
|
and end point in time, which means that any waivers that happen during
|
||||||
|
the range of plan should use the settings of this plan as a reference.
|
||||||
|
|
||||||
|
Plans can be open ended, as in not having a specified end in time. This
|
||||||
|
just means they are indefinitely active until someone changes it.
|
||||||
|
|
||||||
|
Plans can also have a planned end time which sits in the future.
|
||||||
|
columns:
|
||||||
|
- name: id_payaway_plan
|
||||||
|
data_type: bigint
|
||||||
|
description: "The unique id for this plan."
|
||||||
|
tests:
|
||||||
|
- not_null
|
||||||
|
- unique
|
||||||
|
|
||||||
|
- name: id_user_host
|
||||||
|
data_type: character varying
|
||||||
|
description: "The Superhog ID of the host user this record applies to."
|
||||||
|
|
||||||
|
- name: start_at_utc
|
||||||
|
data_type: timestamp without time zone
|
||||||
|
description:
|
||||||
|
The point in time in which this plan became active. It can never be
|
||||||
|
null.
|
||||||
|
|
||||||
|
- name: end_at_utc
|
||||||
|
data_type: timestamp without time zone
|
||||||
|
description:
|
||||||
|
The point in time in which this plan will stop being active. It can
|
||||||
|
be null, which means the plan has no planned end date yet. Should this
|
||||||
|
column have a value, it should always be after the start time of the
|
||||||
|
plan.
|
||||||
|
|
||||||
|
- name: has_no_end_date
|
||||||
|
data_type: boolean
|
||||||
|
description: Syntactic sugar for checking if the plan has a specified end date.
|
||||||
|
|
||||||
|
- name: payaway_percentage
|
||||||
|
data_type: numeric
|
||||||
|
description: |
|
||||||
|
The percentage of the Waiver payments that Superhog will keep as a
|
||||||
|
a fee. Should be between 0% and a 100%. 0% is a valid amount.
|
||||||
|
|
||||||
|
This means that the Superhog fee is computed as:
|
||||||
|
Waiver Amount * payaway_percentage.
|
||||||
|
|
||||||
|
If the amount that comes out of this calculation is smaller than the
|
||||||
|
amount in column payaway_minimum_commission_local_curr, then the
|
||||||
|
Superhog fee becomes payaway_minimum_commission_local_curr instead.
|
||||||
|
So, the final logic becomes:
|
||||||
|
MAX(
|
||||||
|
Waiver Amount * payaway_percentage,
|
||||||
|
payaway_minimum_commission_local_curr
|
||||||
|
)
|
||||||
|
|
||||||
|
- name: payaway_minimum_commission_local_curr
|
||||||
|
data_type: numeric
|
||||||
|
description:
|
||||||
|
The minimum fee that we take from each waiver payment, specified in
|
||||||
|
the currency of the guest payment (so if this record is in dollars, it
|
||||||
|
means it applies to guest payments made in dollars). We will never
|
||||||
|
charge less than this. This can be 0.
|
||||||
|
|
||||||
|
- name: currency
|
||||||
|
data_type: character varying
|
||||||
|
description:
|
||||||
|
The ISO 4217 code for the currency of this record. Must always be
|
||||||
|
filled, otherwise the records is meaningless.
|
||||||
|
tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: created_at_utc
|
||||||
|
data_type: timestamp without time zone
|
||||||
|
description: Timestamp of when the pay away plan was created.
|
||||||
|
|
||||||
|
- name: updated_at_utc
|
||||||
|
data_type: timestamp without time zone
|
||||||
|
description: Timestamp of when the pay away plan to currency was last updated
|
||||||
|
|
||||||
|
- name: dwh_extracted_at_utc
|
||||||
|
data_type: timestamp with time zone
|
||||||
|
description: Timestamp of when this data was extracted into DWH.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue