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
48 changes: 47 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
# dbt_netsuite v0.15.0
For Netsuite2, [PR #144](https://github.com/fivetran/dbt_netsuite/pull/144) includes the following updates:

## 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.
- Cumulative Translation Adjustment (CTA) accounts should use the account number of the system-generated CTA account.
- We modified the logic to ensure the account number is the retained earnings number for income statement accounts in the balance sheet, and CTA rather than null.
- Since this will change the `account_number`, a `--full-refresh` after upgrading will be required.

## New Fields
- Added commonly used fields to each end model. They are listed in the below table.
- Also added foreign keys to each end model to make it easier for customers to join back to source tables for better insights.

| **Models** | **New Fields** |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| [netsuite2__transaction_details](https://fivetran.github.io/dbt_netsuite/#!/model/model.netsuite.netsuite2__transaction_details) | New fields: `is_reversal`, `reversal_transaction_id`, `reversal_date`, `is_reversal_defer`, `is_eliminate`, `exchange_rate`, `department_full_name`, `subsidiary_full_name`, `subsidiary_currency_symbol`, `transaction_line_amount`, `account_display_name` <br> <br> New keys: `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) |
| [netsuite2__balance_sheet](https://fivetran.github.io/dbt_netsuite/#!/model/model.netsuite.netsuite2__balance_sheet) | New fields: `account_display_name`, `subsidiary_full_name`, `is_account_intercompany`, `is_account_leftside` |
| [netsuite2__income_statement](https://fivetran.github.io/dbt_netsuite/#!/model/model.netsuite.netsuite2__income_statement) | New fields: `account_display_name` <br> <br> New keys: `class_id`, `location_id`, `department_id` |


> **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.
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
- To add additional columns to this model, do so by adding our pass-through column variables `locations_pass_through_columns` and `subsidiaries_pass_through_columns` to your `dbt_project.yml` file:

```yml
vars:
locations_pass_through_columns:
- name: "location_custom_field"
subsidiaries_pass_through_columns:
- name: "sub_field"
alias: "subsidiary_field"
```

- For more details on how to passthrough columns, [please consult our README section](https://github.com/fivetran/dbt_netsuite/blob/main/README.md#passing-through-additional-fields).

## Under the Hood
- Additional consistency tests added for each Netsuite2 end model in order to be used during integration test validations.
- Updated yml documentation with new fields.

## Contributors
- [@jmongerlyra](https://github.com/jmongerlyra) ([PR #136](https://github.com/fivetran/dbt_netsuite/pull/136))
- [@fastbarreto](https://github.com/fastbarreto) ([PR #124](https://github.com/fivetran/dbt_netsuite/pull/124))

# dbt_netsuite v0.14.0

For Netsuite2, [PR #138](https://github.com/fivetran/dbt_netsuite/pull/138) and [PR #132](https://github.com/fivetran/dbt_netsuite/pull/132) include the following updates:
Expand Down Expand Up @@ -72,7 +118,7 @@ For Netsuite2, [PR #114](https://github.com/fivetran/dbt_netsuite/pull/114) incl
- transaction_number
- ❗Note: If you have already added any of these fields as passthrough columns to the `transactions_pass_through_columns`, `transaction_lines_pass_through_columns`, `accounts_pass_through_columns`, or `departments_pass_through_columns` vars, you will need to remove or alias these fields from the var to avoid duplicate column errors.

- Removed the unnecessary reference to `entities` in the `netsuit2__transaction_details` model.
- Removed the unnecessary reference to `entities` in the `netsuite2__transaction_details` model.

## 📝 Documentation Update 📝
- [Updated DECISIONLOG](https://github.com/fivetran/dbt_netsuite/blob/main/DECISIONLOG.md#why-converted-transaction-amounts-are-null-if-they-are-non-posting) with our reasoning for why we don't bring in future-facing transactions and leave the `converted_amount` in transaction details empty. ([#115](https://github.com/fivetran/dbt_netsuite/issues/115))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Include the following netsuite package version in your `packages.yml` file:
```yaml
packages:
- package: fivetran/netsuite
version: [">=0.14.0", "<0.15.0"]
version: [">=0.15.0", "<0.16.0"]
```
### Step 3: Define Netsuite.com or Netsuite2 Source
As of April 2022 Fivetran made available a new Netsuite connector which leverages the Netsuite2 endpoint opposed to the original Netsuite.com endpoint. This package is designed to run for either or, not both. By default the `netsuite_data_model` variable for this package is set to the original `netsuite` value which runs the netsuite.com version of the package. If you would like to run the package on Netsuite2 data, you may adjust the `netsuite_data_model` variable to run the `netsuite2` version of the package.
Expand Down
1 change: 1 addition & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ vars:
accounts_pass_through_columns: []
classes_pass_through_columns: []
departments_pass_through_columns: []
subsidiaries_pass_through_columns: []
fivetran-reneeli marked this conversation as resolved.
Show resolved Hide resolved
transactions_pass_through_columns: []
transaction_lines_pass_through_columns: []
balance_sheet_transaction_detail_columns: []
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions integration_tests/ci/sample.profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ integration_tests:
pass: "{{ env_var('CI_REDSHIFT_DBT_PASS') }}"
dbname: "{{ env_var('CI_REDSHIFT_DBT_DBNAME') }}"
port: 5439
schema: netsuite_integration_tests_7
schema: netsuite_integration_tests_8
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: netsuite_integration_tests_7
schema: netsuite_integration_tests_8
threads: 8
keyfile_json: "{{ env_var('GCLOUD_SERVICE_KEY') | as_native }}"
snowflake:
Expand All @@ -33,7 +33,7 @@ integration_tests:
role: "{{ env_var('CI_SNOWFLAKE_DBT_ROLE') }}"
database: "{{ env_var('CI_SNOWFLAKE_DBT_DATABASE') }}"
warehouse: "{{ env_var('CI_SNOWFLAKE_DBT_WAREHOUSE') }}"
schema: netsuite_integration_tests_7
schema: netsuite_integration_tests_8
threads: 8
postgres:
type: postgres
Expand All @@ -42,13 +42,13 @@ integration_tests:
pass: "{{ env_var('CI_POSTGRES_DBT_PASS') }}"
dbname: "{{ env_var('CI_POSTGRES_DBT_DBNAME') }}"
port: 5432
schema: netsuite_integration_tests_7
schema: netsuite_integration_tests_8
threads: 8
databricks:
catalog: "{{ env_var('CI_DATABRICKS_DBT_CATALOG') }}"
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
schema: netsuite_integration_tests_7
schema: netsuite_integration_tests_8
threads: 2
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ models:
# +schema: "netsuite_{{ var('directed_schema','dev') }}" ## To be used for validation tests

vars:
netsuite_schema: netsuite_integration_tests_7
netsuite_schema: netsuite_integration_tests_8
netsuite_data_model_override: netsuite

# Enable below when generating docs
# # Enable below when generating docs
# netsuite2__multibook_accounting_enabled: true
# netsuite2__using_to_subsidiary: true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

with prod as (
select
case when account_id is null then -999999 else account_id end as account_id,
date_trunc(accounting_period_ending, month) as prod_account_period_month,
count(*) as prod_row_count,
sum(converted_amount) as prod_converted_amount
from {{ target.schema }}_netsuite_prod.netsuite2__balance_sheet
where date_trunc(accounting_period_ending, month) < date_trunc(current_date(), month) - 1
group by 1, 2
),

dev as (
select
case when account_id is null then -999999 else account_id end as account_id,
date_trunc(accounting_period_ending, month) as dev_account_period_month,
count(*) as dev_row_count,
sum(converted_amount) as dev_converted_amount
from {{ target.schema }}_netsuite_dev.netsuite2__balance_sheet
where date_trunc(accounting_period_ending, month) < date_trunc(current_date(), month) - 1
group by 1, 2
),

final as (
select
prod.account_id,
prod.prod_account_period_month,
dev.dev_account_period_month,
prod.prod_row_count,
dev.dev_row_count,
prod.prod_converted_amount,
dev.dev_converted_amount
from prod
full outer join dev
on dev.account_id = prod.account_id
and dev.dev_account_period_month = prod.prod_account_period_month
)


select *
from final
where abs(prod_converted_amount - dev_converted_amount) >= 0.01
or abs(prod_row_count - dev_row_count) >= 0.01
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

with prod as (
select
1 as join_key,
count(*) as total_balance_sheet_prod_rows
from {{ target.schema }}_netsuite_prod.netsuite2__balance_sheet
group by 1
),

dev as (
select
1 as join_key,
count(*) as total_balance_sheet_dev_rows
from {{ target.schema }}_netsuite_dev.netsuite2__balance_sheet
group by 1
),

final as (
select
total_balance_sheet_prod_rows,
total_balance_sheet_dev_rows
from prod
full outer join dev
on dev.join_key = prod.join_key
)

select *
from final
where total_balance_sheet_prod_rows != total_balance_sheet_dev_rows
Original file line number Diff line number Diff line change
Expand Up @@ -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.

from {{ target.schema }}_netsuite_dev.netsuite2__income_statement
),

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

with prod as (
select
1 as join_key,
count(*) as total_income_statement_prod_rows
from {{ target.schema }}_netsuite_prod.netsuite2__income_statement
group by 1
),

dev as (
select
1 as join_key,
count(*) as total_income_statement_dev_rows
from {{ target.schema }}_netsuite_dev.netsuite2__income_statement
group by 1
),

final as (
select
total_income_statement_prod_rows,
total_income_statement_dev_rows
from prod
full outer join dev
on dev.join_key = prod.join_key
)

select *
from final
where total_income_statement_prod_rows != total_income_statement_dev_rows
Original file line number Diff line number Diff line change
Expand Up @@ -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

from {{ target.schema }}_netsuite_dev.netsuite2__transaction_details
),

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

with prod as (
select
1 as join_key,
count(*) as total_transaction_detail_prod_rows
from {{ target.schema }}_netsuite_prod.netsuite2__transaction_details
group by 1
),

dev as (
select
1 as join_key,
count(*) as total_transaction_detail_dev_rows
from {{ target.schema }}_netsuite_dev.netsuite2__transaction_details
group by 1
),

final as (
select
total_transaction_detail_prod_rows,
total_transaction_detail_dev_rows
from prod
full outer join dev
on dev.join_key = prod.join_key
)

select *
from final
where total_transaction_detail_prod_rows != total_transaction_detail_dev_rows
Loading