Skip to content

Commit f4aa06a

Browse files
authored
Merge pull request #8 from swishbi/dev
Incorporate customer categories
2 parents fb38df4 + 2677a35 commit f4aa06a

8 files changed

+93
-1
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# dbt_netsuite_source v0.2.1
2+
3+
## 🎉 Feature Updates 🎉
4+
[PR #8](https://github.com/swishbi/dbt_netsuite_source/pull/8) includes the following feature updates:
5+
- Incorporates customer categories as a feature via the `netsuite__using_customer_categories` variable.
6+
7+
## Contributors
8+
- [phillem15](https://github.com/phillem15) ([#8](https://github.com/swishbi/dbt_netsuite_source/pull/8))
9+
10+
# dbt_netsuite_source v0.1.0
11+
Refer to the relevant release notes on the Github repository for specific details for the previous releases. Thank you!
12+
113
# dbt_netsuite_source v0.2.0
214

315
## 🚨 Breaking Changes 🚨:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ vars:
108108
netsuite__time_off_management_enabled: true # Enable `timeofftype`, `workcalendar`, and `workcalendarholiday` if you are using the Time Off Management feature
109109
netsuite__time_tracking_enabled: true # Enable `timebill` if you are using the Time Tracking feature
110110
netsuite__using_budgets: true # Enable `budget`, `budgetcategory`, and `budgetsmachine` if you use budgets
111+
netsuite__using_customer_categories: true # Enable `customercategory` if you categorize your customers
111112
netsuite__using_vendor_categories: true # Enable `vendorcategory` if you categorize your vendors
112113
netsuite__using_jobs: true # Enable `job`, `jobstatus`, and `jobtype` if you use jobs
113114
```

dbt_project.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ vars:
2727
netsuite_classes: "{{ source('netsuite', 'classification') }}"
2828
netsuite_consolidated_exchange_rates: "{{ source('netsuite', 'consolidated_exchange_rate') }}"
2929
netsuite_currencies: "{{ source('netsuite', 'currency') }}"
30+
netsuite_customer_categories: "{{ source('netsuite', 'customer_category') }}"
3031
netsuite_customers: "{{ source('netsuite', 'customer') }}"
3132
netsuite_departments: "{{ source('netsuite', 'department') }}"
3233
netsuite_employee_status_categories: "{{ source('netsuite', 'employee_status_categories') }}"

models/_netsuite__docs.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
{% docs consolidated_exchange_rates_table %} Table detailing average, historical and current exchange rates for all accounting periods. {% enddocs %}
1212

13+
{% docs customer_categories_table %} A table containing categories and how they map to customers. {% enddocs %}
14+
1315
{% docs customers_table %} Table detailing all customer information. {% enddocs %}
1416

1517
{% docs currencies_table %} Table detailing all currency information. {% enddocs %}
@@ -115,4 +117,6 @@
115117

116118
{% docs accounting_book_id %} Unique identifier of the accounting book. {% enddocs %}
117119

118-
{% docs account_type_id %} Unique identifier of thea account type. {% enddocs %}
120+
{% docs account_type_id %} Unique identifier of thea account type. {% enddocs %}
121+
122+
{% docs customer_category_id %} Unique identifier of the customer category. {% enddocs %}

models/_netsuite__sources.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,19 @@ sources:
244244
- name: symbol
245245
description: Currency symbol.
246246

247+
- name: customer_category
248+
identifier: "{{ var('netsuite_customer_category_identifier', 'customercategory') }}"
249+
description: "{{ doc('customer_categories_table') }}"
250+
config:
251+
enabled: "{{ var('netsuite__using_customer_categories', true) }}"
252+
columns:
253+
- name: id
254+
description: "{{ doc('customer_category_id') }}"
255+
- name: name
256+
description: Name of the customer category.
257+
- name: _fivetran_synced
258+
description: "{{ doc('_fivetran_synced') }}"
259+
247260
- name: customer
248261
identifier: "{{ var('netsuite_customer_identifier', 'customer') }}"
249262
description: "{{ doc('customers_table') }}"
@@ -620,55 +633,78 @@ sources:
620633

621634
- name: employees
622635
identifier: "{{ var('netsuite_employee_identifier', 'employee') }}"
636+
623637
- name: employee_statuses
624638
identifier: "{{ var('netsuite_employee_status_identifier', 'employeestatus') }}"
639+
625640
- name: employee_status_categories
626641
identifier: "{{ var('netsuite_employee_status_category_identifier', 'employeestatuscategory') }}"
642+
627643
- name: employee_types
628644
identifier: "{{ var('netsuite_employee_type_identifier', 'employeetype') }}"
645+
629646
- name: employee_type_categories
630647
identifier: "{{ var('netsuite_employee_type_category_identifier', 'employeetypecategory') }}"
648+
631649
- name: item_subtypes
632650
identifier: "{{ var('netsuite_item_subtype_identifier', 'itemsubtype') }}"
651+
633652
- name: item_types
634653
identifier: "{{ var('netsuite_item_type_identifier', 'itemtype') }}"
654+
635655
- name: job_resources
636656
identifier: "{{ var('netsuite_job_resources_identifier', 'jobresources') }}"
657+
637658
- name: job_statuses
638659
identifier: "{{ var('netsuite_job_status_identifier', 'jobstatus') }}"
660+
639661
- name: job_types
640662
identifier: "{{ var('netsuite_job_type_identifier', 'jobtype') }}"
663+
641664
- name: project_tasks
642665
identifier: "{{ var('netsuite_project_task_identifier', 'projecttask') }}"
666+
643667
- name: project_task_assignees
644668
identifier: "{{ var('netsuite_project_task_assignee_identifier', 'projecttaskassignee') }}"
669+
645670
- name: revenue_elements
646671
identifier: "{{ var('netsuite_revenue_element_identifier', 'revenueelement') }}"
647672
tags: ['arm']
673+
648674
- name: revenue_plans
649675
identifier: "{{ var('netsuite_revenue_plan_identifier', 'revenueplan') }}"
650676
tags: ['arm']
677+
651678
- name: revenue_plan_planned_costs
652679
identifier: "{{ var('netsuite_revenue_plan_planned_cost_identifier', 'revenueplanplannedcost') }}"
653680
tags: ['arm']
681+
654682
- name: revenue_plan_planned_revenue
655683
identifier: "{{ var('netsuite_revenue_plan_planned_revenue_identifier', 'revenueplanplannedrevenue') }}"
656684
tags: ['arm']
685+
657686
- name: revenue_plan_statuses
658687
identifier: "{{ var('netsuite_revenue_plan_status_identifier', 'revenueplanstatus') }}"
659688
tags: ['arm']
689+
660690
- name: revenue_plan_types
661691
identifier: "{{ var('netsuite_revenue_plan_type_identifier', 'revenueplantype') }}"
662692
tags: ['arm']
693+
663694
- name: time_entries
664695
identifier: "{{ var('netsuite_time_entry_identifier', 'timebill') }}"
696+
665697
- name: time_off_types
666698
identifier: "{{ var('netsuite_time_off_type_identifier', 'timeofftype') }}"
699+
667700
- name: transaction_sales_teams
668701
identifier: "{{ var('netsuite_transaction_sales_team_identifier', 'transactionsalesteam') }}"
702+
669703
- name: transaction_statuses
670704
identifier: "{{ var('netsuite_transaction_status_identifier', 'transactionstatus') }}"
705+
671706
- name: work_calendars
672707
identifier: "{{ var('netsuite_work_calendar_identifier', 'workcalendar') }}"
708+
673709
- name: work_calendar_holidays
674710
identifier: "{{ var('netsuite_work_calendar_holiday_identifier', 'workcalendarholiday') }}"

models/_stg_netsuite__models.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,19 @@ models:
224224
- name: symbol
225225
description: Currency symbol.
226226

227+
- name: stg_netsuite__customer_categories
228+
description: "{{ doc('customer_categories_table') }}"
229+
columns:
230+
- name: customer_category_id
231+
description: "{{ doc('customer_category_id') }}"
232+
tests:
233+
- unique
234+
- not_null
235+
- name: name
236+
description: Name of the customer category.
237+
- name: _fivetran_synced
238+
description: "{{ doc('_fivetran_synced') }}"
239+
227240
- name: stg_netsuite__customers
228241
description: "{{ doc('customers_table') }}"
229242
columns:

models/base/base_netsuite__customers.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ entity_address as (
77
employees as (
88
select * from {{ ref('base_netsuite__employees') }}
99
),
10+
{% if var('netsuite__using_customer_categories', false) %}
11+
customer_categories as (
12+
select * from {{ ref('stg_netsuite__customer_categories') }}
13+
),
14+
{% endif %}
1015
joined as (
1116

1217
select
@@ -19,6 +24,9 @@ joined as (
1924
sales_rep.employee_name_first_last as sales_rep_name_first_last,
2025
coalesce(parent_customer.company_name, customers.company_name) as parent_company_name,
2126
coalesce(parent_customer.customer_name, customers.customer_name) as parent_customer_name
27+
{% if var('netsuite__using_customer_categories', false) %}
28+
,customer_categories.customer_category_name
29+
{% endif %}
2230

2331
from customers
2432

@@ -30,5 +38,9 @@ joined as (
3038

3139
left join customers as parent_customer
3240
on parent_customer.customer_id = customers.parent_id
41+
{% if var('netsuite__using_customer_categories', false) %}
42+
left join customer_categories
43+
on customer_categories.customer_category_id = customers.customer_category_id
44+
{% endif %}
3345
)
3446
select * from joined
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{ config(enabled=(var('netsuite__using_customer_categories', false))) }}
2+
3+
with source as (
4+
select * from {{ var('netsuite_customer_categories') }}
5+
),
6+
renamed as (
7+
select
8+
id as customer_category_id,
9+
name as customer_category_name
10+
11+
from source
12+
)
13+
select * from renamed

0 commit comments

Comments
 (0)