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

Release v0.15.0: Bug fixes for account numbers, addition of commonly used fields and foreign keys #144

Merged
merged 11 commits into from
Nov 13, 2024

Conversation

fivetran-avinash
Copy link
Contributor

@fivetran-avinash fivetran-avinash commented Nov 12, 2024

PR Overview

This PR will address the following Issue/Feature: [#67], [#135], [#141]

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

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

Breaking Changes (Full refresh required after upgrading)

  • Corrected account_number field logic for the netsuite2__balance_sheet model to match the native Balance Sheet report within Netsuite:
    • Income statement accounts should use the account number of the system-generated retained earnings account.
    • CTA accounts should use the account number of the system-generated CTA account.
    • Since this will change the account_number, a --full-refresh after upgrading will be required.

More Breaking Changes: New Fields

  • Added commonly used fields to specific end models.
  • netsuite2__balance_sheet
    • subsidiary_full_name: Full hierarchical name of the subsidiary.
    • is_account_intercompany: Boolean indicating if a general ledger account recording transactions between subsidiaries of the same organization.
    • is_account_leftside: Boolean indicating if account has a native debit balance.
  • netsuite2__balance_sheet, netsuite2__income_statement, netsuite2__transaction_details
    • account_display_name: Account name without number or hierarchy.
  • netsuite2__transaction_details
    • is_reversal: Boolean indicating line is reversal.
    • reversal_transaction_id: Transaction id of the counterparty in a reversing pair.
    • reversal_date: Transaction date of the counterparty in a reversing pair.
    • is_reversal_defer: Boolean indicating reversal deferral.
    • is_eliminate: Boolean indicating line will auto-eliminate.
    • exchange_rate: Exchange rate used on the transaction.
    • department_full_name: Full hierarchical name of the department.
    • subsidiary_full_name: Full hierarchical name of the subsidiary.
    • subsidiary_currency_symbol: Currency of the subsidiary.
    • transaction_line_amount: Net amount of the transaction line. This is the actual amount entered when it's in a currency other than the functional currency of the subsidiary.
  • Added foreign keys to the following end models to make it easier for customers to join back to source tables for better insights.
    • netsuite2__income_statement: class_id, location_id, department_id
    • netsuite2__transaction_details: customer_id, vendor_id, class_id, location_id, department_id, currency_id, parent_account_id, vendor_category_id (if netsuite2__using_vendor_categories is enabled)

IMPORTANT: All of the affected models have pass-through functionality. If you have already been using passthrough column variables to include the newly added fields (without aliases), you MUST remove the fields from your passthrough variable configuration in order to avoid duplicate column errors.

Feature Updates

  • You can now leverage passthrough columns in netsuite2__transaction_details to bring in additional fields from the locations and subsidiaries source tables. Make sure you aren't bringing in

Under the Hood

  • Additional consistency tests added for each Netsuite2 end model in order to be used during integration test validations.

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:

Able to test and validate there were no major changes on amounts by transaction ids.

Able to run successfully that passthrough columns bring through new columns.

Validation through internal data.

Screenshot 2024-11-11 at 4 40 16 PM

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

💸

@fivetran-avinash fivetran-avinash self-assigned this Nov 12, 2024
fivetran-avinash and others added 4 commits November 11, 2024 17:09
…columns (#136)

* Fix account_number

Fix account_number for system generated accounts.

* Add subsidiaries pass through columns

* Add additional fields

* Fix is_account_intercompany on balance_sheet

* Fix account_number

---------

Co-authored-by: Avinash Kunnath <108772760+fivetran-avinash@users.noreply.github.com>
@fivetran-avinash fivetran-avinash changed the title Release v0.15.0 Release v0.15.0: Bug fixes for account numbers, addition of commonly used fields and foreign keys Nov 12, 2024
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-avinash A few change requests and questions but this is looking good! Additionally, would you be able to inspect the results of the validation tests (particularly the amount and count tests). When viewing the results and removing the final where clause I find that some of the results are null and still passing the condition. Could you double check and see if anything needs to be adjusted on the test side or if some code changes are required. Thanks!

CHANGELOG.md Show resolved Hide resolved
@@ -106,10 +114,17 @@ balance_sheet as (
else accounts.account_id
end as account_id,
case
when not accounts.is_balancesheet then null
when not accounts.is_balancesheet then (select accounts.account_number from accounts where lower(accounts.special_account_type_id) = 'retearnings' limit 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you provide a brief explanation of this subquery. I see it's used in a few other places as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Via @jmongerlyra in the issue:

"The account number for income statement and CTA accounts in the balance sheet model is currently set to NULL. This is not how it is presented on the native Balance Sheet report in NetSuite.

Income statement accounts should use the account number of the system-generated retained earnings account. CTA should use the account number of the system-generated CTA account."

This logic ensures that the account number pulls the retained earnings or CTA account number rather than generating null values. I added some details in the CHANGELOG to call this out.

Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense to me. Thanks for sharing this and calling it out in the CHANGELOG.

CHANGELOG.md Outdated Show resolved Hide resolved
case
when lower(accounts.account_type_id) in ('income', 'othincome') then -transaction_lines.netamount
else transaction_lines.netamount
end as transaction_line_amount
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain this addition a bit more? Will there ever be a scenario where this does not match the transaction_amount?

Copy link
Contributor Author

@fivetran-avinash fivetran-avinash Nov 13, 2024

Choose a reason for hiding this comment

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

This is a new field from the transaction_lines source table, netamount. transaction_amount is being derived from amount in transaction_lines.

According to @jmongerlyra , netamount is the net amount of the transaction line, which is the actual amount entered when it's in a currency other than the functional currency of the subsidiary. Whereas amount is the total amount. I believe these values can be different.

fivetran-avinash and others added 3 commits November 12, 2024 14:04
Co-authored-by: Antonio Ruby Barreto <antonio.ruby.barreto@fastnedcharging.com>
Copy link
Contributor Author

@fivetran-avinash fivetran-avinash left a comment

Choose a reason for hiding this comment

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

@fivetran-joemarkiewicz Pending Buildkite, this is ready for re-review.

Regarding your concern around null test results, I did see this issue in consistency_balance_sheet_amounts because the base of this test is account ids. However, account_ids can be null if accounts have a false is_balancesheet value. So we have a null base that is throwing off the full outer join logic.

For the time being, I created a dummy value for these null cases, and this seemed to prevent the null fanout. But happy to workshop more elegant solutions here if we feel this is a bit hacky.

I didn't see any issues with the other amount test, as it uses a date_day as a base and there are no null transaction dates in our production data. The counts are just comparing row counts, and nothing threw a red flag in terms of these tests.

@@ -5,11 +5,13 @@

with prod as (
select *
except(account_type_name, account_number) --this test has been modified for the purposes of validating this PR. Remove this line before merging.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
except(account_type_name, account_number) --this test has been modified for the purposes of validating this PR. Remove this line before merging.

from {{ target.schema }}_netsuite_prod.netsuite2__balance_sheet
),

dev as (
select *
except(subsidiary_full_name, account_display_name, is_account_intercompany, is_account_leftside, account_type_name, account_number) --this test has been modified for the purposes of validating this PR.Remove this line before merging.
Copy link
Contributor Author

@fivetran-avinash fivetran-avinash Nov 13, 2024

Choose a reason for hiding this comment

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

Suggested change
except(subsidiary_full_name, account_display_name, is_account_intercompany, is_account_leftside, account_type_name, account_number) --this test has been modified for the purposes of validating this PR.Remove this line before merging.

@@ -10,6 +10,7 @@ with prod as (

dev as (
select *
except(account_display_name, class_id, location_id, department_id)--this test has been modified for the purposes of validating this PR. Remove this line before merging.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
except(account_display_name, class_id, location_id, department_id)--this test has been modified for the purposes of validating this PR. Remove this line before merging.

@@ -10,6 +10,7 @@ with prod as (

dev as (
select *
except(is_reversal, reversal_transaction_id, reversal_date, is_reversal_defer, account_display_name, is_eliminate, parent_account_id, customer_id, class_id, location_id, vendor_id, vendor_category_id, currency_id, exchange_rate, department_full_name, subsidiary_full_name, subsidiary_currency_symbol, transaction_line_amount) --this test has been modified for the purposes of validating this PR. Remove this line before merging.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
except(is_reversal, reversal_transaction_id, reversal_date, is_reversal_defer, account_display_name, is_eliminate, parent_account_id, customer_id, class_id, location_id, vendor_id, vendor_category_id, currency_id, exchange_rate, department_full_name, subsidiary_full_name, subsidiary_currency_symbol, transaction_line_amount) --this test has been modified for the purposes of validating this PR. Remove this line before merging.

Copy link
Contributor

Choose a reason for hiding this comment

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

reminder to remove these from the tests

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-avinash thanks for addressing all of my comments. My only remaining comment is that it would be great to add a validation test for the income statement amounts to be used in future reviews.

That is no reason to block this approval and move to release review though. This looks good to me!

@fivetran-avinash
Copy link
Contributor Author

@fivetran-avinash thanks for addressing all of my comments. My only remaining comment is that it would be great to add a validation test for the income statement amounts to be used in future reviews.

That is no reason to block this approval and move to release review though. This looks good to me!

@fivetran-joemarkiewicz Good callout! Actually didn't take too long to create a robust income statement amount consistency test and get it to pass! Moving to release review now.

Screenshot 2024-11-13 at 11 38 08 AM

Copy link
Contributor

@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.

Approved with just a minor update suggestion!

dbt_project.yml Show resolved Hide resolved
@@ -10,6 +10,7 @@ with prod as (

dev as (
select *
except(is_reversal, reversal_transaction_id, reversal_date, is_reversal_defer, account_display_name, is_eliminate, parent_account_id, customer_id, class_id, location_id, vendor_id, vendor_category_id, currency_id, exchange_rate, department_full_name, subsidiary_full_name, subsidiary_currency_symbol, transaction_line_amount) --this test has been modified for the purposes of validating this PR. Remove this line before merging.
Copy link
Contributor

Choose a reason for hiding this comment

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

reminder to remove these from the tests

@fivetran-avinash fivetran-avinash merged commit 72f3fcf into main Nov 13, 2024
9 checks passed
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.

4 participants