Skip to content

Commit 17222c8

Browse files
Merge pull request #98 from fivetran/bugfix/updated-line-item-enhanced
line item enhanced updates
2 parents 7cfdfc5 + ad4640b commit 17222c8

15 files changed

+197
-72
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# dbt_stripe v0.15.1
2+
3+
## Bug Fixes
4+
- Updated the logic in `stripe__line_item_enhanced` to properly bring in refund data by adjusting the joins on balance transactions, refunds and charges.
5+
- Since charges and refunds are both types of balance transactions, included an additional join between refunds and balance transactions to bring in refunds at the same level as charges.
6+
- Updated balance transactions join on `connected_account_id` and `source_relation` to look at both charge and refund balance transactions.
7+
- Fixed `fee_amount` logic to sum together charge and refund amounts.
8+
- Coalesced `fee_amount` with zero for invoice-only (non-header) rows and updated downstream summing logic accordingly.
9+
- Updated `transaction_type` logic to not only bring in `charge`, but also return `charge + refund` if the balance transaction has a charge and a refund associated with it, or `payment intent + refund` if the refund balance transaction is not yet tied to a charge.
10+
11+
## Under the Hood
12+
- Modified the consistency tests to better compare differences between production and development rows.
13+
114
# dbt_stripe v0.15.0
215

316
## Breaking Changes

dbt_project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
config-version: 2
22
name: 'stripe'
33

4-
version: '0.15.0'
4+
version: '0.15.1'
55
require-dbt-version: [">=1.3.0", "<2.0.0"]
66
models:
77
stripe:

docs/catalog.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/index.html

Lines changed: 8 additions & 8 deletions
Large diffs are not rendered by default.

docs/manifest.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

integration_tests/ci/sample.profiles.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ integration_tests:
1616
pass: "{{ env_var('CI_REDSHIFT_DBT_PASS') }}"
1717
dbname: "{{ env_var('CI_REDSHIFT_DBT_DBNAME') }}"
1818
port: 5439
19-
schema: stripe_integrations_tests_14
19+
schema: stripe_integrations_tests_15
2020
threads: 8
2121
bigquery:
2222
type: bigquery
2323
method: service-account-json
2424
project: 'dbt-package-testing'
25-
schema: stripe_integrations_tests_14
25+
schema: stripe_integrations_tests_15
2626
threads: 8
2727
keyfile_json: "{{ env_var('GCLOUD_SERVICE_KEY') | as_native }}"
2828
snowflake:
@@ -33,7 +33,7 @@ integration_tests:
3333
role: "{{ env_var('CI_SNOWFLAKE_DBT_ROLE') }}"
3434
database: "{{ env_var('CI_SNOWFLAKE_DBT_DATABASE') }}"
3535
warehouse: "{{ env_var('CI_SNOWFLAKE_DBT_WAREHOUSE') }}"
36-
schema: stripe_integrations_tests_14
36+
schema: stripe_integrations_tests_15
3737
threads: 8
3838
postgres:
3939
type: postgres
@@ -42,13 +42,13 @@ integration_tests:
4242
pass: "{{ env_var('CI_POSTGRES_DBT_PASS') }}"
4343
dbname: "{{ env_var('CI_POSTGRES_DBT_DBNAME') }}"
4444
port: 5432
45-
schema: stripe_integrations_tests_14
45+
schema: stripe_integrations_tests_15
4646
threads: 8
4747
databricks:
4848
catalog: "{{ env_var('CI_DATABRICKS_DBT_CATALOG') }}"
4949
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
5050
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
51-
schema: stripe_integrations_tests_14
51+
schema: stripe_integrations_tests_15
5252
threads: 8
5353
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
5454
type: databricks

integration_tests/dbt_project.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
config-version: 2
22

33
name: 'stripe_integration_tests'
4-
version: '0.15.0'
4+
version: '0.15.1'
55

66
profile: 'integration_tests'
77

