Skip to content

Commit

Permalink
Prepare for release (#30)
Browse files Browse the repository at this point in the history
* Implemented: schedule suitescript that will export fulfilled transfer order CSV file and put on NetSuite file cabinate. Also made saved search for it. (1-add-support-to-push-transfer-order-from-netsuite-to-oms)

* Implemented: schedule suitescript that will upload fulfilled transfer order csv file from netsuite filecabinate to FTP server. (1-add-support-to-push-transfer-order-from-netsuite-to-oms)

* Implemented: schedule suitescript that will export open purcahse order csv files and upload it on FTP server. Also made saved search to get open PO information. (3-push-purchase-orders-from-netsuite-to-oms)

* Added: support to sync inventory from NS to OMS. (5-sync-inventory-from-netsuite-to-oms)

* Added: support to import cycle count variance from OMS to NS. (7-import-cycle-count-variance-from-oms-to-netsuite)

* Removed: sftp host key and credentials from suitescript. (1-add-support-to-push-transfer-order-from-netsuite-to-oms)

* Removed: sftp host key and credentials from suitescript. 3-push-purchase-orders-from-netsuite-to-oms

* Removed: sftp host key and credentials from suitescript. 5-sync-inventory-from-netsuite-to-oms

* Removed: SFTP hosy key and credential from suitescript. (7-import-cycle-count-variance-from-oms-to-netsuite)

* Added: code to skip CSV file creation if fulfilled transfer order saved search don't return result. (1-add-support-to-push-transfer-order-from-netsuite-to-oms)

* Only: formating changes. (1-add-support-to-push-transfer-order-from-netsuite-to-oms)

* Updated: fulfilled transfer order saved search defination and added 'IN_TRANSFER' shipment type in CSV column. (1-add-support-to-push-transfer-order-from-netsuite-to-oms)

* Added: code to skip CSV file creation if purcahse order saved search doesn't retrun result. (3-push-purchase-orders-from-netsuite-to-oms)

* Updated: purchase order saved search defination and changed the date format as per the HC. (3-push-purchase-orders-from-netsuite-to-oms)

* Modified: suitescript files and added code to skip CSV file creating if saved search doesn't return result. (5-sync-inventory-from-netsuite-to-oms)

* Added: error module which was missed in my last commit. (3-push-purchase-orders-from-netsuite-to-oms)

* Updated: suitescript file. (7-import-cycle-count-variance-from-oms-to-netsuite)

* Implemented: suitescript to create item receipt records for purchase orders. (9-push-purchase-order-receipt-from-oms-to-netsuite) (#13)

* Modified: suitescript files and handle the exceptions. (9-push-purchase-order-receipt-from-oms-to-netsuite)

* Implemented: suitescript to create item receipt records for purchase order. (9-push-purchase-order-receipt-from-oms-to-netsuite)

* Made: custom object to create schedule script and deployment record for the suitescript and added it in deploy.xml file. (9-push-purchase-order-receipt-from-oms-to-netsuite)

* Made: required entry in deploy.xml file. (9-push-purchase-order-receipt-from-oms-to-netsuite)

* Implemented: schedule suitescript to create item receipt records for transfer order from OMS to NetSuite. (10-push-transferorder-receipt-from-oms-to-netsuite) (#15)

* Implemented: Schedule suitescript files to export customer from NetSuite and upload the CSV file on SFTP server. Also made saved search xml data to export customer records. (18-export-customer-from-netsuite) (#19)

* Implemented: schedule scuitescript to import customer records in NetSuite. Made saved csv import xml data for customer. (12-push-customer-from-oms-to-netsuite) (#16)

* Implemented: schedule scuitescript to import customer records in NetSuite. Made saved csv import xml data for customer. (12-push-customer-from-oms-to-netsuite)

* Updated: saved search defination for open purchase order and fulfilled transfer orders. (12-push-customer-from-oms-to-netsuite)

* Updated: deploy.xml file. (12-push-customer-from-oms-to-netsuite)

* Updated: suitescript file and changed the dir name. (12-push-customer-from-oms-to-netsuite)

* Added: support to add/update sales orders from OMS to NS. (17-push-sales-orders-from-oms-to-netsuite) (#20)

* Updated: suitescript files and changed limit of number of retrieve files from NS filecabinet. (17-push-sales-orders-from-oms-to-netsuite)

* Added: support to add/update sales orders from OMS to NS. Made custom form and trasaction fields. Made saved csv import data for sales order field mapping. (17-push-sales-orders-from-oms-to-netsuite)

* Adeed: support to create invoice for sales orders. (23-create-invoice-records-in-netsuite) (#26)

* Added: support to create customer deposit records for sales order in NetSuite. (22-create-customer-deposit-records-in-netsuite) (#25)

* Added: support to create customer deposit records for sales order in NetSuite. (22-create-customer-deposit-records-in-netsuite)

* Updated: suitescript to calculate cancelled amount while making customer deposit amount for sales order. Also updated saved search condition. (22-create-customer-deposit-records-in-netsuite)

* Updated: variable names. (22-create-customer-deposit-records-in-netsuite)

* Updated: custom deposit saved search defination. (22-create-customer-deposit-records-in-netsuite)

* Added: invoice related files in deploy.xml file. (22-create-customer-deposit-records-in-netsuite)

* Added: support to export sales order and sales order items from NetSuite to OMS. (21-export-sales-order-from-netsuite-to-oms) (#29)

* Added: support to export Sales Order from NetSuite to OMS. (21-export-sales-order-from-netsuite-to-oms)

* Added: support to export sales order items from netsuite and upload the CSV file on SFTP server. Also made saved search to export sales order items (21-export-sales-order-from-netsuite-to-oms)

* Updated: inventory cycle count column name. (21-export-sales-order-from-netsuite-to-oms)

---------

Co-authored-by: Rehan Khan <[email protected]>
Co-authored-by: rehan3586 <[email protected]>
  • Loading branch information
3 people authored Aug 2, 2023
1 parent ca7f27c commit a0bad2e
Show file tree
Hide file tree
Showing 59 changed files with 3,768 additions and 0 deletions.
3 changes: 3 additions & 0 deletions project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"defaultAuthId": ""
}
73 changes: 73 additions & 0 deletions src/FileCabinet/SuiteScripts/HC_generateCSV_Customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/task', 'N/search', 'N/record', 'N/error'], function (task, search, record, error) {
function execute(context) {
try {
var date = new Date();
var searchId = 'customsearch_hc_export_customer'; // Saved Search Id which will export customer records

var savedSearch = search.load({ id: searchId });

// Run the search
var searchResult = savedSearch.run().getRange({ start: 0, end: 1 });

// If the search returned no results, do not create the CSV file
if (searchResult.length === 0) {
log.debug('No results found. Skipping CSV file creation.');
return;
}

var searchTask = task.create({
taskType: task.TaskType.SEARCH
});

searchTask.savedSearchId = searchId;

// Check Customer CSV Folder is created or not
var folderInternalId = search
.create({
type: search.Type.FOLDER,
filters: [['name', 'is', 'Customer CSV']],
columns: ['internalid']
})
.run()
.getRange({ start: 0, end: 1 })
.map(function (result) {
return result.getValue('internalid');
})[0];

// Made Customer CSV folder in NetSuite File Cabinet
if (folderInternalId == null) {
var folder = record.create({ type: record.Type.FOLDER});
folder.setValue({ fieldId: 'name',
value: 'Customer CSV' });
var folderId = folder.save();
}

var fileName = date + '-CustomerExport.csv';
var path = 'Customer CSV/' + fileName;
searchTask.filePath = path;

var searchTaskId = searchTask.submit();

var taskStatus = task.checkStatus(searchTaskId);

log.debug("Search task is submitted ! " + taskStatus.status);
log.debug("Customer CSV file Successfully Uploaded in NetSuite with file name ! " + fileName);
} catch (e) {
log.error({
title: 'Error in generating customer csv files',
details: e,
});
throw error.create({
name:"Error in generating customer csv files",
message: e
});
}
}
return {
execute: execute
};
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/task', 'N/search', 'N/record', 'N/error'], function (task, search, record, error) {
function execute(context) {
try {
var date = new Date();
var searchId = 'customsearch_fulfilled_transferorder'; // Saved Search Id which will export fulfilled transfer order

var savedSearch = search.load({ id: searchId });

// Run the search
var searchResult = savedSearch.run().getRange({ start: 0, end: 1 });

// If the search returned no results, do not create the CSV file
if (searchResult.length === 0) {
log.debug('No results found. Skipping CSV file creation.');
return;
}

var searchTask = task.create({
taskType: task.TaskType.SEARCH
});

searchTask.savedSearchId = searchId;

// Check Fulfilled Transfer Order CSV Folder is created or not
var folderInternalId = search
.create({
type: search.Type.FOLDER,
filters: [['name', 'is', 'Fulfilled Transfer Order CSV']],
columns: ['internalid']
})
.run()
.getRange({ start: 0, end: 1 })
.map(function (result) {
return result.getValue('internalid');
})[0];

// Made Fulfilled Transfer Order CSV folder in NetSuite File Cabinet
if (folderInternalId == null) {
var folder = record.create({ type: record.Type.FOLDER});
folder.setValue({ fieldId: 'name',
value: 'Fulfilled Transfer Order CSV' });
var folderId = folder.save();
}

var fileName = date + '-TransferOrderExport.csv';
var path = 'Fulfilled Transfer Order CSV/' + fileName;
searchTask.filePath = path;

var searchTaskId = searchTask.submit();

var taskStatus = task.checkStatus(searchTaskId);

log.debug("Search task is submitted ! " + taskStatus.status);
log.debug("Transfer Order Fulfillment CSV file Successfully Uploaded in NetSuite with file name ! " + fileName);
} catch (e) {
log.error({
title: 'Error in generating fulfilled transfer order csv files',
details: e,
});
throw error.create({
name:"Error in generating fulfilled transfer order csv files",
message: e
});
}
}
return {
execute: execute
};
});
73 changes: 73 additions & 0 deletions src/FileCabinet/SuiteScripts/HC_generateCSV_InventoryItems.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/task', 'N/search', 'N/record', 'N/error'], function (task, search, record, error) {
function execute(context) {
try {
var date = new Date();
var searchId = 'customsearch_export_inventory_item'; // Saved Search Id which will export Inventory Items

var savedSearch = search.load({ id: searchId });

// Run the search
var searchResult = savedSearch.run().getRange({ start: 0, end: 1 });

// If the search returned no results, do not create the CSV file
if (searchResult.length === 0) {
log.debug('No results found. Skipping CSV file creation.');
return;
}

var searchTask = task.create({
taskType: task.TaskType.SEARCH
});

searchTask.savedSearchId = searchId;

// Check Inventory Item CSV Folder is created or not
var folderInternalId = search
.create({
type: search.Type.FOLDER,
filters: [['name', 'is', 'Inventory Item CSV']],
columns: ['internalid']
})
.run()
.getRange({ start: 0, end: 1 })
.map(function (result) {
return result.getValue('internalid');
})[0];

// Made Inventory Item CSV folder in NetSuite File Cabinet
if (folderInternalId == null) {
var folder = record.create({ type: record.Type.FOLDER});
folder.setValue({ fieldId: 'name',
value: 'Inventory Item CSV' });
var folderId = folder.save();
}

var fileName = date + '-InventoryItemExport.csv';
var path = 'Inventory Item CSV/' + fileName;
searchTask.filePath = path;

var searchTaskId = searchTask.submit();

var taskStatus = task.checkStatus(searchTaskId);

log.debug("Search task is submitted ! " + taskStatus.status);
log.debug("Inventory Item CSV file Successfully Uploaded in NetSuite with file name ! " + fileName);
} catch (e) {
log.error({
title: 'Error in generating inventory item csv files',
details: e,
});
throw error.create({
name:"Error in generating inventory item csv files",
message: e
});
}
}
return {
execute: execute
};
});
73 changes: 73 additions & 0 deletions src/FileCabinet/SuiteScripts/HC_generateCSV_OpenPurchaseOrders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/task', 'N/search', 'N/record', 'N/error'], function (task, search, record, error) {
function execute(context) {
try {
var date = new Date();
var searchId = 'customsearch_open_purchaserorder'; // Saved Search Id which will export open purchase order

var savedSearch = search.load({ id: searchId });

// Run the search
var searchResult = savedSearch.run().getRange({ start: 0, end: 1 });

// If the search returned no results, do not create the CSV file
if (searchResult.length === 0) {
log.debug('No results found. Skipping CSV file creation.');
return;
}

var searchTask = task.create({
taskType: task.TaskType.SEARCH
});

searchTask.savedSearchId = searchId;

// Check Open Purchase Order CSV Folder is created or not
var folderInternalId = search
.create({
type: search.Type.FOLDER,
filters: [['name', 'is', 'Open Purchase Order CSV']],
columns: ['internalid']
})
.run()
.getRange({ start: 0, end: 1 })
.map(function (result) {
return result.getValue('internalid');
})[0];

// Made Open Purchase Order CSV folder in NetSuite File Cabinet
if (folderInternalId == null) {
var folder = record.create({ type: record.Type.FOLDER});
folder.setValue({ fieldId: 'name',
value: 'Open Purchase Order CSV' });
var folderId = folder.save();
}

var fileName = date + '-OpenPurchaseExport.csv';
var path = 'Open Purchase Order CSV/' + fileName;
searchTask.filePath = path;

var searchTaskId = searchTask.submit();

var taskStatus = task.checkStatus(searchTaskId);

log.debug("Search task is submitted ! " + taskStatus.status);
log.debug("Open Purchase Order Fulfillment CSV file Successfully Uploaded in NetSuite with file name ! " + fileName);
} catch (e) {
log.error({
title: 'Error in generating open purchase order csv files',
details: e,
});
throw error.create({
name:"Error in generating open purchase order csv files",
message: e
});
}
}
return {
execute: execute
};
});
81 changes: 81 additions & 0 deletions src/FileCabinet/SuiteScripts/HC_importCustomer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* @NApiVersion 2.1
* @NScriptType ScheduledScript
*/
define(['N/sftp', 'N/task', 'N/error'], function (sftp, task, error) {
function execute(context) {
try {
// Establish a connection to a remote FTP server
/* The host key can be obtained using OpenSSH's ssh-keyscan tool:
ssh-keyscan -t <hostKeyType> -p <port> <hostDomain>
Example: ssh-keyscan -t ECDSA -p 235 hc-uat.hotwax.io
*/

var hostKey = '';

var connection = sftp.createConnection({
username: '',
keyId: '',
url: '',
port: 235,
directory: '/home/{SFTP-USER}/{FOLDER}',
hostKey: hostKey
});

log.debug("Connection established successfully with SFTP server!");

var list = connection.list({
path: '/export/'
});

for (var i=0; i<list.length; i++) {
if (!list[i].directory) {
try {
var fileName = list[i].name;

// Download the file from the remote server
var downloadedFile = connection.download({
directory: '/export',
filename: fileName
});
log.debug("File downloaded successfully !"+fileName);

// Create CSV import task
var scriptTask = task.create({taskType: task.TaskType.CSV_IMPORT});
scriptTask.mappingId = 'custimport_customer_hc';
scriptTask.importFile = downloadedFile;
var csvImportTaskId = scriptTask.submit();

var taskStatus = task.checkStatus(csvImportTaskId);
if (taskStatus.status === 'FAILED') {
log.debug("Import Customer CSV task has been failed");
} else {
connection.move({
from: '/export/'+fileName,
to: '/export/archive/'+fileName
})
log.debug('File moved!');
}
} catch (e) {
log.error({
title: 'Error in processing customer csv files',
details: e,
});
}
}
}
} catch (e) {
log.error({
title: 'Error in importing customer csv files',
details: e,
});
throw error.create({
name:"Error in importing customer csv files",
message: e
});
}
}
return {
execute: execute
};
});
Loading

0 comments on commit a0bad2e

Please sign in to comment.