Skip to content

Feature: Exchange rate addition - #223

Merged
fivetran-avinash merged 18 commits into
mainfrom
feature/exchange-rate
Sep 16, 2026
Merged

fivetran-avinash merged 18 commits into
mainfrom
feature/exchange-rate

Conversation

@fivetran-avinash

@fivetran-avinash fivetran-avinash commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

PR Overview

Package version introduced in this PR:

  • 1.10.0

This PR addresses the following Issue/Feature(s):

  • GA-1032740

Summary of changes:

  • Bringing in exchange rate data, as well as additional variable support to grab the reporting date for the balance sheet and general ledger by period converted amounts.

Submission Checklist

  • Alignment meeting with the reviewer (if needed)
    • Timeline and validation requirements discussed
  • Provide validation details:
    • Validation Steps: Check for unintentional effects (e.g., add/run consistency & integrity tests)
    • Testing Instructions: Confirm the change addresses the issue(s)
    • Focus Areas: Complex logic or queries that need extra attention
  • Merge any relevant open PRs into this PR

Changelog

  • Draft changelog for PR
  • Final changelog for release review

@fivetran-avinash fivetran-avinash self-assigned this Sep 2, 2026
Resolves conflicts in dbt_project.yml/integration_tests/dbt_project.yml
(kept 1.10.0), account_data.csv (combined both branches' new seed
accounts), and CHANGELOG.md (kept newest-first order: 1.10.0, 1.9.2, 1.9.1).
@fivetran-avinash fivetran-avinash added the docs:ready Triggers the docs generator workflow. label Sep 2, 2026
@fivetran-avinash fivetran-avinash added docs:ready Triggers the docs generator workflow. and removed docs:ready Triggers the docs generator workflow. labels Sep 8, 2026

@fivetran-jamie fivetran-jamie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, just some doc-related comments

Comment thread .quickstart/quickstart.yml Outdated
Comment thread .quickstart/quickstart.yml Outdated
Comment thread CHANGELOG.md Outdated
Comment thread models/intermediate/int_quickbooks__general_ledger_balances.sql Outdated
Comment thread .quickstart/quickstart.yml Outdated
Comment thread README.md Outdated
@fivetran-data-model-bot fivetran-data-model-bot removed the docs:ready Triggers the docs generator workflow. label Sep 11, 2026
@fivetran-avinash fivetran-avinash added the docs:ready Triggers the docs generator workflow. label Sep 11, 2026

@fivetran-avinash fivetran-avinash left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fivetran-jamie Ready for re-review!

Comment thread .quickstart/quickstart.yml Outdated
type: string
value: ""
description: "The primary reporting currency, use the same 3-letter ISO currency code (e.g., USD, EUR, GBP, CAD) that appears in your QuickBooks `currency_id` field. Relevant for organizations with multiple currencies, this field defaults to an empty string; when not set, the package applies exchange rate conversions to all transactions, regardless of currency."
description: "The primary reporting currency, use the same 3-letter ISO currency code (e.g., USD, EUR, GBP, CAD) that appears in your QuickBooks `currency_id` field. Relevant for organizations with multiple currencies, this field defaults to an empty string; when not set, the package applies exchange rate conversions to all transactions, regardless of currency. Required if 'Enable Report-Date Balance Sheet FX Conversion' is enabled."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: "The primary reporting currency, use the same 3-letter ISO currency code (e.g., USD, EUR, GBP, CAD) that appears in your QuickBooks `currency_id` field. Relevant for organizations with multiple currencies, this field defaults to an empty string; when not set, the package applies exchange rate conversions to all transactions, regardless of currency. Required if 'Enable Report-Date Balance Sheet FX Conversion' is enabled."
description: "The primary reporting currency, use the same 3-letter ISO currency code (e.g., USD, EUR, GBP, CAD) that appears in your QuickBooks `currency_id` field. Relevant for organizations with multiple currencies, this field defaults to an empty string; when not set, the package applies exchange rate conversions to all transactions, regardless of currency. Required if 'Enable Report-Date Balance Sheet FX Conversion' is true."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

