Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert cent based fields to major currency unit based #87

Merged
merged 36 commits into from
Jan 22, 2025

Conversation

fivetran-reneeli
Copy link
Contributor

@fivetran-reneeli fivetran-reneeli commented Dec 18, 2024

PR Overview

This PR will address the following Issue/Feature: fivetran/dbt_stripe#100

This PR will result in the following new package version: v0.13.0

Breaking change as customers using only the staging models will experience changes in values in currency-related fields.

Please provide the finalized CHANGELOG entry which details the relevant changes included in this PR:

Breaking Change

  • This package assumes that amount-based fields, which as raw values are represented in the smallest denomination in Stripe, are cent-based. This PR shifts the existing conversion from cents to dollars to further upstream. Previously, currency-related fields were converted in downstream models, but now have been converted directly in staging models. Since currency-related fields now have different values, this is a breaking change.

To disable this default conversion, refer to the README on disabling the stripe__amount_divide variable.

PR Checklist

Basic Validation

Please acknowledge that you have successfully performed the following commands locally:

  • dbt run –full-refresh && dbt test
  • dbt run (if incremental models are present) && dbt test

Before marking this PR as "ready for review" the following have been applied:

  • The appropriate issue has been linked, tagged, and properly assigned
  • All necessary documentation and version upgrades have been applied
  • docs were regenerated (unless this PR does not include any code or yml updates)
  • BuildKite integration tests are passing
  • Detailed validation steps have been provided below

Detailed Validation

Please share any and all of your validation steps:

See validation link in internal ticket

If you had to summarize this PR in an emoji, which would it be?

💃

Copy link
Contributor

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fivetran-reneeli thanks for applying these updates. I have a few comments below before approval. Let me know if you would like to discuss in more detail.

models/stg_stripe__balance_transaction.sql Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
models/stg_stripe.yml Outdated Show resolved Hide resolved
models/stg_stripe.yml Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
@fivetran-reneeli fivetran-reneeli linked an issue Jan 7, 2025 that may be closed by this pull request
4 tasks
Copy link
Contributor

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fivetran-reneeli thanks for these edits, a few more comments in the review. Thanks!

macros/convert_values.sql Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
models/docs.md Outdated Show resolved Hide resolved
Copy link
Contributor

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few remaining comments before approval. Let me know if you have any questions.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
models/docs.md Outdated Show resolved Hide resolved
macros/convert_values.sql Show resolved Hide resolved
fivetran-reneeli and others added 6 commits January 16, 2025 11:01
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Joe Markiewicz <[email protected]>
Copy link
Contributor Author

@fivetran-reneeli fivetran-reneeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fivetran-joemarkiewicz , changes applied!

README.md Show resolved Hide resolved
models/docs.md Outdated Show resolved Hide resolved
macros/convert_values.sql Show resolved Hide resolved
Copy link
Contributor

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fivetran-reneeli a few more change suggestions and notes before approval. The largest change is the request to make the macro more dynamic via the adapter.dispatch and then namespace references. Also, this will need to be a breaking change. See my notes below.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
integration_tests/dbt_project.yml Outdated Show resolved Hide resolved
Comment on lines 1 to 7
{% macro convert_values(field_name, divide_by=100.0, divide_var=var('stripe__convert_values',false), alias=None) %}
{% if divide_var %}
{{ field_name }} / {{ divide_by }} as {{ alias if alias else field_name }}
{% else %}
{{ field_name }} as {{ alias if alias else field_name }}
{% endif %}
{% endmacro %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for not catching this earlier, but we should add the adapter dispatch here in case users ever need to override this while also allowing there to not be any issues if customers have macros with the same name in their own projects (which is likely with a macro named convert_values).

Can you update this to resemble the following structure seen here. Essentially adding the dispatch and then having the default version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the macro, let me know if you have any questions

models/stg_stripe__credit_note.sql Outdated Show resolved Hide resolved
Copy link
Contributor

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -14,7 +14,7 @@ models:
tests:
- not_null
- name: amount
description: Gross amount of the transaction, in cents.
description: Gross amount of the transaction. "{{ doc('convert_values') }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never thought of using doc blocks in this way, neat!

Copy link
Contributor

@fivetran-jamie fivetran-jamie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fivetran-reneeli fivetran-reneeli merged commit d41ea2c into main Jan 22, 2025
8 checks passed
@fivetran-reneeli fivetran-reneeli deleted the feature/standardize_cent_conversions branch January 22, 2025 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Documentation] Move badges below H1 heading
3 participants