From ac87ab4cfd4032892adc99d06d2a2ecf78fe7cf2 Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Tue, 17 Sep 2024 11:56:21 +0200 Subject: [PATCH 1/2] create file --- models/intermediate/core/int_core__payaway.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 models/intermediate/core/int_core__payaway.sql diff --git a/models/intermediate/core/int_core__payaway.sql b/models/intermediate/core/int_core__payaway.sql new file mode 100644 index 0000000..d6b570b --- /dev/null +++ b/models/intermediate/core/int_core__payaway.sql @@ -0,0 +1,4 @@ +with stg_core__payaway as (select * from {{ ref("stg_core__payaway") }}) + +select * +from stg_core__payaway From f3e9985d0f6d9131d1363190f5777585e9bfb06e Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Tue, 17 Sep 2024 12:16:52 +0200 Subject: [PATCH 2/2] model and docs --- .../intermediate/core/int_core__payaway.sql | 21 ++++- models/intermediate/core/schema.yml | 86 +++++++++++++++++++ 2 files changed, 104 insertions(+), 3 deletions(-) diff --git a/models/intermediate/core/int_core__payaway.sql b/models/intermediate/core/int_core__payaway.sql index d6b570b..918c54f 100644 --- a/models/intermediate/core/int_core__payaway.sql +++ b/models/intermediate/core/int_core__payaway.sql @@ -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 diff --git a/models/intermediate/core/schema.yml b/models/intermediate/core/schema.yml index 8a57965..976b09a 100644 --- a/models/intermediate/core/schema.yml +++ b/models/intermediate/core/schema.yml @@ -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.