Skip to content

Commit

Permalink
Merge pull request #21 from fivetran/bug/null-exchange-rate
Browse files Browse the repository at this point in the history
null if addition to transaction exchange rates
  • Loading branch information
fivetran-joemarkiewicz authored Jul 2, 2021
2 parents 4cc3d1b + 727adec commit c811794
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

name: 'shopify'
version: '0.4.1'
version: '0.4.2'
config-version: 2

require-dbt-version: [">=0.18.0", "<0.20.0"]
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/data/shopify_transaction_data.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
id,order_id,refund_id,amount,authorization,created_at,processed_at,device_id,gateway,source_name,message,currency,location_id,parent_id,payment_avs_result_code,kind,currency_exchange_id,currency_exchange_adjustment,currency_exchange_original_amount,currency_exchange_final_amount,currency_exchange_currency,error_code,status,test,user_id,_fivetran_synced,payment_credit_card_bin,payment_cvv_result_code,payment_credit_card_number,payment_credit_card_company,receipt
2667417567303,2181743870023,,415,abcd999999,2020-02-27 16:05:37.000 +0000,2020-02-27 16:05:37.000 +0000,,gateway_here,source_name,message_here,USD,,,Z,sale,,,,,,,success,FALSE,,2020-10-28 20:33:09.797 +0000,,,,,{ "charges": { "data": [ { "balance_transaction": { "exchange_rate": "0.75862" } }] }}
2667417567303,2181743870023,,415,abcd999999,2020-02-27 16:05:37.000 +0000,2020-02-27 16:05:37.000 +0000,,gateway_here,source_name,message_here,USD,,,Z,sale,,,,,,,success,FALSE,,2020-10-28 20:33:09.797 +0000,,,,,{ "charges": { "data": [ { "balance_transaction": { "exchange_rate": null } }] }}
2572210896967,2089104834631,,415,abcd888888,2020-01-12 20:06:37.000 +0000,2020-01-12 20:06:37.000 +0000,,gateway_here,source_name,message_here,USD,,,Y,sale,,,,,,,success,FALSE,,2020-10-28 17:05:27.756 +0000,,,,,
2664325611591,2179107356743,,415,abcd77777,2020-02-26 00:12:37.000 +0000,2020-02-26 00:12:37.000 +0000,,gateway_here,source_name,message_here,USD,,,,sale,,,,,,,success,FALSE,,2020-10-28 20:23:50.344 +0000,,,,,{ "charges": { "data": [ { "balance_transaction": { "exchange_rate": "0.523" } }] }}
2595729735751,2114590769223,,15.95,abcd66666,2020-01-26 11:04:41.000 +0000,2020-01-26 11:04:41.000 +0000,,gateway_here,source_name,message_here,USD,,,Y,sale,,,,,,,success,FALSE,,2020-10-28 18:10:27.604 +0000,,,,,
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'shopify_integration_tests'
version: '0.4.1'
version: '0.4.2'
profile: 'integration_tests'
config-version: 2

Expand Down
7 changes: 3 additions & 4 deletions models/shopify__transactions.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

with transactions as (
select *
from {{ var('shopify_transaction') }}
Expand All @@ -7,11 +6,11 @@ with transactions as (

select
*,
coalesce(cast({{ fivetran_utils.json_parse("receipt",["charges","data",0,"balance_transaction","exchange_rate"]) }} as {{ dbt_utils.type_numeric() }} ),1) as exchange_rate,
coalesce(cast({{ fivetran_utils.json_parse("receipt",["charges","data",0,"balance_transaction","exchange_rate"]) }} as {{ dbt_utils.type_numeric() }} ),1) * amount as currency_exchange_calculated_amount
coalesce(cast(nullif({{ fivetran_utils.json_parse("receipt",["charges","data",0,"balance_transaction","exchange_rate"]) }}, '') as {{ dbt_utils.type_numeric() }} ),1) as exchange_rate,
coalesce(cast(nullif({{ fivetran_utils.json_parse("receipt",["charges","data",0,"balance_transaction","exchange_rate"]) }}, '') as {{ dbt_utils.type_numeric() }} ),1) * amount as currency_exchange_calculated_amount
from transactions

)

select *
from exchange_rate
from exchange_rate

0 comments on commit c811794

Please sign in to comment.