{"name": "rate", "datatype": dbt.type_float()},
{"name": "created_at", "datatype": dbt.type_timestamp()},
{"name": "updated_at", "datatype": dbt.type_timestamp()},
{"name": "_fivetran_deleted", "datatype": "boolean"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
{"name": "_fivetran_deleted", "datatype": "boolean"}
{"name": "_fivetran_deleted", "datatype": dbt.type_boolean()}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated

Comment thread models/intermediate/int_quickbooks__general_ledger_balances.sql
Comment thread README.md
coalesce(period_ending_converted_balance_starter,
first_value(period_ending_converted_balance_starter) over (partition by gl_partition {{ fivetran_utils.partition_by_source_relation(package_name='quickbooks') }}
order by period_last_day rows unbounded preceding)) as period_ending_converted_balance
period_beginning_converted_balance_final as period_beginning_converted_balance,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude suggests that this is using the legacy cumulative sum and needs to be updated to align with period_ending_converted_balance. Summary below:

Accounting identity breaks when report-date FX is enabled

In the final CTE, when using_report_date_fx_conversion: true:

  • period_ending_converted_balance = period_ending_balance_final * report_date_rate (report-date rate)
  • period_beginning_converted_balance = period_beginning_converted_balance_final (legacy cumulative transaction-date sum)

These use different methodologies in the same row. period_beginning[N+1] ≠ period_ending[N]. Any user computing net converted movement from these two columns gets a number that doesn't reconcile.

Fix: add a CTE that materializes period_ending_converted_balance, then derive period_beginning_converted_balance as lag() of it:

gl_report_date_converted as (
    select
        *,
        case
            when report_date_rate is not null
            then period_ending_balance_final * report_date_rate
            else period_ending_converted_balance_legacy
        end as period_ending_converted_balance_final
    from gl_report_date_rate
),

# Then in final:
{% if report_date_fx_enabled %}
lag(period_ending_converted_balance_final) over (
    partition by account_id, source_relation, coalesce(class_id, '0')
    order by period_last_day
) as period_beginning_converted_balance,
period_ending_converted_balance_final as period_ending_converted_balance
{% else %}
period_beginning_converted_balance_final as period_beginning_converted_balance,
period_ending_converted_balance_legacy as period_ending_converted_balance
{% endif %}

First-period lag() returning null is correct — no prior period exists.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Took the above suggestion and applied some changes to account for this, let me know your thoughts!

Comment thread CHANGELOG.md Outdated
@@ -1,3 +1,17 @@
# dbt_quickbooks v1.10.0 (--full-refresh required when enabling `using_report_date_fx_conversion`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would move the full refresh note from the title

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed

Comment thread integration_tests/dbt_project.yml
@fivetran-data-model-bot fivetran-data-model-bot removed the docs:ready Triggers the docs generator workflow. label Sep 15, 2026
@fivetran-avinash fivetran-avinash added docs:ready Triggers the docs generator workflow. and removed docs:ready Triggers the docs generator workflow. labels Sep 15, 2026
@fivetran-avinash fivetran-avinash added the docs:ready Triggers the docs generator workflow. label Sep 15, 2026

@fivetran-avinash fivetran-avinash left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fivetran-jamie Ready for another look!

@fivetran-jamie fivetran-jamie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Two minor suggestions

Comment thread macros/get_report_date_fx_enabled.sql Outdated
Comment thread CHANGELOG.md Outdated
Co-authored-by: Jamie Rodriguez <65564846+fivetran-jamie@users.noreply.github.com>
@fivetran-data-model-bot fivetran-data-model-bot removed the docs:ready Triggers the docs generator workflow. label Sep 15, 2026
@fivetran-avinash fivetran-avinash added the docs:ready Triggers the docs generator workflow. label Sep 15, 2026
Comment thread CHANGELOG.md
@@ -1,3 +1,17 @@
# dbt_quickbooks v1.10.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing PR link

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added

Comment thread README.md

If a matching exchange rate isn't available for an account's currency as of the period's last day, the package falls back to the legacy transaction-date summation method for that account and period.

> IMPORTANT: If you enable `using_report_date_fx_conversion`, you need to run a `--full-refresh` for the change to take effect on historical data.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If users need to run a full refresh to get the conversion on historical data, we should call this out in the changelog.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added it to the schema change section

description: Timestamp of the date which the exchange rate record was last updated.
- name: source_relation
description: "{{ doc('source_relation') }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing _fivetran_deleted

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added

@fivetran-data-model-bot fivetran-data-model-bot removed the docs:ready Triggers the docs generator workflow. label Sep 16, 2026
@fivetran-avinash fivetran-avinash added the docs:ready Triggers the docs generator workflow. label Sep 16, 2026

@fivetran-avinash fivetran-avinash left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fivetran-savage Ready for re-review!

@fivetran-avinash
fivetran-avinash merged commit 6b44f49 into main Sep 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs:ready Triggers the docs generator workflow.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants