cast balance amounts to numeric

This commit is contained in:
Pablo Martin 2024-02-23 17:08:58 +01:00
parent 23471e5b87
commit dbecade13c
2 changed files with 15 additions and 6 deletions

View file

@ -12,16 +12,16 @@ models:
data_type: character varying
description: "{{ doc('generic_id_desc') }}"
- name: fee
data_type: bigint
data_type: numeric
description: "Fees paid for this transaction. Represented as a positive integer when assessed."
- name: net
data_type: bigint
data_type: numeric
description: "Net impact to a Stripe balance. A positive value represents incrementing a Stripe balance, and a negative value decrementing a Stripe balance. You can calculate the net impact of a transaction on a balance by amount - fee"
- name: type
data_type: character varying
description: "Transaction type: adjustment, advance, advance_funding, anticipation_repayment, application_fee, application_fee_refund, charge, climate_order_purchase, climate_order_refund, connect_collection_transfer, contribution, issuing_authorization_hold, issuing_authorization_release, issuing_dispute, issuing_transaction, obligation_outbound, obligation_reversal_inbound, payment, payment_failure_refund, payment_network_reserve_hold, payment_network_reserve_release, payment_refund, payment_reversal, payment_unreconciled, payout, payout_cancel, payout_failure, refund, refund_failure, reserve_transaction, reserved_funds, stripe_fee, stripe_fx_fee, tax_fee, topup, topup_reversal, transfer, transfer_cancel, transfer_failure, or transfer_refund. Learn more about balance transaction types and what they represent. To classify transactions for accounting purposes, consider reporting_category instead."
- name: amount
data_type: bigint
data_type: numeric
description: "Gross amount of this transaction. A positive value represents funds charged to another party, and a negative value represents funds sent to another party."
- name: object
data_type: character varying

View file

@ -6,10 +6,19 @@ with
stg_stripe__balance_transactions as (
select
{{ adapter.quote("id") }},
{{ adapter.quote("fee") }} / (10 ^ cur.decimal_positions) as fee,
{{ adapter.quote("net") }} / (10 ^ cur.decimal_positions) as net,
cast(
{{ adapter.quote("fee") }}
/ (10 ^ cur.decimal_positions) as numeric(19, 4)
) as fee,
cast(
{{ adapter.quote("net") }}
/ (10 ^ cur.decimal_positions) as numeric(19, 4)
) as net,
{{ adapter.quote("type") }},
{{ adapter.quote("amount") }} / (10 ^ cur.decimal_positions) as amount,
cast(
{{ adapter.quote("amount") }}
/ (10 ^ cur.decimal_positions) as numeric(19, 4)
) as amount,
{{ adapter.quote("object") }},
{{ adapter.quote("source") }},
{{ adapter.quote("status") }},