88
# For use with validations
99
models:
1010
+schema: "stripe_{{ var('directed_schema','dev') }}"
1111

12-
vars:
13-
stripe_schema: stripe_integrations_tests_14
12+
vars:
13+
stripe_schema: stripe_integrations_tests_15
1414
stripe__standardized_billing_model_enabled: true
1515
stripe__using_credit_notes: true
1616
stripe_source:
@@ -39,7 +39,7 @@ vars:
3939
stripe_credit_note_identifier: "credit_note_data"
4040
stripe_credit_note_line_item_identifier: "credit_note_line_item_data"
4141

42-
stripe__subscription_history: false
42+
stripe__subscription_history: false
4343

4444
seeds:
4545
stripe_integration_tests:

integration_tests/tests/consistency/consistency_activity_itemized_2.sql

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,42 @@
44
) }}
55

66
with prod as (
7-
select balance_transaction_id, dispute_id as dispute_ids -- we don't have multi-dispute records in our data
7+
select balance_transaction_id, dispute_ids
88
from {{ target.schema }}_stripe_prod.stripe__activity_itemized_2
99
),
1010

1111
dev as (
1212
select balance_transaction_id, dispute_ids
1313
from {{ target.schema }}_stripe_dev.stripe__activity_itemized_2
14+
),
15+
16+
prod_not_in_dev as (
17+
-- rows from prod not found in dev
18+
select * from prod
19+
except distinct
20+
select * from dev
21+
),
22+
23+
dev_not_in_prod as (
24+
-- rows from dev not found in prod
25+
select * from dev
26+
except distinct
27+
select * from prod
28+
),
29+
30+
final as (
31+
select
32+
*,
33+
'from prod' as source
34+
from prod_not_in_dev
35+
36+
union all -- union since we only care if rows are produced
37+
38+
select
39+
*,
40+
'from dev' as source
41+
from dev_not_in_prod
1442
)
1543

16-
-- test will return values and fail if the values are different (which they shouldn't be in our test data)
1744
select *
18-
from prod
19-
join dev
20-
on prod.balance_transaction_id = dev.balance_transaction_id
21-
where prod.dispute_ids != dev.dispute_ids
45+
from final

integration_tests/tests/consistency/consistency_balance_change_from_activity_itemized_3.sql

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,42 @@
44
) }}
55

66
with prod as (
7-
select balance_transaction_id, dispute_reason as dispute_reasons -- we don't have multi-dispute records in our data
7+
select balance_transaction_id, dispute_reasons
88
from {{ target.schema }}_stripe_prod.stripe__balance_change_from_activity_itemized_3
99
),
1010

1111
dev as (
1212
select balance_transaction_id, dispute_reasons
1313
from {{ target.schema }}_stripe_dev.stripe__balance_change_from_activity_itemized_3
14+
),
15+
16+
prod_not_in_dev as (
17+
-- rows from prod not found in dev
18+
select * from prod
19+
except distinct
20+
select * from dev
21+
),
22+
23+
dev_not_in_prod as (
24+
-- rows from dev not found in prod
25+
select * from dev
26+
except distinct
27+
select * from prod
28+
),
29+
30+
final as (
31+
select
32+
*,
33+
'from prod' as source
34+
from prod_not_in_dev
35+
36+
union all -- union since we only care if rows are produced
37+
38+
select
39+
*,
40+
'from dev' as source
41+
from dev_not_in_prod
1442
)
1543

16-
-- test will return values and fail if the values are different (which they shouldn't be in our test data)
1744
select *
18-
from prod
19-
join dev
20-
on prod.balance_transaction_id = dev.balance_transaction_id
21-
where prod.dispute_reasons != dev.dispute_reasons
45+
from final

integration_tests/tests/consistency/consistency_daily_overview.sql

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,35 @@ with
1919
from {{ target.schema }}_stripe_{{ prod_or_dev }}.stripe__daily_overview
2020
group by 1,2 -- need to group to remove randomization stemming from rolling totals
2121
),
22-
{% endfor %}
22+
{% endfor %}
2323

