upgrade refunds
This commit is contained in:
parent
2c00bf4f8e
commit
b4dd241c65
1 changed files with 20 additions and 4 deletions
|
|
@ -1,16 +1,26 @@
|
||||||
with
|
with
|
||||||
raw_refunds as (select * from {{ source("stripe_uk", "refunds") }}),
|
raw_refunds as (select * from {{ source("stripe_uk", "refunds") }}),
|
||||||
|
stg_seed__currencies as (select * from {{ ref("stg_seed__currencies") }}),
|
||||||
stg_stripe__refunds as (
|
stg_stripe__refunds as (
|
||||||
select
|
select
|
||||||
{{ adapter.quote("id") }},
|
{{ adapter.quote("id") }},
|
||||||
{{ adapter.quote("amount") }},
|
cast(
|
||||||
|
{{ adapter.quote("amount") }}
|
||||||
|
/ (10 ^ cur.decimal_positions) as numeric(19, 4)
|
||||||
|
) as amount,
|
||||||
{{ adapter.quote("charge") }},
|
{{ adapter.quote("charge") }},
|
||||||
{{ adapter.quote("object") }},
|
{{ adapter.quote("object") }},
|
||||||
{{ adapter.quote("reason") }},
|
{{ adapter.quote("reason") }},
|
||||||
{{ adapter.quote("status") }},
|
{{ adapter.quote("status") }},
|
||||||
to_timestamp({{ adapter.quote("created") }}) as created_at_utc,
|
to_timestamp({{ adapter.quote("created") }}) as created_at_utc,
|
||||||
|
cast(
|
||||||
|
to_timestamp({{ adapter.quote("created") }}) as date
|
||||||
|
) as created_date_utc,
|
||||||
to_timestamp({{ adapter.quote("updated") }}) as updated_at_utc,
|
to_timestamp({{ adapter.quote("updated") }}) as updated_at_utc,
|
||||||
{{ adapter.quote("currency") }},
|
cast(
|
||||||
|
to_timestamp({{ adapter.quote("updated") }}) as date
|
||||||
|
) as updated_date_utc,
|
||||||
|
upper({{ adapter.quote("currency") }}) as currency,
|
||||||
{{ adapter.quote("metadata") }},
|
{{ adapter.quote("metadata") }},
|
||||||
{{ adapter.quote("payment_intent") }},
|
{{ adapter.quote("payment_intent") }},
|
||||||
{{ adapter.quote("receipt_number") }},
|
{{ adapter.quote("receipt_number") }},
|
||||||
|
|
@ -18,9 +28,15 @@ with
|
||||||
{{ adapter.quote("balance_transaction") }},
|
{{ adapter.quote("balance_transaction") }},
|
||||||
{{ adapter.quote("destination_details") }},
|
{{ adapter.quote("destination_details") }},
|
||||||
{{ adapter.quote("source_transfer_reversal") }},
|
{{ adapter.quote("source_transfer_reversal") }},
|
||||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_date
|
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc,
|
||||||
|
cast(
|
||||||
|
{{ adapter.quote("_airbyte_extracted_at") }} as date
|
||||||
|
) as dwh_extracted_date_utc
|
||||||
|
|
||||||
from raw_refunds
|
from raw_refunds r
|
||||||
|
left join
|
||||||
|
stg_seed__currencies cur
|
||||||
|
on upper(r.{{ adapter.quote("currency") }}) = cur.iso_4217_code
|
||||||
)
|
)
|
||||||
select *
|
select *
|
||||||
from stg_stripe__refunds
|
from stg_stripe__refunds
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue