Skip to content
28 changes: 19 additions & 9 deletions .quickstart/quickstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,41 @@ supported_vars:
description: "Additional `CLASSIFICATION` columns to include in `netsuite2__income_statement`"
display_name: "Additional Class Columns"

customers_pass_through_columns:
type: dictionary
description: "Additional `CUSTOMER` columns to include in `netsuite2__transaction_details`"
display_name: "Additional Customer Columns"

departments_pass_through_columns:
type: dictionary
description: "Additional `DEPARTMENT` columns to include in `netsuite2__transaction_details` and `netsuite2__income_statement`"
display_name: "Additional Department Columns"

transactions_pass_through_columns:
items_pass_through_columns:
type: dictionary
description: "Additional `TRANSACTION` columns to include in `netsuite2__transaction_details`"
display_name: "Additional Transaction Columns"

transaction_lines_pass_through_columns:
type: dictionary
description: "Additional `TRANSACTION_LINE` columns to include in `netsuite2__transaction_details`"
display_name: "Additional Transaction Line Columns"
description: "Additional `ITEM` columns to include in `netsuite2__transaction_details`"
display_name: "Additional Item Columns"

locations_pass_through_columns:
type: dictionary
description: "Additional `LOCATION` columns to include in `netsuite2__transaction_details`"
display_name: "Additional Location Columns"

subsidiaries_pass_through_columns:
type: dictionary
description: "Additional `SUBSIDIARY` columns to include in `netsuite2__transaction_details`"
display_name: "Additional Subsidiary Columns"

transactions_pass_through_columns:
type: dictionary
description: "Additional `TRANSACTION` columns to include in `netsuite2__transaction_details`"
display_name: "Additional Transaction Columns"

transaction_lines_pass_through_columns:
type: dictionary
description: "Additional `TRANSACTION_LINE` columns to include in `netsuite2__transaction_details`"
display_name: "Additional Transaction Line Columns"

balance_sheet_transaction_detail_columns:
type: list
description: "Additional columns from `netsuite2__transaction_details` to include in `netsuite2__balance_sheet`"
Expand Down
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
# dbt_netsuite v1.6.0
[PR #200](https://github.com/fivetran/dbt_netsuite/pull/200) includes the following updates:

## Schema/Data Changes (--full-refresh required after upgrading)

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.

Is the reason we don't bring in these rows because they don't impact Quickstart users?

| stg_netsuite2__transaction_accounting_lines | New field | | amount_linked | |
| stg_netsuite2__transaction_lines | New field | | _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.

Yep

**5 total changes • 2 possible breaking changes**

| Data Model(s) | Change type | Old | New | Notes |
| ------------- | ----------- | --- | --- | ----- |
| `netsuite2__transaction_details`<br>`netsuite2__entity_subsidiary_relationships` | Filter on `VENDOR` data | Soft-deleted records excluded | Soft-deleted records included | |

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.

Should we include stg_netsuite2__vendors here (or not since it doesn't impact Quickstart customers)?

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.

Thinking no since it doesn't impact them

| `netsuite2__transaction_details`<br>`stg_netsuite2__transaction_accounting_lines` | New field | | `amount_linked` | The amount applied against another transaction (e.g. a payment applied to an invoice). |
| `stg_netsuite2__customers` | New fields | | `is_inactive`, `comments`, `url`, `created_at` | **Breaking Change (dbt Core):** Remove from `customers_pass_through_columns` if currently included. |
| `stg_netsuite2__entities` | New fields | | `date_created`, `_fivetran_deleted` | **Breaking Change (dbt Core):** Remove from `entities_pass_through_columns` if currently included. |
| `stg_netsuite2__transaction_lines`<br>`stg_netsuite2__transactions` | New field | | `_fivetran_deleted` | Soft-deleted `TRANSACTION` records are still filtered out. |

## Feature Update
- Adds **Additional Customer Columns** (`customers_pass_through_columns` [in dbt Core](https://github.com/fivetran/dbt_netsuite#passing-through-additional-fields)) and **Additional Item Columns** (`items_pass_through_columns` [in dbt Core](https://github.com/fivetran/dbt_netsuite#passing-through-additional-fields)) to Quickstart, persisting chosen custom columns from the `CUSTOMER` and `ITEM` source tables. These fields are brought into `netsuite2__transaction_details`.

# dbt_netsuite v1.6.0-a1
[PR #200](https://github.com/fivetran/dbt_netsuite/pull/200) includes the following updates:

## Schema/Data Changes (--full-refresh required after upgrading)
**2 total changes • 0 possible breaking changes**

| Data Model(s) | Change type | Old | New | Notes |
| ------------- | ----------- | --- | --- | ----- |
| `netsuite2__transaction_details`<br>`netsuite2__entity_subsidiary_relationships` | Filter on `VENDOR` data | Soft-deleted records excluded | Soft-deleted records included | |
| `netsuite2__transaction_details` | New field | | `amount_linked` | The amount applied against another transaction (e.g. a payment applied to an invoice). |

<details><summary> <i>dbt Core/Additional Details</i> </summary>

**5 total changes • 2 possible breaking changes**
Comment thread
fivetran-avinash marked this conversation as resolved.

| Data Model(s) | Change type | Old | New | Notes |
| ------------- | ----------- | --- | --- | ----- |
| `stg_netsuite2__customers` | New fields | | `is_inactive`, `comments`, `url`, `created_at` | **Breaking Change:** Remove from `customers_pass_through_columns` if currently included. |
| `stg_netsuite2__entities` | New fields | | `date_created`, `_fivetran_deleted` | **Breaking Change:** Remove from `entities_pass_through_columns` if currently included. |
| `stg_netsuite2__transaction_accounting_lines` | New field | | `amount_linked` | |
| `stg_netsuite2__transaction_lines` | New field | | `_fivetran_deleted` | |
| `stg_netsuite2__transactions` | New field | | `_fivetran_deleted` | Soft-deleted records are still filtered out. |
Comment thread
fivetran-avinash marked this conversation as resolved.

</details>
<br>

## Feature Update
- Adds **Additional Customer Columns** (`customers_pass_through_columns` [in dbt Core](https://github.com/fivetran/dbt_netsuite#passing-through-additional-fields)) and **Additional Item Columns** (`items_pass_through_columns` [in dbt Core](https://github.com/fivetran/dbt_netsuite#passing-through-additional-fields)) to Quickstart, persisting chosen custom columns from the `CUSTOMER` and `ITEM` source tables. These fields are brought into `netsuite2__transaction_details`.

# dbt_netsuite v1.5.1
[PR #199](https://github.com/fivetran/dbt_netsuite/pull/199) includes the following updates:

Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Include the following netsuite package version in your `packages.yml` file:
```yaml
packages:
- package: fivetran/netsuite
version: [">=1.5.0", "<1.6.0"]
version: [">=1.6.0", "<1.7.0"]
```

#### Databricks dispatch configuration
Expand Down Expand Up @@ -272,40 +272,40 @@ vars:
accounts_pass_through_columns: # Included in all end models
- name: "new_custom_field"
alias: "custom_field"
classes_pass_through_columns: # Included in income_statement models
classes_pass_through_columns: # Included in income_statement model
- name: "this_field"
customers_pass_through_columns: # Included in transaction_details model
- name: "customer_custom_field"
alias: "customer_field"
items_pass_through_columns: # Included in transaction_details model
- name: "items_custom_field"
departments_pass_through_columns: # Included in income_statement and transaction_details models
- name: "unique_string_field"
alias: "field_id"
transform_sql: "cast(field_id as string)"
transactions_pass_through_columns: # Included in transaction_details models
transactions_pass_through_columns: # Included in transaction_details model
- name: "that_field"
transaction_lines_pass_through_columns: # Included in transaction_details models
transaction_lines_pass_through_columns: # Included in transaction_details model
- name: "other_id"
alias: "another_id"
transform_sql: "cast(another_id as int64)"
locations_pass_through_columns: # Included in transaction_details models
locations_pass_through_columns: # Included in transaction_details model
- name: "location_custom_field"
subsidiaries_pass_through_columns: # Included in transaction_details models
subsidiaries_pass_through_columns: # Included in transaction_details model
- name: "sub_field"
alias: "subsidiary_field"
customers_pass_through_columns: # Not included in end models; only in stg customer models
- name: "customer_custom_field"
alias: "customer_field"
consolidated_exchange_rates_pass_through_columns: # Not included in end models; only in stg consolidated_exchange_rates models
consolidated_exchange_rates_pass_through_columns: # Not included in end models; only in stg consolidated_exchange_rates model
- name: "consolidate_this_field"
entities_pass_through_columns: # Not included in end models; only in stg entities model
- name: "entity_custom_field"
alias: "entity_field"
accounting_periods_pass_through_columns: # Not included in end models; only in stg accounting_periods models
accounting_periods_pass_through_columns: # Not included in end models; only in stg accounting_periods model
- name: "custom_field"
transform_sql: "cast(custom_field as string)"
vendors_pass_through_columns: # Not included in end models; only in stg vendors models
vendors_pass_through_columns: # Not included in end models; only in stg vendors model
- name: "vendors_custom_field"
alias: "vendors_field"
items_pass_through_columns: # Not included in end models; only in stg items models
- name: "items_custom_field"
nexuses_pass_through_columns: # Not included in end models; only in stg items models
nexuses_pass_through_columns: # Not included in end models; only in stg nexuses model
- name: "items_custom_field"
```

Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config-version: 2
name: 'netsuite'
version: '1.5.1'
version: '1.6.0'
require-dbt-version: [">=1.3.0", "<3.0.0"]

models:
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.

2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'netsuite_integration_tests'
version: '1.5.1'
version: '1.6.0'
profile: 'integration_tests'
config-version: 2

Expand Down
10 changes: 5 additions & 5 deletions integration_tests/seeds/netsuite2_transaction_data.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_fivetran_synced,_fivetran_active,id,transactionnumber,type,memo,trandate,status,createddate,duedate,closedate,currency,entity,postingperiod,posting,isreversal,reversal,reversaldate,reversaldefer
2022-05-27 13:41:13,TRUE,5914,,VendBill,,2017-05-07 0:00:00,A,2017-05-07 10:34:43,2017-05-05 0:00:00,,1,1570,,T,F,325251,2023-08-01 0:00:00,F
2022-05-27 13:41:13,TRUE,3,,VendBill,,2015-09-10 0:00:00,B,2017-05-12 3:41:25,2015-10-09 0:00:00,2015-10-05 0:00:00,1,36,251,T,F,325252,2023-08-02 0:00:00,F
2022-05-27 13:41:13,TRUE,302,,VendBill,ZZZZZ,2016-03-20 0:00:00,B,2017-04-25 3:41:25,2016-04-19 0:00:00,2017-05-07 0:00:00,1,5,261,T,F,325323,2023-08-03 0:00:00,F
2022-05-26 13:41:13,FALSE,302,,VendBill,ZZZZZ,2016-03-20 0:00:00,B,2017-04-25 3:41:25,2016-04-19 0:00:00,2017-05-07 0:00:00,1,5,261,T,F,325323,2023-08-03 0:00:00,F
_fivetran_synced,_fivetran_active,_fivetran_deleted,id,transactionnumber,type,memo,trandate,status,createddate,duedate,closedate,currency,entity,postingperiod,posting,isreversal,reversal,reversaldate,reversaldefer
2022-05-27 13:41:13,TRUE,FALSE,5914,,VendBill,,2017-05-07 0:00:00,A,2017-05-07 10:34:43,2017-05-05 0:00:00,,1,1570,,T,F,325251,2023-08-01 0:00:00,F
2022-05-27 13:41:13,TRUE,FALSE,3,,VendBill,,2015-09-10 0:00:00,B,2017-05-12 3:41:25,2015-10-09 0:00:00,2015-10-05 0:00:00,1,36,251,T,F,325252,2023-08-02 0:00:00,F
2022-05-27 13:41:13,TRUE,FALSE,302,,VendBill,ZZZZZ,2016-03-20 0:00:00,B,2017-04-25 3:41:25,2016-04-19 0:00:00,2017-05-07 0:00:00,1,5,261,T,F,325323,2023-08-03 0:00:00,F
2022-05-26 13:41:13,FALSE,FALSE,302,,VendBill,ZZZZZ,2016-03-20 0:00:00,B,2017-04-25 3:41:25,2016-04-19 0:00:00,2017-05-07 0:00:00,1,5,261,T,F,325323,2023-08-03 0:00:00,F
6 changes: 5 additions & 1 deletion macros/staging/get_customers_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@
{"name": "externalid", "datatype": dbt.type_string()},
{"name": "parent", "datatype": dbt.type_int()},
{"name": "isperson", "datatype": dbt.type_string()},
{"name": "isinactive", "datatype": dbt.type_string()},
{"name": "altname", "datatype": dbt.type_string()},
{"name": "companyname", "datatype": dbt.type_string()},
{"name": "firstname", "datatype": dbt.type_string()},
{"name": "lastname", "datatype": dbt.type_string()},
{"name": "email", "datatype": dbt.type_string()},
{"name": "phone", "datatype": dbt.type_string()},
{"name": "comments", "datatype": dbt.type_string()},
{"name": "url", "datatype": dbt.type_string()},
{"name": "defaultbillingaddress", "datatype": dbt.type_int()},
{"name": "defaultshippingaddress", "datatype": dbt.type_int()},
{"name": "receivablesaccount", "datatype": dbt.type_int()},
{"name": "currency", "datatype": dbt.type_int()},
{"name": "firstorderdate", "datatype": dbt.type_timestamp()}
{"name": "firstorderdate", "datatype": dbt.type_timestamp()},
{"name": "datecreated", "datatype": dbt.type_timestamp()}
] %}

{{ fivetran_utils.add_pass_through_columns(columns, var('customers_pass_through_columns')) }}
Expand Down
1 change: 1 addition & 0 deletions macros/staging/get_entity_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{"name": "_fivetran_synced", "datatype": dbt.type_timestamp()},
{"name": "contact", "datatype": dbt.type_int()},
{"name": "customer", "datatype": dbt.type_int()},
{"name": "datecreated", "datatype": dbt.type_timestamp()},
{"name": "employee", "datatype": dbt.type_int()},
{"name": "entitytitle", "datatype": dbt.type_string()},
{"name": "id", "datatype": dbt.type_int()},
Expand Down
1 change: 1 addition & 0 deletions macros/staging/get_transactionaccountingline_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
{"name": "account", "datatype": dbt.type_int()},
{"name": "accountingbook", "datatype": dbt.type_int()},
{"name": "amount", "datatype": dbt.type_float()},
{"name": "amountlinked", "datatype": dbt.type_float()},
{"name": "amountpaid", "datatype": dbt.type_float()},
{"name": "amountunpaid", "datatype": dbt.type_float()},
{"name": "credit", "datatype": dbt.type_float()},
Expand Down
2 changes: 2 additions & 0 deletions models/netsuite2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ models:
description: Original transaction line amount, without sign adjustments. Reflects the raw amount entered in the source system.
- name: transaction_line_amount_raw
description: Original net amount of the transaction line, without sign adjustments. Matches the amount entered in the transaction currency.
- name: amount_linked
description: The amount of the transaction line that has been applied against another transaction (e.g. a payment applied to an invoice).
- name: accounting_book_id
description: The unique identifier of the accounting book.
- name: accounting_book_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ joined as (

transaction_accounting_lines.exchange_rate,
transaction_accounting_lines.amount,
transaction_accounting_lines.amount_linked,
transaction_accounting_lines.credit_amount,
transaction_accounting_lines.debit_amount,
transaction_accounting_lines.paid_amount,
Expand All @@ -46,7 +47,7 @@ joined as (
on transaction_lines.transaction_line_id = transaction_accounting_lines.transaction_line_id
and transaction_lines.transaction_id = transaction_accounting_lines.transaction_id
and transaction_lines.source_relation = transaction_accounting_lines.source_relation

{% if multibook_accounting_enabled %}
left join accounting_books
on accounting_books.accounting_book_id = transaction_accounting_lines.accounting_book_id
Expand All @@ -61,6 +62,7 @@ joined as (
accounting_books.accounting_book_name,
transaction_accounting_lines.exchange_rate,
transaction_accounting_lines.amount,
transaction_accounting_lines.amount_linked,
transaction_accounting_lines.credit_amount,
transaction_accounting_lines.debit_amount,
transaction_accounting_lines.paid_amount,
Expand Down
22 changes: 20 additions & 2 deletions models/netsuite2/netsuite2__transaction_details.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
{%- set using_exchange_rate = var('netsuite2__using_exchange_rate', true) -%}
{%- set using_vendor_categories = var('netsuite2__using_vendor_categories', true) -%}
{%- set accounts_pass_through_columns = var('accounts_pass_through_columns', []) -%}
{%- set customers_pass_through_columns = var('customers_pass_through_columns', []) -%}
{%- set items_pass_through_columns = var('items_pass_through_columns', []) -%}
{%- set departments_pass_through_columns = var('departments_pass_through_columns', []) -%}
{%- set locations_pass_through_columns = var('locations_pass_through_columns', []) -%}
{%- set subsidiaries_pass_through_columns = var('subsidiaries_pass_through_columns', []) -%}
Expand Down Expand Up @@ -228,12 +230,27 @@ transaction_details as (
when lower(transactions.transaction_type) in ('custinvc', 'custcred') then customers__transactions.customer_external_id
else customers__transaction_lines.customer_external_id
end as customer_external_id,

{% if customers_pass_through_columns != [] %}
{% for col in customers_pass_through_columns%}

case
when lower(transactions.transaction_type) in ('custinvc', 'custcred') then customers__transactions.{{ col.alias if col.alias else col.name }}
else customers__transaction_lines.{{ col.alias if col.alias else col.name }}
end as {{ col.alias if col.alias else col.name }},
{% endfor %}
{% endif %}

classes.class_id,
classes.full_name as class_full_name,
transaction_lines.item_id,
items.name as item_name,
items.type_name as item_type_name,
items.sales_description,
items.sales_description

-- The below script allows for items table pass through columns.
{{ netsuite.persist_pass_through_columns(items_pass_through_columns, identifier='items') }},

locations.location_id,
locations.name as location_name,
locations.city as location_city,
Expand Down Expand Up @@ -303,7 +320,8 @@ transaction_details as (

transactions_with_converted_amounts.converted_amount_using_transaction_accounting_period as converted_amount_raw,
transaction_lines.amount as transaction_amount_raw,
transaction_lines.netamount as transaction_line_amount_raw
transaction_lines.netamount as transaction_line_amount_raw,
transaction_lines.amount_linked
from transaction_lines

join transactions
Expand Down
Loading
Loading