24-
final as (
25-
-- test will fail if any rows from prod are not found in dev
26-
(select * from prod
24+
prod_not_in_dev as (
25+
-- rows from prod not found in dev
26+
select * from prod
27+
except distinct
28+
select * from dev
29+
),
30+
31+
dev_not_in_prod as (
32+
-- rows from dev not found in prod
33+
select * from dev
2734
except distinct
28-
select * from dev)
35+
select * from prod
36+
),
37+
38+
final as (
39+
select
40+
*,
41+
'from prod' as source
42+
from prod_not_in_dev
2943

3044
union all -- union since we only care if rows are produced
3145

32-
-- test will fail if any rows from dev are not found in prod
33-
(select * from dev
34-
except distinct
35-
select * from prod)
36-
)
46+
select
47+
*,
48+
'from dev' as source
49+
from dev_not_in_prod
50+
)
3751

3852
select *
3953
from final

integration_tests/tests/consistency/consistency_ending_balance_reconciliation_itemized_4_count.sql

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,42 @@
44
) }}
55

66
with prod as (
7-
select balance_transaction_id, dispute_reason as dispute_reasons -- we don't have multi-dispute records in our data
7+
select balance_transaction_id, dispute_reasons
88
from {{ target.schema }}_stripe_prod.stripe__ending_balance_reconciliation_itemized_4
99
),
1010

1111
dev as (
1212
select balance_transaction_id, dispute_reasons
1313
from {{ target.schema }}_stripe_dev.stripe__ending_balance_reconciliation_itemized_4
14+
),
15+
16+
prod_not_in_dev as (
17+
-- rows from prod not found in dev
18+
select * from prod
19+
except distinct
20+
select * from dev
21+
),
22+
23+
dev_not_in_prod as (
24+
-- rows from dev not found in prod
25+
select * from dev
26+
except distinct
27+
select * from prod
28+
),
29+
30+
final as (
31+
select
32+
*,
33+
'from prod' as source
34+
from prod_not_in_dev
35+
36+
union all -- union since we only care if rows are produced
37+
38+
select
39+
*,
40+
'from dev' as source
41+
from dev_not_in_prod
1442
)
1543

16-
-- test will return values and fail if the values are different (which they shouldn't be in our test data)
1744
select *
18-
from prod
19-
join dev
20-
on prod.balance_transaction_id = dev.balance_transaction_id
21-
where prod.dispute_reasons != dev.dispute_reasons
45+
from final

integration_tests/tests/consistency/consistency_line_item_enhanced.sql

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,43 @@
55

66
with prod as (
77
select *
8+
except(fee_amount, refund_amount, transaction_type) --remove before merge
89
from {{ target.schema }}_stripe_prod.stripe__line_item_enhanced
910
),
1011

1112
dev as (
1213
select *
14+
except(fee_amount, refund_amount, transaction_type) --remove before merge
1315
from {{ target.schema }}_stripe_dev.stripe__line_item_enhanced
14-
),
16+
),
1517

16-
final as (
17-
-- test will fail if any rows from prod are not found in dev
18-
(select * from prod
18+
prod_not_in_dev as (
19+
-- rows from prod not found in dev
20+
select * from prod
1921
except distinct
20-
select * from dev)
22+
select * from dev
23+
),
24+
25+
dev_not_in_prod as (
26+
-- rows from dev not found in prod
27+
select * from dev
28+
except distinct
29+
select * from prod
30+
),
31+
32+
final as (
33+
select
34+
*,
35+
'from prod' as source
36+
from prod_not_in_dev
2137

2238
union all -- union since we only care if rows are produced
2339

24-
-- test will fail if any rows from dev are not found in prod
25-
(select * from dev
26-
except distinct
27-
select * from prod)
28-
)
40+
select
41+
*,
42+
'from dev' as source
43+
from dev_not_in_prod
44+
)
2945

3046
select *
3147
from final

0 commit comments

Comments
 (0)