-
Notifications
You must be signed in to change notification settings - Fork 39
Feature/retained earnings to sub calendar #187
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
base: main
Are you sure you want to change the base?
Feature/retained earnings to sub calendar #187
Conversation
…_with_converted_amounts.to_subsidiary_id, subsidiaries.subsidiary_id)
|
|
||
| primary_subsidiary_calendar as ( | ||
| select | ||
| fiscal_calendar_id, | ||
| source_relation | ||
| from subsidiaries | ||
| where parent_id is null | ||
| ), |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
fivetran-joemarkiewicz
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.

| 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 |
There was a problem hiding this comment.
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.

| 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Co-authored-by: Joe Markiewicz <[email protected]>
Co-authored-by: Claude README Updater <[email protected]> Co-authored-by: fivetran-catfritz <[email protected]>
fivetran-joemarkiewicz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR Overview
Package version introduced in this PR:
This PR addresses the following Issue/Feature(s):
Summary of changes:
accounting_period_full_nameto end models.netsuite2__using_to_subsidiaryis enabled,netsuite2__balance_sheetapplies each transaction’sto_subsidiaryfiscal calendar. Ifto_subsidiaryisnull, the model falls back to the fiscal calendar of the transaction’ssubsidiary_id.Submission Checklist
Changelog