Skip to content

Commit

Permalink
fix coupon redemption history, credit payment history, invoice histor…
Browse files Browse the repository at this point in the history
…y comments
  • Loading branch information
btkcodedev committed Aug 15, 2024
1 parent 101999f commit 749c0a2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
SELECT
id AS coupon_redemption_id,
cast(updated_at AS {{ dbt.type_timestamp() }}) AS updated_at,
NULL AS account_id,
NULL AS coupon_id,
account_id,
(coupon->>'id')::text AS coupon_id,
cast(created_at AS {{ dbt.type_timestamp() }}) AS created_at,
currency,
discounted,
Expand All @@ -24,8 +24,8 @@
SELECT
id AS coupon_redemption_id,
cast(updated_at AS {{ dbt.type_timestamp() }}) AS updated_at,
NULL AS account_id,
NULL AS coupon_id,
account_id,
coupon:id::text AS coupon_id,
cast(created_at AS {{ dbt.type_timestamp() }}) AS created_at,
currency,
discounted,
Expand All @@ -44,8 +44,8 @@
SELECT
id AS coupon_redemption_id,
cast(updated_at AS {{ dbt.type_timestamp() }}) AS updated_at,
NULL AS account_id,
NULL AS coupon_id,
account_id,
JSON_EXTRACT_SCALAR(coupon, '$.id') AS coupon_id,
cast(created_at AS {{ dbt.type_timestamp() }}) AS created_at,
currency,
discounted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
SELECT
id AS credit_payment_id,
cast(updated_at AS {{ dbt.type_timestamp() }}) AS updated_at,
NULL AS account_id,
NULL AS action,
account_id,
action,
cast(amount AS {{ dbt.type_float() }}) AS amount,
NULL AS applied_to_invoice_id,
(applied_to_invoice->>'id')::text AS applied_to_invoice_id,
cast(created_at AS {{ dbt.type_timestamp() }}) AS created_at,
currency,
NULL AS refund_transaction_id,
NULL AS original_credit_payment_id,
NULL AS original_invoice_id,
(refund_transaction->>'id')::text AS refund_transaction_id,
(original_credit_payment->>'id')::text AS original_credit_payment_id,
(original_invoice->>'id')::text AS original_invoice_id,
id AS uuid,
NULL AS voided_at,
cast(voided_at AS {{ dbt.type_timestamp() }}) AS voided_at,
ROW_NUMBER() OVER (PARTITION BY id ORDER BY updated_at DESC) = 1 AS is_most_recent_record
FROM
{{ source('source_recurly', 'credit_payments') }}
Expand All @@ -28,17 +28,17 @@
SELECT
id AS credit_payment_id,
cast(updated_at AS {{ dbt.type_timestamp() }}) AS updated_at,
NULL AS account_id,
NULL AS action,
account_id,
action,
cast(amount AS {{ dbt.type_float() }}) AS amount,
NULL AS applied_to_invoice_id,
applied_to_invoice:id::text AS applied_to_invoice_id,
cast(created_at AS {{ dbt.type_timestamp() }}) AS created_at,
currency,
NULL AS refund_transaction_id,
NULL AS original_credit_payment_id,
NULL AS original_invoice_id,
id AS uuid, -- Using 'id' as 'uuid' since there's no separate 'uuid' field
NULL AS voided_at,
refund_transaction:id::text AS refund_transaction_id,
original_credit_payment:id::text AS original_credit_payment_id,
original_invoice:id::text AS original_invoice_id,
id AS uuid,
cast(voided_at AS {{ dbt.type_timestamp() }}) AS voided_at,
ROW_NUMBER() OVER (PARTITION BY id ORDER BY updated_at DESC) = 1 AS is_most_recent_record
FROM
{{ source('source_recurly', 'credit_payments') }}
Expand All @@ -52,17 +52,17 @@
SELECT
id AS credit_payment_id,
cast(updated_at AS {{ dbt.type_timestamp() }}) AS updated_at,
NULL AS account_id,
NULL AS action,
account_id,
action,
cast(amount AS {{ dbt.type_float() }}) AS amount,
NULL AS applied_to_invoice_id,
JSON_EXTRACT_SCALAR(applied_to_invoice, '$.id') AS applied_to_invoice_id,
cast(created_at AS {{ dbt.type_timestamp() }}) AS created_at,
currency,
NULL AS refund_transaction_id,
NULL AS original_credit_payment_id,
NULL AS original_invoice_id,
JSON_EXTRACT_SCALAR(refund_transaction, '$.id') AS refund_transaction_id,
JSON_EXTRACT_SCALAR(original_credit_payment, '$.id') AS original_credit_payment_id,
JSON_EXTRACT_SCALAR(original_invoice, '$.id') AS original_invoice_id,
id AS uuid,
NULL AS voided_at,
cast(voided_at AS {{ dbt.type_timestamp() }}) AS voided_at,
ROW_NUMBER() OVER (PARTITION BY id ORDER BY updated_at DESC) = 1 AS is_most_recent_record
FROM
{{ source('source_recurly', 'credit_payments') }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

WITH tmp AS (
SELECT
NULL AS invoice_id,
id AS invoice_id,
NULL AS updated_at,
NULL AS account_id,
NULL AS balance,
Expand Down

0 comments on commit 749c0a2

Please sign in to comment.