A collection of scripts to transform Dear/Cin7 and Shopify data into NetSuite-compatible CSV import files.
- Overview
- Prerequisites
- Installation
- Dear / Cin7
- Shopify
- NetSuite
- Project Structure
- NetSuite Import Mappings
This project automates the transformation of inventory data from Dear/Cin7 and Shopify into NetSuite-compatible CSV import files. It handles three types of items:
- Inventory Items: Standard products from Dear/Cin7 filtered by Shopify SKUs
- Matrix Items: Product families with size variations (e.g., apparel)
- Assembly Items: Bundle products with components (Bills of Materials)
The scripts ensure proper filtering, mapping, and formatting required by NetSuite's CSV import feature.
- Node.js: v18.0.0 or higher
- npm: v9.0.0 or higher
- TypeScript: Installed via project dependencies
- Access to Dear/Cin7 and Shopify for CSV exports
- Clone the repository:
git clone https://github.com/SuavecitoInc/netsuite-import-tools.git
cd netsuite-import-tools- Install dependencies:
npm install- Create the
inputdirectory if it doesn't exist:
mkdir -p input outputBefore running any scripts, export the following CSV files and place them in the input/ directory:
-
Inventory List → Save as
input/Inventory_List.csv- Export all inventory items
- Include fields: ProductCode, Name, Barcode, Weight, Price, etc.
-
Assembly BOM List → Save as
input/Assembly_BOM_List.csv- Export all assembly bills of materials
- Include fields: ProductSKU, ComponentSKU, Quantity
-
Matrix Inventory List → Save as
input/Inventory_Matrix_List.csv- Export only apparel/sized items
- Include family and option fields
- Important: Remove these items from
Inventory_List.csv
-
Suppliers
- Export all suppliers, supplier contacts and supplier addresses from Dear/Cin7
- Save as
input/Suppliers.csv,input/SupplierContacts.csv, andinput/SupplierAddresses.csv
- Product Export → Save as
input/SHOPIFY-ITEMS.csv- Export all products from your Shopify store
- Include Fields Handle, Title, Body (HTML), Vendor, Product Category, Type, and Variant SKU. Remove anything else
input/
├── Assembly_BOM_List.csv
├── Inventory_List.csv
├── Inventory_Matrix_List.csv
├── Suppliers.csv
├── SupplierContacts.csv
├── SupplierAddresses.csv
└── SHOPIFY-ITEMS.csv
Generates standard inventory items for NetSuite, excluding assemblies and matrix items.
Run:
npm run dear:inventory-itemOutput: output/Dear_to_NetSuite_Inventory_Items.csv
Generates parent and child matrix items for product families (e.g., apparel with sizes).
Run:
npm run dear:inventory-item-matrixOutput: output/Dear_to_NetSuite_Inventory_Items_Matrix.csv
Note: This includes both parent items (1 per family) and child items (variants).
Generates assembly/bundle items with their component mappings.
Run:
npm run dear:assembly-itemOutput: output/Dear_to_NetSuite_Assembly_Items.csv
Generates inventory availability adjustments for NetSuite based on Dear inventory data.
Run:
npm run dear:inventory-availabilityOutput: output/Dear_to_NetSuite_Inventory_Adjustment.csv
Generates supplier and supplier contact records for NetSuite based on Dear supplier data.
Run:
npm run dear:vendorsOutput:
output/Dear_to_NetSuite_Vendors.csvoutput/Dear_to_NetSuite_Vendor_Addresses.csvoutput/Dear_Supplier_Contacts_to_NetSuite_Vendor_Contacts.csv
Before running any scripts, export the following CSV files and place them in the input/ directory:
- Product Export → Save as
input/NETSUITE-ITEMS-EXPORT.csv- Export all Products from NetSuite
- Include fields: Internal ID, Type, Item SKU.
- Product Export → Save as
input/SHOPIFY-ITEMS-EXPORT.csv- Export all products from your Shopify store
- Include all fields, this is just a standard Shopify product export
input/
├── NETSUITE-ITEMS-EXPORT.csv
└── SHOPIFY-ITEMS-EXPORT.csv
Generates standard inventory items for NetSuite, excluding assemblies and matrix items.
Run:
npm run shopify:inventory-item -- SHOPIFY-ITEMS-EXPORT.csvOutput: output/Shopify_to_NetSuite_Inventory_Items.csv
Generates parent and child matrix items for product families (e.g., apparel with sizes).
Run:
npm run shopify:inventory-item-matrix -- SHOPIFY-ITEMS-EXPORT.csvOutput: output/NetSuite_Inventory_Items_Matrix.csv
Note: This includes both parent items (1 per family) and child items (variants).
Generates a CSF of items, matching Shopify items to NetSuite items based on SKU, and mapping fields from Shopify to NetSuite. You must add the fields you want to map to the FIELD_MAPS.
Config:
const FIELD_MAPS = [
{
shopifyField: 'Body (HTML)', // Shopify field name from the export
netsuiteField: 'Description', // Desired NetSuite field name for the output CSV column
},
];Run:
npm run shopify:match-items -- SHOPIFY-ITEMS-EXPORT NETSUITE-ITEMS-EXPORTOutput: output/Shopify_to_NetSuite_Matched_Items.csv
-
Inventory Items (
NetSuite_Inventory_Items.csv)- Must be imported first as they are components for assemblies
-
Matrix Items (
NetSuite_Inventory_Items_Matrix.csv)- Import parent items, then child items
-
Assembly Items (
NetSuite_Assembly_Items.csv)- Import last, after all component items exist
Why? Assembly items reference inventory items as components. If components don't exist in NetSuite, the import will fail.
To enable detailed logging, edit the script file and set:
const DEBUG = true;This will output:
- All SKUs being processed
- Item-by-item details
- Component mappings for assemblies
- Family groupings for matrix items
Field mappings are configured in:
src/lib/configs/dear.ts- Dear/Cin7 to NetSuite field mappingssrc/lib/configs/shopify.ts- Shopify to NetSuite field mappings
Issue: Script runs but no CSV is created.
Solution:
- Check that input CSV files exist in
input/directory - Verify CSV files have correct column headers
- Check terminal for error messages
Issue: CSV uploads but NetSuite shows import errors.
Solution:
- Verify you followed the import order
- Check that all referenced items exist (components, subsidiaries, classes)
- Review NetSuite's error log for specific field issues
- Verify saved import mappings match your file structure (see SAVED_IMPORTS.md)
Issue: "Duplicate external ID" error in NetSuite.
Solution:
- Check if items already exist in NetSuite
- Use Update mode instead of Add mode in NetSuite import
- Review your source data for duplicate SKUs
Issue: Expected more items in output CSV.
Solution:
- Items may be filtered out if not in Shopify export
- Check that
SHOPIFY-ITEMS.csvcontains all expected SKUs - Enable DEBUG mode to see which items are being filtered
netsuite-import-tools/
├── input/ # Place CSV exports here
│ ├── Assembly_BOM_List.csv
│ ├── Inventory_List.csv
│ ├── Inventory_Matrix_List.csv
│ ├── Inventory_Availability.csv
│ ├── Suppliers.csv
│ ├── SupplierContacts.csv
│ ├── SupplierAddresses.csv
│ ├── NETSUITE-ITEMS-EXPORT.csv
│ ├── SHOPIFY-ITEMS-EXPORT.csv
│ └── SHOPIFY-ITEMS.csv
├── output/ # Generated NetSuite CSVs
│ ├── NetSuite_Assembly_Items.csv
│ ├── NetSuite_Inventory_Items.csv
│ └── NetSuite_Inventory_Items_Matrix.csv
│ ├── Dear_to_NetSuite_Vendors.csv
│ ├── Dear_Supplier_Contacts_to_NetSuite_Vendor_Contacts.csv
│ └── Dear_Supplier_Addresses_to_NetSuite_Vendor_Addresses.csv
├── src/
│ ├── dear/
│ │ ├── assembly-item.ts # Assembly items script
│ │ ├── inventory-item.ts # Standard inventory script
│ │ └── inventory-item-matrix.ts # Matrix items script
│ │ └── vendors.ts # Supplier script
│ ├── shopify/
│ │ ├── helpers.ts # Helper functions for Shopify integration
│ │ ├── inventory-item.ts # Standard inventory script
│ │ └── inventory-item-matrix.ts # Matrix items script
│ └── lib/
│ ├── configs/
│ │ └── dear.ts # Field mappings
│ │ └── shopify.ts # Field mappings
│ ├── types/ # TypeScript types
│ └── utils.ts # Shared utilities
├── package.json
├── tsconfig.json
├── README.md
└── SAVED_IMPORTS.md # NetSuite import mappings
Saved CSV Import mappings for NetSuite can be found in SAVED_IMPORTS.md.
These mappings define how CSV columns map to NetSuite fields during import.
- Only apparel with size variations are handled as NetSuite Matrix Items
- All other product families are imported as standard Inventory Items
- Matrix items must be separated into their own CSV (
Inventory_Matrix_List.csv) - Remove matrix items from
Inventory_List.csvbefore running the standard inventory import
Assembly component SKUs are automatically included in the inventory items output, even if they're not in Shopify. This ensures all components exist before assemblies are imported.