model and docs

This commit is contained in:
Pablo Martin 2024-09-17 12:16:52 +02:00
parent ac87ab4cfd
commit f3e9985d0f
2 changed files with 104 additions and 3 deletions

View file

@ -1,4 +1,19 @@
with stg_core__payaway as (select * from {{ ref("stg_core__payaway") }})
with
stg_core__payaway as (select * from {{ ref("stg_core__payaway") }}),
stg_core__currency as (select * from {{ ref("stg_core__currency") }})
select *
from stg_core__payaway
-- 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

View file

@ -3252,3 +3252,89 @@ models:
description: |
Informative field of how many different billing countries are
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.