Skip to content

Conversation

@fivetran-catfritz
Copy link
Contributor

@fivetran-catfritz fivetran-catfritz commented Nov 21, 2025

PR Overview

Package version introduced in this PR:

  • v1.3.0

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

Summary of changes:

  • Add field accounting_period_full_name to end models.
  • When netsuite2__using_to_subsidiary is enabled, netsuite2__balance_sheet applies each transaction’s to_subsidiary fiscal calendar. If to_subsidiary is null, the model falls back to the fiscal calendar of the transaction’s subsidiary_id.

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-catfritz fivetran-catfritz self-assigned this Nov 21, 2025
@fivetran-catfritz fivetran-catfritz linked an issue Nov 21, 2025 that may be closed by this pull request
4 tasks
Comment on lines -57 to -64

primary_subsidiary_calendar as (
select
fiscal_calendar_id,
source_relation
from subsidiaries
where parent_id is null
),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lines 224 and 329 take over for this.


{% if using_to_subsidiary_and_exchange_rate %}
left join subsidiaries as to_subsidiaries
on to_subsidiaries.subsidiary_id = coalesce(transactions_with_converted_amounts.to_subsidiary_id, subsidiaries.subsidiary_id)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

coalesce because to_subsidiary_id can be null


{% if using_to_subsidiary_and_exchange_rate %}
left join subsidiaries as to_subsidiaries
on to_subsidiaries.subsidiary_id = coalesce(transactions_with_converted_amounts.to_subsidiary_id, subsidiaries.subsidiary_id)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

coalesce because to_subsidiary_id can be null

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-catfritz thanks for working through this PR! A few comments and questions before approving.

left join accounting_periods as reporting_accounting_periods
on reporting_accounting_periods.accounting_period_id = transactions_with_converted_amounts.reporting_accounting_period_id
and reporting_accounting_periods.source_relation = transactions_with_converted_amounts.source_relation
and reporting_accounting_periods.fiscal_calendar_id = {{ 'to_subsidiaries' if using_to_subsidiary_and_exchange_rate else 'subsidiaries' }}.fiscal_calendar_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, is this join here necessary if not using to_subsidiaries? For example, was this join previously incorrect having the subsdiaries.fiscal_calendar_id component of the join omitted?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same question for the transaction_accounting_periods join below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I take this out I do get fanout. See the row count for dev vs. prod. Previously this was handled by the old line 230 primary_subsidiary_calendar join, but it limited accounting_periods to those only in the primary subsidiary calendar. For our test data, this was not an issue, but we should not limit it to account for more use cases.
Screenshot 2025-11-25 at 6 19 57 PM

left join accounting_periods as reporting_accounting_periods
on reporting_accounting_periods.accounting_period_id = transactions_with_converted_amounts.reporting_accounting_period_id
and reporting_accounting_periods.source_relation = transactions_with_converted_amounts.source_relation
and reporting_accounting_periods.fiscal_calendar_id = {{ 'to_subsidiaries' if using_to_subsidiary_and_exchange_rate else 'subsidiaries' }}.fiscal_calendar_id
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I take this out I do get fanout. See the row count for dev vs. prod. Previously this was handled by the old line 230 primary_subsidiary_calendar join, but it limited accounting_periods to those only in the primary subsidiary calendar. For our test data, this was not an issue, but we should not limit it to account for more use cases.
Screenshot 2025-11-25 at 6 19 57 PM

or transactions_with_converted_amounts.is_income_statement
where (accounts.is_balancesheet
or transactions_with_converted_amounts.is_income_statement)
and transactions_with_converted_amounts.reporting_accounting_period_id is not null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we no long have an inner join, line 232 accomplishes the same thing.

or transactions_with_converted_amounts.is_income_statement
where (accounts.is_balancesheet
or transactions_with_converted_amounts.is_income_statement)
and transactions_with_converted_amounts.reporting_accounting_period_id is not null
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here. Compensates for the lack on inner join.

fivetran-catfritz and others added 2 commits November 26, 2025 09:46
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Claude README Updater <[email protected]>
Co-authored-by: fivetran-catfritz <[email protected]>
@fivetran-catfritz fivetran-catfritz added the docs:ready Triggers the docs generator workflow. label Nov 26, 2025
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

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.

[Bug] Roll RE on to_subsidiary fiscal calendar

4 participants