From e962ed7b0a7866094635e53eff99795f7424c624 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Wed, 20 Apr 2022 09:22:21 -0500 Subject: [PATCH 01/33] orders APIs --- .../lib/customscript_ext_api_lib.js | 82 ++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js index 7b7b9e2..a37b271 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js @@ -133,7 +133,7 @@ return response; } } catch (e) { - log.debug('Error Fetcing Plans', JSON.stringify(e.message)); + log.debug('Error Calling API', JSON.stringify(e.message)); return; } }; @@ -211,7 +211,7 @@ return response; } } catch (e) { - log.debug('Error Cancelling Contract', JSON.stringify(e.message)); + log.debug('Error Calling API', JSON.stringify(e.message)); return; } }; @@ -265,6 +265,84 @@ return; } }; + /*****************************************ORDERS*****************************************/ + + /** + * CREATE ORDER + * API Documentation: https://docs.extend.com/reference/orderscreate + */ + exports.createOrder = function (objOrderDetails) { + var config = extendConfig.getConfig(); + + try { + var response = https.post({ + url: config.domain + '/orders', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + 'X-Extend-Access-Token': config.key, + 'Accept': 'application/json;version=' + config.version + }, + body: JSON.stringify(objOrderDetails), + }); + if (response) { + return response; + } + } catch (e) { + log.debug('Error Calling API', JSON.stringify(e.message)); + return; + } + }; + /** + * UPDATE ORDER LINE FULFILLMENT + * API Documentation: https://docs.extend.com/reference/lineitemsfulfill + */ + exports.fulfillOrderLine = function (objOrderDetails, stLineItemId) { + var config = extendConfig.getConfig(); + try { + var response = https.post({ + url: config.domain + '/line-items/' + stLineItemId + '/fulfill', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + 'X-Extend-Access-Token': config.key, + 'Accept': 'application/json;version=' + config.version + }, + body: JSON.stringify(objOrderDetails), + }); + if (response) { + return response; + } + } catch (e) { + log.debug('Error Calling API', JSON.stringify(e.message)); + return; + } + }; + + /** + * REFUND CONTRACT + * API Documentation: https://docs.extend.com/reference/refundscreate + */ + exports.refundContract = function (objRefundDetails) { + var config = extendConfig.getConfig(); + try { + var response = https.post({ + url: config.domain + '/refunds', + headers: { + 'Content-Type': 'application/json', + 'X-Extend-Access-Token': config.key, + 'Accept': 'application/json;version=' + config.version + }, + body: JSON.stringify(objRefundDetails), + }); + if (response) { + return response; + } + } catch (e) { + log.debug('Error Calling API', JSON.stringify(e.message)); + return; + } + }; return exports; }); From d1bf111579582b1b0b6d53f0f4a60ddef65b1f86 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Mon, 23 May 2022 12:25:34 -0500 Subject: [PATCH 02/33] initial orders updates --- .../src/Archive.zip | Bin 0 -> 44751 bytes .../lib/customscript_ext_api_lib.js | 134 +++++++----------- .../lib/customscript_ext_config_lib.js | 13 +- .../lib/customscript_ext_util.js | 131 +++++++++++------ .../customscript_ext_create_order_mr.js | 101 +++++++++++++ 5 files changed, 246 insertions(+), 133 deletions(-) create mode 100644 com.extend.extendproductprotection/src/Archive.zip create mode 100644 com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js diff --git a/com.extend.extendproductprotection/src/Archive.zip b/com.extend.extendproductprotection/src/Archive.zip new file mode 100644 index 0000000000000000000000000000000000000000..14bb4ffdf597f1707efbd06fa4e73e435d12091c GIT binary patch literal 44751 zcmc$_19Ya_vM&6^>?9rA9otFA>e#kz+qOEkJGPyU)v;~cx}B}H&N^rR_l~je9e=)2 zqw;=uYu21qPgTuXuZ%b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cmV?d00001 diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js index a37b271..4bbaa28 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js @@ -25,7 +25,6 @@ var response = https.post({ url: config.domain + '/stores/' + config.storeId + '/products?upsert=' + bIsUpsert + '?batch=' + bIsBatch, headers: { - Accept: 'application/json', 'Content-Type': 'application/json', 'X-Extend-Access-Token': config.key, 'Accept': 'application/json;version=' + config.version @@ -51,7 +50,6 @@ var response = https.put({ url: config.domain + '/stores/' + config.storeId + '/products/' + stItemId, headers: { - Accept: 'application/json', 'Content-Type': 'application/json', 'X-Extend-Access-Token': config.key, 'Accept': 'application/json;version=' + config.version @@ -118,7 +116,7 @@ * GET OFFERS * API Documentation: https://developers.extend.com/default#operation/getOffer */ - exports.getPlansByItem = function (stItemId) { + exports.getOffers= function (stItemId) { var config = extendConfig.getConfig(); try { var response = https.get({ @@ -137,84 +135,7 @@ return; } }; - /*****************************************CONTRACTS*****************************************/ - - /** - * CREATE CONTRACT - * API Documentation: https://developers.extend.com/default#operation/createContracts - */ - exports.createWarrantyContract = function (objContractDetails) { - var config = extendConfig.getConfig(); - - - try { - var response = https.post({ - url: config.domain + '/stores/' + config.storeId + '/contracts', - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - 'X-Extend-Access-Token': config.key, - 'Accept': 'application/json;version=' + config.version - }, - body: JSON.stringify(objContractDetails), - }); - if (response) { - return response; - } - } catch (e) { - log.debug('Error Calling API', JSON.stringify(e.message)); - return; - } - }; - /** - * UPDATE CONTRACT - * API Documentation: https://developers.helloextend.com/2020-08-01#operation/updateContracts - */ - exports.updateWarrantyContract = function (objContractDetails, stContractId) { - var config = extendConfig.getConfig(); - try { - var response = https.put({ - url: config.domain + '/contracts/' + stContractId, - headers: { - Accept: 'application/json', - 'Content-Type': 'application/json', - 'X-Extend-Access-Token': config.key, - 'Accept': 'application/json;version=' + config.version - }, - body: JSON.stringify(objContractDetails), - }); - if (response) { - return response; - } - } catch (e) { - log.debug('Error Calling API', JSON.stringify(e.message)); - return; - } - }; - - /** - * CANCEL CONTRACT - * API Documentation: https://developers.extend.com/default#operation/refundContract - */ - exports.cancelWarrantyContract = function (stContractId, bIsCommit) { - var config = extendConfig.getConfig(); - try { - var response = https.post({ - url: config.domain + '/stores/' + config.storeId + '/contracts/' + stContractId + '/refund?commit=' + bIsCommit, - headers: { - 'Content-Type': 'application/json', - 'X-Extend-Access-Token': config.key, - 'Accept': 'application/json;version=' + config.version - }, - }); - if (response) { - return response; - } - } catch (e) { - log.debug('Error Calling API', JSON.stringify(e.message)); - return; - } - }; + /*****************************************LEADS*****************************************/ /** * CREATE LEAD @@ -226,7 +147,6 @@ var response = https.post({ url: config.domain + '/stores/' + config.storeId + '/leads', headers: { - Accept: 'application/json', 'Content-Type': 'application/json', 'X-Extend-Access-Token': config.key, 'Accept': 'application/json;version=' + config.version @@ -278,7 +198,6 @@ var response = https.post({ url: config.domain + '/orders', headers: { - Accept: 'application/json', 'Content-Type': 'application/json', 'X-Extend-Access-Token': config.key, 'Accept': 'application/json;version=' + config.version @@ -303,7 +222,6 @@ var response = https.post({ url: config.domain + '/line-items/' + stLineItemId + '/fulfill', headers: { - Accept: 'application/json', 'Content-Type': 'application/json', 'X-Extend-Access-Token': config.key, 'Accept': 'application/json;version=' + config.version @@ -343,6 +261,54 @@ return; } }; + /** + * GET REFUND QUOTE + * API Documentation: https://docs.extend.com/reference/refundsget + */ + exports.getRefundQuote = function (objRefundDetails) { + var config = extendConfig.getConfig(); + try { + var response = https.get({ + url: config.domain + '/refunds', + headers: { + 'Content-Type': 'application/json', + 'X-Extend-Access-Token': config.key, + 'Accept': 'application/json;version=' + config.version + }, + body: JSON.stringify(objRefundDetails), + }); + if (response) { + return response; + } + } catch (e) { + log.debug('Error Calling API', JSON.stringify(e.message)); + return; + } + }; +/** + * REQUEST REFUND + * API Documentation: https://docs.extend.com/reference/refundscreate + */ + exports.requestRefund = function (objRefundDetails) { + var config = extendConfig.getConfig(); + try { + var response = https.post({ + url: config.domain + '/refunds', + headers: { + 'Content-Type': 'application/json', + 'X-Extend-Access-Token': config.key, + 'Accept': 'application/json;version=' + config.version + }, + body: JSON.stringify(objRefundDetails), + }); + if (response) { + return response; + } + } catch (e) { + log.debug('Error Calling API', JSON.stringify(e.message)); + return; + } +}; return exports; }); diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js index 0bf1bc3..b942d1a 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js @@ -16,12 +16,12 @@ //Get storeId & APIkey from config custom record var SB_STORE_ID; var SB_API_KEY; - var SB_API_VERSION; + var SB_API_VERSION = 'latest'; var SB_EMAIL; var SB_REF_ID; var STORE_ID; var API_KEY; - var API_VERSION; + var API_VERSION = 'latest'; var REF_ID; var customrecord_ext_configurationSearchObj = search.create({ @@ -43,15 +43,20 @@ if(stEnvironment == objExtendEnvironment.SANDBOX){ SB_STORE_ID = result.getValue({ name: 'custrecord_ext_store_id' }); SB_API_KEY = result.getValue({ name: 'custrecord_ext_api_key' }); - SB_API_VERSION = result.getValue({ name: 'custrecord_ext_api_version' }); SB_EMAIL = result.getValue({ name: 'custrecord_ext_demo_email' }); SB_REF_ID = result.getValue({ name: 'custrecord_ext_ref_id' }); + if(result.getValue({ name: 'custrecord_ext_api_version' })){ + SB_API_VERSION = result.getValue({ name: 'custrecord_ext_api_version' }); + + } }else{ STORE_ID = result.getValue({ name: 'custrecord_ext_store_id' }); API_KEY = result.getValue({ name: 'custrecord_ext_api_key' }); - API_VERSION = result.getValue({ name: 'custrecord_ext_api_version' }); REF_ID = result.getValue({ name: 'custrecord_ext_ref_id' }); + if(result.getValue({ name: 'custrecord_ext_api_version' })){ + API_VERSION = result.getValue({ name: 'custrecord_ext_api_version' }); + } } diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index b4c1ea2..7f5ca50 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -14,18 +14,70 @@ function (search, record, error, EXTEND_API, EXTEND_CONFIG) { var exports = {}; /** - * Contract Functions + * Order Functions */ - //create extend contracts - exports.createExtendContracts = function (objExtendData, objSalesOrderRecord) { - log.debug('EXTEND UTIL _createExtendContracts:', '**ENTER**'); - log.debug('EXTEND UTIL _createExtendContracts: SO ID', objSalesOrderRecord.id); + //create extend order + exports.createExtendOrder = function (objSalesOrderRecord) { + log.debug('EXTEND UTIL _createExtendOrder:', '**ENTER**'); + log.debug('EXTEND UTIL _createExtendOrder: SO ID', objSalesOrderRecord.id); + + //////////////////////////SUPPORT FUNCTIONS/////////////////////////// + var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); + + log.debug('EXTEND UTIL _createExtendOrder: Line Count', stLineCount); + + if (stLineCount > 0) { + log.debug('EXTEND UTIL _createExtendOrder: Get Extend Data', '**START**'); + } + log.debug('_getExtendData: Get Extend Data', '**ENTER**'); + var objExtendItemData = {}; + + var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + for (var i = 0; i < stLineCount; i++) { + var stItemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); + //Check if item is one of the configured extend items + if (stExtendItemId === stItemId) { + log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); + //get qty of contracts created & compare to extend item qty + var stContractQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_qty', line: i }); + var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); + + if (stContractQty < stExtendItemQty) { + + //get related item from extend line + var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + //check for new fulfillments + for (var j = 0; j < stLineCount; j++) { + var stRelatedItem = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); + if (stRelatedItem === stExtendItemRefId) { + + var stRelatedItemQtyFulfilled = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantityfulfilled', line: j }); + if (stRelatedItemQtyFulfilled <= stExtendItemQty && stRelatedItemQtyFulfilled > stContractQty) { + + var stUniqueKey = i; + // Start building the Extend Order Info Object + objExtendItemData[stUniqueKey] = {}; + objExtendItemData[stUniqueKey].quantity = Math.min(stRelatedItemQtyFulfilled, (stExtendItemQty - stContractQty)); + objExtendItemData[stUniqueKey].item = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + objExtendItemData[stUniqueKey].line = i; + objExtendItemData[stUniqueKey].purchase_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: j }); + objExtendItemData[stUniqueKey].extend_plan_id = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); + objExtendItemData[stUniqueKey].itemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; + objExtendItemData[stUniqueKey].plan_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); + + } + } + } + + } + } + } for (key in objExtendData) { var objExtendContractRequestJSON = {}; var stQuantity = objExtendData[key].quantity; - log.debug('EXTEND UTIL _createExtendContracts: Quantity of Line', stQuantity); + log.debug('EXTEND UTIL _createExtendOrder: Quantity of Line', stQuantity); var arrContractIds = []; var stExtendContractQty = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_qty', line: objExtendData[key].line }); var stExtendContractId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: objExtendData[key].line });; @@ -168,8 +220,8 @@ }; // Build the Extend API JSON for contract creation - exports.buildExtendContractJSON = function (objValues) { - log.debug('EXTEND UTIL _buildExtendContractJSON:', '**ENTER**'); + exports.buildExtendOrderJSON = function (objValues) { + log.debug('EXTEND UTIL _buildExtendOrderJSON:', '**ENTER**'); // Date is a string and we need to format for extend const stTranDate = new Date(objValues.tran_date); @@ -177,22 +229,13 @@ //get product refId objValues.refId = exports.getItemRefId(objValues.itemId); //If Demo use demo email for contracts - log.debug('demo email', EXTEND_CONFIG.getConfig()); - if(EXTEND_CONFIG.getConfig().email){ - objValues.email = EXTEND_CONFIG.getConfig().email; + var config = EXTEND_CONFIG.getConfig(); + if(config.email){ + objValues.email = config.email; } - var objJSON = { - 'transactionId': objValues.id, - 'transactionDate': objValues.tran_date, -// 'transactionTotal': objValues.total_amount * 100, - - 'transactionTotal': { - 'currencyCode': objValues.currency, - 'amount': parseInt(objValues.total_amount * 100) - }, + var objJSON = { 'currency': objValues.currency, - 'poNumber': objValues.order_number, 'customer': { 'email': objValues.email, 'name': objValues.name, @@ -201,41 +244,39 @@ 'address1': objValues.bill_address1, 'address2': objValues.bill_address2, 'city': objValues.bill_city, - 'provinceCode': objValues.bill_state, + 'postalCode': objValues.bill_zip, 'countryCode': objValues.bill_country, - 'postalCode': objValues.bill_zip + 'province': objValues.bill_state, }, 'shippingAddress': { 'address1': objValues.ship_address1, 'address2': objValues.ship_address2, 'city': objValues.ship_city, - 'provinceCode': objValues.ship_state, + 'postalCode': objValues.ship_zip, 'countryCode': objValues.ship_country, - 'postalCode': objValues.ship_zip - } - }, - 'product': { - 'referenceId': objValues.refId, - // 'purchasePrice': objValues.purchase_price * 100, + 'province': objValues.ship_state - 'purchasePrice': { - 'currencyCode': objValues.currency, - 'amount': parseInt(objValues.purchase_price * 100), } - - // 'serialNumber' : objValues.serial_number }, - 'plan': { - // 'purchasePrice': objValues.plan_price * 100, - - 'purchasePrice': { - 'currencyCode': objValues.currency, - 'amount': parseInt(objValues.plan_price * 100), - }, + 'storeId': config.storeId, + 'lineItems': [ + { + 'plan': { + 'id': objValues.extend_plan_id, + 'purchasePrice': parseInt(objValues.plan_price * 100) + }, + 'product': { + 'id': objValues.refId, + // 'serialNumber': objValues.serial_number, + 'purchasePrice': parseInt(objValues.purchase_price * 100) + }, + 'quantity': objValues.quantity + } + ], + 'total': parseInt(objValues.total_amount * 100), + 'transactionId': objValues.id, + } - 'planId': objValues.extend_plan_id - } - }; return objJSON; }; diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js new file mode 100644 index 0000000..c713c45 --- /dev/null +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js @@ -0,0 +1,101 @@ +/** + *@name: EXTEND SUITESCRIPT SDK - Create Contract from Fulfillment JS + *@description: + * This script invokes a call to the Extend Contracts POST endpoint whenever + * an item with a protection plan is fulfilled + * + *@copyright Extend, Inc + *@author Michael Draper + * + *@NApiVersion 2.x + *@NScriptType MapReduceScript + *@ModuleScope Public + */ +define([ + 'N/runtime', + 'N/record', + 'N/search', + '../lib/customscript_ext_util' +], + function (runtime, record, search, EXTEND_UTIL) { + var exports = {}; + + exports.getInputData = function () { + try { + log.audit('getInputData', '** START **'); + //todo build search in getinput instead of param? + var stSalesOrderSearchID = runtime.getCurrentScript().getParameter('custscript_ext_so_search'); + + log.debug('stSalesOrderSearchID', stSalesOrderSearchID); + var salesOrderSearch = search.load({ + id: stSalesOrderSearchID + }); + + return salesOrderSearch; + + } catch (e) { + log.error('getInputData', 'error: ' + e); + } + } + exports.reduce = function (context) { + try { + log.debug('reduce', '** START **'); + + var stSalesOrderId = context.key; + log.audit('reduce', 'stSalesOrderId: ' + stSalesOrderId); + //Load associated Saled Order Record + var objSalesOrderRecord = record.load({ + type: 'salesorder', + id: stSalesOrderId + }); + // Get Extend Details from Sales Order + log.audit('reduce: SO Data to Extend Object', objExtendData); + objExtendData = EXTEND_UTIL.createExtendOrder(objSalesOrderRecord); + + } catch (e) { + log.error('reduce', 'key: ' + context.key + ' error: ' + e); + record.submitFields({ + type: record.Type.SALES_ORDER, + id: stSalesOrderId, + values: { + 'custbody_ext_process_error': true + }, + options: { + enableSourcing: false, + ignoreMandatoryFields: true + } + }); + // create user note attached to record + var objNoteRecord = record.create({ + type: record.Type.NOTE, + }) + objNoteRecord.setValue('transaction', stSalesOrderId); + objNoteRecord.setValue('title', 'Extend Error Order Create'); + objNoteRecord.setValue('note', JSON.stringify(e.message)); + var stNoteId = objNoteRecord.save(); + log.debug('reduce', 'stNoteId: ' + stNoteId); + + } + } + exports.summarize = function (summary) { + log.audit('summarize', '** START **'); + try { + var mapKeys = []; + summary.mapSummary.keys.iterator().each(function (key) { + mapKeys.push(key); + return true; + }); + if (mapKeys.length < 1) { + log.debug('summarize', 'No results were processed'); + } + log.debug('summarize', JSON.stringify(summary)); + + } catch (e) { + log.error('summarize', 'error: ' + e); + } + } + + + + return exports; + }); From e0c888efc2ac017f450354de99f000162e024fcc Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Tue, 24 May 2022 09:53:21 -0500 Subject: [PATCH 03/33] updated util lib --- .../lib/customscript_ext_util.js | 274 +++++++++--------- 1 file changed, 139 insertions(+), 135 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 7f5ca50..703c571 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -3,7 +3,7 @@ *@description: Structures the various JSON request bodies to the Extend API * @NApiVersion 2.x */ - define([ +define([ 'N/search', 'N/record', 'N/error', @@ -12,7 +12,7 @@ ], function (search, record, error, EXTEND_API, EXTEND_CONFIG) { - var exports = {}; + var exports = {}; /** * Order Functions */ @@ -20,140 +20,91 @@ exports.createExtendOrder = function (objSalesOrderRecord) { log.debug('EXTEND UTIL _createExtendOrder:', '**ENTER**'); log.debug('EXTEND UTIL _createExtendOrder: SO ID', objSalesOrderRecord.id); + var objExtendOrderRequestJSON = {}; - //////////////////////////SUPPORT FUNCTIONS/////////////////////////// - var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); + //build array of items + var objExtendItemData = exports.getSalesOrderInfo(objSalesOrderRecord); + log.debug('EXTEND UTIL _createExtendOrder: objExtendItemData', objExtendItemData); - log.debug('EXTEND UTIL _createExtendOrder: Line Count', stLineCount); + //build order data obj + var objExtendData = {}; + objExtendData = exports.getSalesOrderInfo(objSalesOrderRecord); + log.debug('EXTEND UTIL _createExtendOrder: objExtendData', objExtendData); - if (stLineCount > 0) { - log.debug('EXTEND UTIL _createExtendOrder: Get Extend Data', '**START**'); - } - log.debug('_getExtendData: Get Extend Data', '**ENTER**'); - var objExtendItemData = {}; - - var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); - for (var i = 0; i < stLineCount; i++) { - var stItemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); - //Check if item is one of the configured extend items - if (stExtendItemId === stItemId) { - log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); - //get qty of contracts created & compare to extend item qty - var stContractQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_qty', line: i }); - var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); - - if (stContractQty < stExtendItemQty) { - - //get related item from extend line - var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - //check for new fulfillments - for (var j = 0; j < stLineCount; j++) { - var stRelatedItem = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); - if (stRelatedItem === stExtendItemRefId) { - - var stRelatedItemQtyFulfilled = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantityfulfilled', line: j }); - if (stRelatedItemQtyFulfilled <= stExtendItemQty && stRelatedItemQtyFulfilled > stContractQty) { - - var stUniqueKey = i; - // Start building the Extend Order Info Object - objExtendItemData[stUniqueKey] = {}; - objExtendItemData[stUniqueKey].quantity = Math.min(stRelatedItemQtyFulfilled, (stExtendItemQty - stContractQty)); - objExtendItemData[stUniqueKey].item = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - objExtendItemData[stUniqueKey].line = i; - objExtendItemData[stUniqueKey].purchase_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: j }); - objExtendItemData[stUniqueKey].extend_plan_id = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); - objExtendItemData[stUniqueKey].itemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; - objExtendItemData[stUniqueKey].plan_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); - - } - } - } - } - } - } + objExtendData.lineItems = exports.buildExtendItemJSON(objExtendItemData); + log.debug('EXTEND UTIL _createExtendOrder: objExtendData', objExtendData); - for (key in objExtendData) { + //build order json obj + objExtendOrderRequestJSON = exports.buildExtendOrderJSON(objExtendData); + log.debug('EXTEND UTIL _createExtendOrder: objExtendContractRequestJSON', objExtendOrderRequestJSON); + //call api + var objExtendResponse = EXTEND_API.createWarrantyContract(objExtendOrderRequestJSON); + log.debug('EXTEND UTIL _createExtendOrder: Extend Response Object: ', objExtendResponse); + //handle response + if (objExtendResponse.code === 201) { + var objExtendResponseBody = JSON.parse(objExtendResponse.body); + log.debug('EXTEND UTIL _createExtendOrder: Extend Response Body Parsed: ', objExtendResponseBody); - var objExtendContractRequestJSON = {}; - var stQuantity = objExtendData[key].quantity; - log.debug('EXTEND UTIL _createExtendOrder: Quantity of Line', stQuantity); - var arrContractIds = []; - var stExtendContractQty = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_qty', line: objExtendData[key].line }); - var stExtendContractId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: objExtendData[key].line });; + } else { + log.error('EXTEND UTIL _createExtendContracts', objExtendResponse); + objSalesOrderRecord.setValue({ fieldId: 'custbody_ext_process_error', value: true }); + // create user note attached to record + var objNoteRecord = record.create({ + type: record.Type.NOTE, + }) + objNoteRecord.setValue('transaction', objSalesOrderRecord.id); + objNoteRecord.setValue('title', 'Extend Order Create Error'); + objNoteRecord.setValue('note', JOSN.stringify(objExtendResponse)); + var stNoteId = objNoteRecord.save(); + } - if (stExtendContractId) { - arrContractIds = JSON.parse(stExtendContractId); - } - // Create contract call for quantity fulfilled on the Extend item - for (var i = 0; i < stQuantity; i++) { - objExtendContractRequestJSON = exports.buildExtendContractJSON(objExtendData[key]); - log.debug('EXTEND UTIL _createExtendContracts: objExtendContractRequestJSON', objExtendContractRequestJSON); - - var objExtendResponse = EXTEND_API.createWarrantyContract(objExtendContractRequestJSON); - log.debug('EXTEND UTIL _createExtendContracts: Extend Response Object: ' + i, objExtendResponse); - if (objExtendResponse.code === 201) { - var objExtendResponseBody = JSON.parse(objExtendResponse.body); - arrContractIds.push(objExtendResponseBody.id); - stExtendContractQty++; - } else { - log.error('EXTEND UTIL _createExtendContracts', objExtendResponse); - objSalesOrderRecord.setValue({ fieldId: 'custbody_ext_process_error', value: true }); - // create user note attached to record - var objNoteRecord = record.create({ - type: record.Type.NOTE, - }) - objNoteRecord.setValue('transaction', objSalesOrderRecord.id); - objNoteRecord.setValue('title', 'Extend Contract Create Error | Line ' + key); - objNoteRecord.setValue('note', JOSN.stringify(objExtendResponse)); - var stNoteId = objNoteRecord.save(); - } - } - log.debug('EXTEND UTIL _createExtendContracts: arrContractIds', arrContractIds); - log.debug('EXTEND UTIL _createExtendContracts: new stExtendContractQty', stExtendContractQty); + //storing returned contract ids + /* + var arrContractIds = []; + var stExtendContractId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: objExtendData[key].line });; - // If Extend contract is created, populate the appropriate custom column field for contracts - // on the Sales Order line - objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_qty', line: objExtendData[key].line, value: stExtendContractQty }); - objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: objExtendData[key].line, value: JSON.stringify(arrContractIds) }); + if (stExtendContractId) { + arrContractIds = JSON.parse(stExtendContractId); } + // If Extend contract is created, populate the appropriate custom column field for contracts + // on the Sales Order line + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: objExtendData[key].line, value: JSON.stringify(arrContractIds) }); +*/ objSalesOrderRecord.save(); }; //get Sales Order Info required for contract create - exports.getSalesOrderInfo = function (objExtendData, objSalesOrderRecord) { + exports.getSalesOrderInfo = function (objSalesOrderRecord) { log.debug('EXTEND UTIL _getSalesOrderInfo:', '**ENTER**'); - - for (stKey in objExtendData) { - log.debug('EXTEND UTIL _getSalesOrderInfo: Key', stKey); - log.debug('EXTEND UTIL _getSalesOrderInfo: ExtendData Object', objExtendData); - var objCustomerInfo = exports.getCustomerInfo(objSalesOrderRecord.getValue({ fieldId: 'entity' })); - //Build SO Info Object - objExtendData[stKey].id = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); - objExtendData[stKey].tran_date = exports.getepochDate(); - objExtendData[stKey].currency = 'USD'; - objExtendData[stKey].order_number = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); - objExtendData[stKey].total_amount = objSalesOrderRecord.getValue({ fieldId: 'total' }); - objExtendData[stKey].name = objSalesOrderRecord.getText({ fieldId: 'entity' }).replace(/[0-9]/g, ''); - objExtendData[stKey].email = objCustomerInfo.email; - objExtendData[stKey].phone = objCustomerInfo.phone; - objExtendData[stKey].bill_address1 = objCustomerInfo.bill_address1; - objExtendData[stKey].bill_address2 = objCustomerInfo.bill_address2; - objExtendData[stKey].bill_city = objCustomerInfo.bill_city; - objExtendData[stKey].bill_state = objCustomerInfo.bill_state; - objExtendData[stKey].bill_zip = objCustomerInfo.bill_zip; - objExtendData[stKey].bill_country = objCustomerInfo.bill_country; - objExtendData[stKey].ship_address1 = objCustomerInfo.ship_address1; - objExtendData[stKey].ship_address2 = objCustomerInfo.ship_address2; - objExtendData[stKey].ship_city = objCustomerInfo.ship_city; - objExtendData[stKey].ship_state = objCustomerInfo.ship_state; - objExtendData[stKey].ship_zip = objCustomerInfo.ship_zip; - objExtendData[stKey].ship_country = objCustomerInfo.ship_country; - } + var objExtendData = {}; + log.debug('EXTEND UTIL _getSalesOrderInfo: ExtendData Object', objExtendData); + var objCustomerInfo = exports.getCustomerInfo(objSalesOrderRecord.getValue({ fieldId: 'entity' })); + //Build SO Info Object + objExtendData.id = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); + objExtendData.tran_date = exports.getepochDate(); + objExtendData.currency = 'USD'; + objExtendData.order_number = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); + objExtendData.total_amount = objSalesOrderRecord.getValue({ fieldId: 'total' }); + objExtendData.name = objSalesOrderRecord.getText({ fieldId: 'entity' }).replace(/[0-9]/g, ''); + objExtendData.email = objCustomerInfo.email; + objExtendData.phone = objCustomerInfo.phone; + objExtendData.bill_address1 = objCustomerInfo.bill_address1; + objExtendData.bill_address2 = objCustomerInfo.bill_address2; + objExtendData.bill_city = objCustomerInfo.bill_city; + objExtendData.bill_state = objCustomerInfo.bill_state; + objExtendData.bill_zip = objCustomerInfo.bill_zip; + objExtendData.bill_country = objCustomerInfo.bill_country; + objExtendData.ship_address1 = objCustomerInfo.ship_address1; + objExtendData.ship_address2 = objCustomerInfo.ship_address2; + objExtendData.ship_city = objCustomerInfo.ship_city; + objExtendData.ship_state = objCustomerInfo.ship_state; + objExtendData.ship_zip = objCustomerInfo.ship_zip; + objExtendData.ship_country = objCustomerInfo.ship_country; return objExtendData; }; - exports.getItemRefId = function(stItemId){ + exports.getItemRefId = function (stItemId) { var refIdValue = EXTEND_CONFIG.getConfig().refId; var stItemRefId = stItemId; if (refIdValue) { @@ -218,7 +169,73 @@ } return stPurchasePrice; }; + exports.getSalesOrderItemInfo = function (objSalesOrderRecord) { + + //////////////////////////SUPPORT FUNCTIONS/////////////////////////// + var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); + + log.debug('EXTEND UTIL _createExtendOrder: Line Count', stLineCount); + log.debug('_getExtendData: Get Extend Data', '**ENTER**'); + + var objExtendItemData = {}; + var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + for (var i = 0; i < stLineCount; i++) { + stUniqueKey = i; + objExtendItemData[stUniqueKey] = {}; + var stItemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); + + //Check if item is one of the configured extend items + if (stExtendItemId === stItemId) { + log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); + + //get related item from extend line + var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + for (var j = 0; j < stLineCount; j++) { + var stRelatedItem = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); + if (stRelatedItem === stExtendItemRefId) { + // Start building the Extend Order Plan Info Object + objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + objExtendItemData[stUniqueKey].extend_plan_id = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); + objExtendItemData[stUniqueKey].itemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; + objExtendItemData[stUniqueKey].plan_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); + + } + } + } else { + // Start building the Extend Order Item Info Object + objExtendItemData[stUniqueKey].quantity = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); + objExtendItemData[stUniqueKey].item = stItemId + objExtendItemData[stUniqueKey].line = i; + objExtendItemData[stUniqueKey].purchase_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); + } + + } + }; + exports.buildExtendItemJSON = function (objValues) { + //item json + var lineItems = []; + for (key in objValues) { + var item = { + 'plan': { + 'id': objValues[key].extend_plan_id, + 'purchasePrice': parseInt(objValues[key].plan_price * 100) + }, + 'product': { + 'id': objValues.refId, + // 'serialNumber': objValues.serial_number, + 'purchasePrice': parseInt(objValues[key].purchase_price * 100) + }, + 'quantity': objValues[key].quantity + } + log.debug('_buildExtendItemJSON: Item obj | Line ', item + ' | ' + key); + lineItems.push(item); + + } + log.debug('_buildExtendItemJSON: lineItems', lineItems); + + return lineItems; + }; // Build the Extend API JSON for contract creation exports.buildExtendOrderJSON = function (objValues) { log.debug('EXTEND UTIL _buildExtendOrderJSON:', '**ENTER**'); @@ -229,8 +246,8 @@ //get product refId objValues.refId = exports.getItemRefId(objValues.itemId); //If Demo use demo email for contracts - var config = EXTEND_CONFIG.getConfig(); - if(config.email){ + var config = EXTEND_CONFIG.getConfig(); + if (config.email) { objValues.email = config.email; } @@ -259,20 +276,7 @@ } }, 'storeId': config.storeId, - 'lineItems': [ - { - 'plan': { - 'id': objValues.extend_plan_id, - 'purchasePrice': parseInt(objValues.plan_price * 100) - }, - 'product': { - 'id': objValues.refId, - // 'serialNumber': objValues.serial_number, - 'purchasePrice': parseInt(objValues.purchase_price * 100) - }, - 'quantity': objValues.quantity - } - ], + 'lineItems': objValues.lineItems, 'total': parseInt(objValues.total_amount * 100), 'transactionId': objValues.id, } From ab2930a93677eb12c5d547a1d044a1c7444d2bf4 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Thu, 16 Jun 2022 09:01:05 -0500 Subject: [PATCH 04/33] order creation/response handling --- .../lib/customscript_ext_util.js | 1 - 1 file changed, 1 deletion(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 703c571..3f7c014 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -170,7 +170,6 @@ define([ return stPurchasePrice; }; exports.getSalesOrderItemInfo = function (objSalesOrderRecord) { - //////////////////////////SUPPORT FUNCTIONS/////////////////////////// var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); From 957754ee34b5639c673b687a5896190f302b9530 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Thu, 16 Jun 2022 09:01:29 -0500 Subject: [PATCH 05/33] order creation/response handling --- .../lib/customscript_ext_config_lib.js | 10 +- .../lib/customscript_ext_util.js | 672 ++++++++++-------- .../customscript_ext_create_order_mr.js | 3 +- .../src/deploy.xml | 2 +- 4 files changed, 370 insertions(+), 317 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js index b942d1a..81fe50b 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js @@ -26,7 +26,9 @@ var customrecord_ext_configurationSearchObj = search.create({ type: "customrecord_ext_configuration", - filters:[], + filters:[ + ["isinactive","is","F"] + ], columns: [ search.createColumn({name: "custrecord_ext_environment", label: "Environment "}), @@ -84,7 +86,7 @@ //param is custom record extend config var stEnvironment = runtime.getCurrentScript().getParameter('custscript_ext_environment'); log.audit('stEnvironment', stEnvironment); - switch(stEnvironment){ + switch(Number(stEnvironment)){ case objExtendEnvironment.SANDBOX: stEnvironment = 'SANDBOX' break; @@ -98,8 +100,8 @@ var objKeys = {}; objKeys['SANDBOX'] = objSandbox; - objKeys['PRODUCTION'] = objSandbox; //Demo Purposes - //objKeys['PRODUCTION'] = objProd; + //objKeys['PRODUCTION'] = objSandbox; //Demo Purposes + objKeys['PRODUCTION'] = objProd; //by runtime or by global param //runtime /* diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 3f7c014..0c44f2c 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -4,6 +4,7 @@ * @NApiVersion 2.x */ define([ + 'N/runtime', 'N/search', 'N/record', 'N/error', @@ -11,41 +12,39 @@ define([ '../lib/customscript_ext_config_lib' ], - function (search, record, error, EXTEND_API, EXTEND_CONFIG) { + function (runtime, search, record, error, EXTEND_API, EXTEND_CONFIG) { var exports = {}; /** * Order Functions */ //create extend order exports.createExtendOrder = function (objSalesOrderRecord) { - log.debug('EXTEND UTIL _createExtendOrder:', '**ENTER**'); - log.debug('EXTEND UTIL _createExtendOrder: SO ID', objSalesOrderRecord.id); + log.audit('EXTEND UTIL _createExtendOrder:', '**ENTER**'); + log.audit('EXTEND UTIL _createExtendOrder: SO ID', objSalesOrderRecord.id); var objExtendOrderRequestJSON = {}; - //build array of items - var objExtendItemData = exports.getSalesOrderInfo(objSalesOrderRecord); - log.debug('EXTEND UTIL _createExtendOrder: objExtendItemData', objExtendItemData); - //build order data obj var objExtendData = {}; + //get SO header data objExtendData = exports.getSalesOrderInfo(objSalesOrderRecord); - log.debug('EXTEND UTIL _createExtendOrder: objExtendData', objExtendData); - - + log.audit('EXTEND UTIL _createExtendOrder: getSalesOrderInfo objExtendData', objExtendData); + //build array of items + var objExtendItemData = exports.getSalesOrderItemInfo(objSalesOrderRecord); + log.audit('EXTEND UTIL _createExtendOrder: objExtendItemData', objExtendItemData); + //format items objExtendData.lineItems = exports.buildExtendItemJSON(objExtendItemData); - log.debug('EXTEND UTIL _createExtendOrder: objExtendData', objExtendData); + log.audit('EXTEND UTIL _createExtendOrder: objExtendData', objExtendData); //build order json obj objExtendOrderRequestJSON = exports.buildExtendOrderJSON(objExtendData); - log.debug('EXTEND UTIL _createExtendOrder: objExtendContractRequestJSON', objExtendOrderRequestJSON); + log.audit('EXTEND UTIL _createExtendOrder: objExtendOrderRequestJSON', objExtendOrderRequestJSON); //call api - var objExtendResponse = EXTEND_API.createWarrantyContract(objExtendOrderRequestJSON); - log.debug('EXTEND UTIL _createExtendOrder: Extend Response Object: ', objExtendResponse); + var objExtendResponse = EXTEND_API.createOrder(objExtendOrderRequestJSON); + log.audit('EXTEND UTIL _createExtendOrder: Extend Response Object: ', objExtendResponse); //handle response if (objExtendResponse.code === 201) { var objExtendResponseBody = JSON.parse(objExtendResponse.body); - log.debug('EXTEND UTIL _createExtendOrder: Extend Response Body Parsed: ', objExtendResponseBody); - + EXTEND_API.handleResponse(objExtendResponseBody, objSalesOrderRecord); } else { log.error('EXTEND UTIL _createExtendContracts', objExtendResponse); objSalesOrderRecord.setValue({ fieldId: 'custbody_ext_process_error', value: true }); @@ -55,337 +54,390 @@ define([ }) objNoteRecord.setValue('transaction', objSalesOrderRecord.id); objNoteRecord.setValue('title', 'Extend Order Create Error'); - objNoteRecord.setValue('note', JOSN.stringify(objExtendResponse)); + objNoteRecord.setValue('note', JSON.stringify(objExtendResponse)); var stNoteId = objNoteRecord.save(); } - //storing returned contract ids - /* - var arrContractIds = []; - var stExtendContractId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: objExtendData[key].line });; - - if (stExtendContractId) { - arrContractIds = JSON.parse(stExtendContractId); - } - - // If Extend contract is created, populate the appropriate custom column field for contracts - // on the Sales Order line - objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: objExtendData[key].line, value: JSON.stringify(arrContractIds) }); -*/ objSalesOrderRecord.save(); }; + exports.handleResponse = function (objExtendResponse, objSalesOrderRecord) { + + log.debug('EXTEND UTIL _createExtendOrder: Extend Response Body Parsed: ', objExtendResponseBody); + var arrLineItems = objExtendResponseBody.lineItems; + var objExtendResponseData = {}; + + for (var i = 0; i < arrLineItems.length; i++) { + log.debug('EXTEND UTIL _createExtendOrder: arrLineItems: ', arrLineItems[i]); + var line = arrLineItems[i].lineItemTransactionId; + line = line.substring(objSalesOrderRecord.id.toString().length, line.length); + log.debug('EXTEND UTIL _createExtendOrder: line: ', line + '|' + typeof line); + stUniqueKey = line; + + + if (arrLineItems[i].type == 'contract') { + var arrContractIds = []; + arrContractIds = objExtendResponseData[stUniqueKey].contractIds; + log.debug('EXTEND UTIL _createExtendOrder: arrContractIds: ', arrContractIds); + log.debug('EXTEND UTIL _createExtendOrder: contractid arrLineItems: ', arrLineItems[i].contractId); + arrContractIds.push(arrLineItems[i].contractId) + objExtendResponseData[stUniqueKey].contractIds = arrContractIds; + + // If Extend contract is created, populate the appropriate custom column field for contracts + // on the Sales Order line + // objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: line, value: JSON.stringify(arrContractIds) }); - //get Sales Order Info required for contract create - exports.getSalesOrderInfo = function (objSalesOrderRecord) { - log.debug('EXTEND UTIL _getSalesOrderInfo:', '**ENTER**'); - var objExtendData = {}; - log.debug('EXTEND UTIL _getSalesOrderInfo: ExtendData Object', objExtendData); - var objCustomerInfo = exports.getCustomerInfo(objSalesOrderRecord.getValue({ fieldId: 'entity' })); - //Build SO Info Object - objExtendData.id = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); - objExtendData.tran_date = exports.getepochDate(); - objExtendData.currency = 'USD'; - objExtendData.order_number = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); - objExtendData.total_amount = objSalesOrderRecord.getValue({ fieldId: 'total' }); - objExtendData.name = objSalesOrderRecord.getText({ fieldId: 'entity' }).replace(/[0-9]/g, ''); - objExtendData.email = objCustomerInfo.email; - objExtendData.phone = objCustomerInfo.phone; - objExtendData.bill_address1 = objCustomerInfo.bill_address1; - objExtendData.bill_address2 = objCustomerInfo.bill_address2; - objExtendData.bill_city = objCustomerInfo.bill_city; - objExtendData.bill_state = objCustomerInfo.bill_state; - objExtendData.bill_zip = objCustomerInfo.bill_zip; - objExtendData.bill_country = objCustomerInfo.bill_country; - objExtendData.ship_address1 = objCustomerInfo.ship_address1; - objExtendData.ship_address2 = objCustomerInfo.ship_address2; - objExtendData.ship_city = objCustomerInfo.ship_city; - objExtendData.ship_state = objCustomerInfo.ship_state; - objExtendData.ship_zip = objCustomerInfo.ship_zip; - objExtendData.ship_country = objCustomerInfo.ship_country; - return objExtendData; - }; - exports.getItemRefId = function (stItemId) { - var refIdValue = EXTEND_CONFIG.getConfig().refId; - var stItemRefId = stItemId; - if (refIdValue) { - // Lookup to item to see if it is eligible for warranty offers - var arrItemLookup = search.lookupFields({ - type: 'item', - id: stItemId, - columns: refIdValue - }); - for (var prop in arrItemLookup) { - var stItemRefId = arrItemLookup[prop] - break; } } - return stItemRefId; - } - //get Transaction Date required for contract create - exports.getTransactionDate = function (stDate) { - var stTimeDate = new Date(stDate); - return stTimeDate.getTime() / 1000; }; - //get Current Date in epoch format required for contract create - exports.getepochDate = function () { - var stTimeDate = new Date(); - return stTimeDate.getTime(); - }; - //get Customer Info required for contract create - exports.getCustomerInfo = function (stCustomerId) { - var objCustomerRecord = record.load({ - type: 'customer', - id: stCustomerId - }); - var objCustomerInfo = { - "email": objCustomerRecord.getValue({ fieldId: 'email' }), - "phone": objCustomerRecord.getValue({ fieldId: 'phone' }), - "bill_address1": objCustomerRecord.getValue({ fieldId: 'billaddr1' }), - "bill_address2": objCustomerRecord.getValue({ fieldId: 'billaddr2' }), - "bill_city": objCustomerRecord.getValue({ fieldId: 'billcity' }), - "bill_state": objCustomerRecord.getValue({ fieldId: 'billstate' }), - "bill_zip": objCustomerRecord.getValue({ fieldId: 'billzip' }), - "bill_country": "US", - "ship_address1": objCustomerRecord.getValue({ fieldId: 'shipaddr1' }), - "ship_address2": objCustomerRecord.getValue({ fieldId: 'shipaddr2' }), - "ship_city": objCustomerRecord.getValue({ fieldId: 'shipcity' }), - "ship_state": objCustomerRecord.getValue({ fieldId: 'shipstate' }), - "ship_zip": objCustomerRecord.getValue({ fieldId: 'shipzip' }), - "ship_country": "US", + //get Sales Order Info required for contract create + exports.getSalesOrderInfo = function (objSalesOrderRecord) { + log.debug('EXTEND UTIL _getSalesOrderInfo:', '**ENTER**'); + var objExtendData = {}; + log.debug('EXTEND UTIL _getSalesOrderInfo: ExtendData Object', objExtendData); + var objCustomerInfo = exports.getCustomerInfo(objSalesOrderRecord.getValue({ fieldId: 'entity' })); + var objShipAddress = exports.getAddress(objSalesOrderRecord, 'shippingaddress'); + var objBillAddress = exports.getAddress(objSalesOrderRecord, 'billingaddress'); + //Build SO Info Object + objExtendData.id = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); + objExtendData.tran_date = exports.getepochDate(); + objExtendData.currency = 'USD'; + objExtendData.order_number = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); + objExtendData.total_amount = objSalesOrderRecord.getValue({ fieldId: 'total' }); + objExtendData.name = objSalesOrderRecord.getText({ fieldId: 'entity' }).replace(/[0-9]/g, ''); + objExtendData.email = objCustomerInfo.email; + objExtendData.phone = objCustomerInfo.phone; + objExtendData.bill_address1 = objBillAddress.address1; + objExtendData.bill_address2 = objBillAddress.address2; + objExtendData.bill_city = objBillAddress.city; + objExtendData.bill_state = objBillAddress.state; + objExtendData.bill_zip = objBillAddress.zip; + objExtendData.bill_country = objBillAddress.country; + objExtendData.ship_address1 = objShipAddress.address1; + objExtendData.ship_address2 = objShipAddress.address2; + objExtendData.ship_city = objShipAddress.city; + objExtendData.ship_state = objShipAddress.state; + objExtendData.ship_zip = objShipAddress.zip; + objExtendData.ship_country = objShipAddress.country; + return objExtendData; + }; + exports.getAddress = function (objSalesOrderRecord, addressField) { + var address = objSalesOrderRecord.getSubrecord({ + fieldId: addressField + }); + var objAddress = { + address1: address.getValue({ + fieldId: 'addr1' + }), + address2: address.getValue({ + fieldId: 'addr2' + }), + city: address.getValue({ + fieldId: 'city' + }), + state: address.getValue({ + fieldId: 'state' + }), + country: address.getValue({ + fieldId: 'country' + }), + zip: address.getValue({ + fieldId: 'zip' + }) + }; + return objAddress; } - return objCustomerInfo; - }; - //get Item Purchase Price - exports.getPurchasePrice = function (stItemId) { - var arrFilters = []; - arrFilters.push(search.createFilter({ name: 'internalid', operator: 'is', values: [stItemId] })); - var arrColumns = []; - arrColumns.push(search.createColumn({ name: 'baseprice' })); + exports.getItemRefId = function (stItemId) { + var config = EXTEND_CONFIG.getConfig(); + var refIdValue = config.refId; + var stItemRefId = stItemId; + if (refIdValue) { + // Lookup to item to see if it is eligible for warranty offers + var arrItemLookup = search.lookupFields({ + type: 'item', + id: stItemId, + columns: refIdValue + }); + for (var prop in arrItemLookup) { + var stItemRefId = arrItemLookup[prop] + break; + } + } - var arrSearchResults = exports.search('item', null, arrFilters, arrColumns); - var stPurchasePrice; - if (arrSearchResults.length) { - stPurchasePrice = arrSearchResults[0].getValue({ name: 'baseprice' }); + return stItemRefId; } - return stPurchasePrice; - }; - exports.getSalesOrderItemInfo = function (objSalesOrderRecord) { - //////////////////////////SUPPORT FUNCTIONS/////////////////////////// - var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); - - log.debug('EXTEND UTIL _createExtendOrder: Line Count', stLineCount); - log.debug('_getExtendData: Get Extend Data', '**ENTER**'); - - var objExtendItemData = {}; - - var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); - for (var i = 0; i < stLineCount; i++) { - stUniqueKey = i; - objExtendItemData[stUniqueKey] = {}; - var stItemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); - - //Check if item is one of the configured extend items - if (stExtendItemId === stItemId) { - log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); - - //get related item from extend line - var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - for (var j = 0; j < stLineCount; j++) { - var stRelatedItem = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); - if (stRelatedItem === stExtendItemRefId) { - // Start building the Extend Order Plan Info Object - objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - objExtendItemData[stUniqueKey].extend_plan_id = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); - objExtendItemData[stUniqueKey].itemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; - objExtendItemData[stUniqueKey].plan_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); - + //get Transaction Date required for contract create + exports.getTransactionDate = function (stDate) { + var stTimeDate = new Date(stDate); + return stTimeDate.getTime() / 1000; + }; + //get Current Date in epoch format required for contract create + exports.getepochDate = function () { + var stTimeDate = new Date(); + return stTimeDate.getTime(); + }; + //get Customer Info required for contract create + exports.getCustomerInfo = function (stCustomerId) { + var objCustomerRecord = record.load({ + type: 'customer', + id: stCustomerId + }); + var objCustomerInfo = { + "email": objCustomerRecord.getValue({ fieldId: 'email' }), + "phone": objCustomerRecord.getValue({ fieldId: 'phone' }), + "bill_address1": objCustomerRecord.getValue({ fieldId: 'billaddr1' }), + "bill_address2": objCustomerRecord.getValue({ fieldId: 'billaddr2' }), + "bill_city": objCustomerRecord.getValue({ fieldId: 'billcity' }), + "bill_state": objCustomerRecord.getValue({ fieldId: 'billstate' }), + "bill_zip": objCustomerRecord.getValue({ fieldId: 'billzip' }), + "bill_country": "US", + "ship_address1": objCustomerRecord.getValue({ fieldId: 'shipaddr1' }), + "ship_address2": objCustomerRecord.getValue({ fieldId: 'shipaddr2' }), + "ship_city": objCustomerRecord.getValue({ fieldId: 'shipcity' }), + "ship_state": objCustomerRecord.getValue({ fieldId: 'shipstate' }), + "ship_zip": objCustomerRecord.getValue({ fieldId: 'shipzip' }), + "ship_country": "US", + } + return objCustomerInfo; + }; + //get Item Purchase Price + exports.getPurchasePrice = function (stItemId) { + var arrFilters = []; + arrFilters.push(search.createFilter({ name: 'internalid', operator: 'is', values: [stItemId] })); + var arrColumns = []; + arrColumns.push(search.createColumn({ name: 'baseprice' })); + + var arrSearchResults = exports.search('item', null, arrFilters, arrColumns); + var stPurchasePrice; + if (arrSearchResults.length) { + stPurchasePrice = arrSearchResults[0].getValue({ name: 'baseprice' }); + } + return stPurchasePrice; + }; + exports.getSalesOrderItemInfo = function (objSalesOrderRecord) { + //////////////////////////SUPPORT FUNCTIONS/////////////////////////// + var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); + + log.debug('EXTEND UTIL _createExtendOrder: Line Count', stLineCount); + log.debug('_getExtendData: Get Extend Data', '**ENTER**'); + + var objExtendItemData = {}; + + var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + for (var i = 0; i < stLineCount; i++) { + var stItemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); + stUniqueKey = i; + if (stExtendItemId !== stItemId) { + objExtendItemData[stUniqueKey] = {}; + } + //Check if item is one of the configured extend items + if (stExtendItemId === stItemId) { + log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); + + //get related item from extend line + var stExtendItemRefId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + for (var j = 0; j < stLineCount; j++) { + var stRelatedItem = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); + if (stRelatedItem === stExtendItemRefId) { + log.debug('_getExtendData: stRelatedItem| stExtendItemRefId ', stRelatedItem + ' | ' + stExtendItemRefId); + + stUniqueKey = j; + // Start building the Extend Order Plan Info Object + objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); + objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; + objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); + + } } + } else { + // Start building the Extend Order Item Info Object + objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); + objExtendItemData[stUniqueKey].itemId = stItemId + objExtendItemData[stUniqueKey].line = i; + objExtendItemData[stUniqueKey].purchase_price = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); + objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + i; } - } else { - // Start building the Extend Order Item Info Object - objExtendItemData[stUniqueKey].quantity = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); - objExtendItemData[stUniqueKey].item = stItemId - objExtendItemData[stUniqueKey].line = i; - objExtendItemData[stUniqueKey].purchase_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); - } - } - }; - exports.buildExtendItemJSON = function (objValues) { - //item json - var lineItems = []; - for (key in objValues) { - var item = { - 'plan': { - 'id': objValues[key].extend_plan_id, - 'purchasePrice': parseInt(objValues[key].plan_price * 100) - }, - 'product': { - 'id': objValues.refId, - // 'serialNumber': objValues.serial_number, - 'purchasePrice': parseInt(objValues[key].purchase_price * 100) - }, - 'quantity': objValues[key].quantity } - log.debug('_buildExtendItemJSON: Item obj | Line ', item + ' | ' + key); - lineItems.push(item); + return objExtendItemData; + }; + exports.buildExtendItemJSON = function (objValues) { + //item json + var lineItems = []; + for (key in objValues) { + //get product refId + objValues.refId = exports.getItemRefId(objValues[key].itemId); + var item = { + 'product': { + 'id': objValues.refId, + // 'serialNumber': objValues.serial_number, + 'purchasePrice': parseInt(objValues[key].purchase_price * 100) + }, + 'quantity': objValues[key].quantity, + 'lineItemTransactionId': objValues[key].lineItemID + } + if (objValues[key].extend_plan_id && objValues[key].plan_price) { + item.plan = { + 'id': objValues[key].extend_plan_id, + 'purchasePrice': objValues[key].plan_price + } + } + lineItems.push(item); - } - log.debug('_buildExtendItemJSON: lineItems', lineItems); - return lineItems; - }; - // Build the Extend API JSON for contract creation - exports.buildExtendOrderJSON = function (objValues) { - log.debug('EXTEND UTIL _buildExtendOrderJSON:', '**ENTER**'); + } + log.debug('_buildExtendItemJSON: lineItems', lineItems); - // Date is a string and we need to format for extend - const stTranDate = new Date(objValues.tran_date); + return lineItems; + }; + // Build the Extend API JSON for contract creation + exports.buildExtendOrderJSON = function (objValues) { + log.debug('EXTEND UTIL _buildExtendOrderJSON:', '**ENTER**'); - //get product refId - objValues.refId = exports.getItemRefId(objValues.itemId); - //If Demo use demo email for contracts - var config = EXTEND_CONFIG.getConfig(); - if (config.email) { - objValues.email = config.email; - } + // Date is a string and we need to format for extend + const stTranDate = new Date(objValues.tran_date); - var objJSON = { - 'currency': objValues.currency, - 'customer': { - 'email': objValues.email, - 'name': objValues.name, - 'phone': objValues.phone, - 'billingAddress': { - 'address1': objValues.bill_address1, - 'address2': objValues.bill_address2, - 'city': objValues.bill_city, - 'postalCode': objValues.bill_zip, - 'countryCode': objValues.bill_country, - 'province': objValues.bill_state, - }, - 'shippingAddress': { - 'address1': objValues.ship_address1, - 'address2': objValues.ship_address2, - 'city': objValues.ship_city, - 'postalCode': objValues.ship_zip, - 'countryCode': objValues.ship_country, - 'province': objValues.ship_state + //If Demo use demo email for contracts + var config = EXTEND_CONFIG.getConfig(); + if (config.email) { + objValues.email = config.email; + } - } - }, - 'storeId': config.storeId, - 'lineItems': objValues.lineItems, - 'total': parseInt(objValues.total_amount * 100), - 'transactionId': objValues.id, - } + var objJSON = { + 'currency': objValues.currency, + 'customer': { + 'email': objValues.email, + 'name': objValues.name, + 'phone': objValues.phone, + 'billingAddress': { + 'address1': objValues.bill_address1, + 'address2': objValues.bill_address2, + 'city': objValues.bill_city, + 'postalCode': objValues.bill_zip, + 'countryCode': objValues.bill_country, + 'province': objValues.bill_state, + }, + 'shippingAddress': { + 'address1': objValues.ship_address1, + 'address2': objValues.ship_address2, + 'city': objValues.ship_city, + 'postalCode': objValues.ship_zip, + 'countryCode': objValues.ship_country, + 'province': objValues.ship_state - return objJSON; - }; + } + }, + 'storeId': config.storeId, + 'lineItems': objValues.lineItems, + 'total': parseInt(objValues.total_amount * 100), + 'transactionId': objValues.id, + } - /** - * Performs empty validations - */ - exports.objectIsEmpty = function (obj) { - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) - return false; - } - return true; - }; - exports.stringIsEmpty = function (stValue) { - if ((stValue == '') || (stValue == null) || (stValue == undefined)) { + return objJSON; + }; + /** + * Performs empty validations + */ + exports.objectIsEmpty = function (obj) { + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) + return false; + } return true; - } - return false; - }; - /** - * Createa Custom Error Object - */ - exports.createError = function (objErrorDetails) { - var objCustomError = error.create({ - name: objErrorDetails.title, - message: objErrorDetails.message, - notifyOff: true - }); - return objCustomError; - }; - - /** - * Performs search with no size limitations - */ - exports.search = function (stRecordType, stSearchId, arrSearchFilter, arrSearchColumn, bUseFilterExpressions, arrSearchSetting) { - if (!stRecordType && !stSearchId) { - throw 'search: Missing a required argument. Either stRecordType or stSearchId should be provided.'; - } - - var arrReturnSearchResults = []; - var objSavedSearch; - var intMaxResults = 1000; - if (stSearchId) { - objSavedSearch = search.load({ - id: stSearchId - }); - } - else { - objSavedSearch = search.create({ - type: stRecordType + }; + exports.stringIsEmpty = function (stValue) { + if ((stValue == '') || (stValue == null) || (stValue == undefined)) { + return true; + } + return false; + }; + /** + * Createa Custom Error Object + */ + exports.createError = function (objErrorDetails) { + var objCustomError = error.create({ + name: objErrorDetails.title, + message: objErrorDetails.message, + notifyOff: true }); - } + return objCustomError; + }; + + /** + * Performs search with no size limitations + */ + exports.search = function (stRecordType, stSearchId, arrSearchFilter, arrSearchColumn, bUseFilterExpressions, arrSearchSetting) { + if (!stRecordType && !stSearchId) { + throw 'search: Missing a required argument. Either stRecordType or stSearchId should be provided.'; + } - // add search filter if one is passed - if (arrSearchFilter) { - //Use Filter Expressions if that option has been enabled - if (bUseFilterExpressions) { - if (stSearchId) { - objSavedSearch.filterExpression = objSavedSearch.filters.concat(arrSearchFilter); + var arrReturnSearchResults = []; + var objSavedSearch; + var intMaxResults = 1000; + if (stSearchId) { + objSavedSearch = search.load({ + id: stSearchId + }); + } + else { + objSavedSearch = search.create({ + type: stRecordType + }); + } + + // add search filter if one is passed + if (arrSearchFilter) { + //Use Filter Expressions if that option has been enabled + if (bUseFilterExpressions) { + if (stSearchId) { + objSavedSearch.filterExpression = objSavedSearch.filters.concat(arrSearchFilter); + } + else { + objSavedSearch.filterExpression = arrSearchFilter; + } } else { - objSavedSearch.filterExpression = arrSearchFilter; + if (stSearchId) { + objSavedSearch.filters = objSavedSearch.filters.concat(arrSearchFilter); + } + else { + objSavedSearch.filters = arrSearchFilter; + } } } - else { + // add search column if one is passed + if (arrSearchColumn) { if (stSearchId) { - objSavedSearch.filters = objSavedSearch.filters.concat(arrSearchFilter); + objSavedSearch.columns = objSavedSearch.columns.concat(arrSearchColumn); } else { - objSavedSearch.filters = arrSearchFilter; + objSavedSearch.columns = arrSearchColumn; } } - } - // add search column if one is passed - if (arrSearchColumn) { - if (stSearchId) { - objSavedSearch.columns = objSavedSearch.columns.concat(arrSearchColumn); - } - else { - objSavedSearch.columns = arrSearchColumn; - } - } - // add search settings if one is passed - if (arrSearchSetting && arrSearchSetting.length > 0) { - if (stSearchId) { - objSavedSearch.settings = objSavedSearch.columns.concat(arrSearchSetting); - } - else { - objSavedSearch.settings = arrSearchSetting; + // add search settings if one is passed + if (arrSearchSetting && arrSearchSetting.length > 0) { + if (stSearchId) { + objSavedSearch.settings = objSavedSearch.columns.concat(arrSearchSetting); + } + else { + objSavedSearch.settings = arrSearchSetting; + } } - } - var objResultSet = objSavedSearch.run(); - var intSearchIndex = 0; - var arrResultSlice = null; - do { - arrResultSlice = objResultSet.getRange(intSearchIndex, intSearchIndex + intMaxResults); - if (arrResultSlice == null) { - break; + var objResultSet = objSavedSearch.run(); + var intSearchIndex = 0; + var arrResultSlice = null; + do { + arrResultSlice = objResultSet.getRange(intSearchIndex, intSearchIndex + intMaxResults); + if (arrResultSlice == null) { + break; + } + arrReturnSearchResults = arrReturnSearchResults.concat(arrResultSlice); + intSearchIndex = arrReturnSearchResults.length; } - arrReturnSearchResults = arrReturnSearchResults.concat(arrResultSlice); - intSearchIndex = arrReturnSearchResults.length; - } - while (arrResultSlice.length >= intMaxResults); + while (arrResultSlice.length >= intMaxResults); - return arrReturnSearchResults; - }; - return exports; - }); \ No newline at end of file + return arrReturnSearchResults; + }; + return exports; + }); \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js index c713c45..d24dd44 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js @@ -24,7 +24,7 @@ define([ try { log.audit('getInputData', '** START **'); //todo build search in getinput instead of param? - var stSalesOrderSearchID = runtime.getCurrentScript().getParameter('custscript_ext_so_search'); + var stSalesOrderSearchID = runtime.getCurrentScript().getParameter('custscript_ext_order_search'); log.debug('stSalesOrderSearchID', stSalesOrderSearchID); var salesOrderSearch = search.load({ @@ -49,7 +49,6 @@ define([ id: stSalesOrderId }); // Get Extend Details from Sales Order - log.audit('reduce: SO Data to Extend Object', objExtendData); objExtendData = EXTEND_UTIL.createExtendOrder(objSalesOrderRecord); } catch (e) { diff --git a/com.extend.extendproductprotection/src/deploy.xml b/com.extend.extendproductprotection/src/deploy.xml index 235c594..3e6c925 100644 --- a/com.extend.extendproductprotection/src/deploy.xml +++ b/com.extend.extendproductprotection/src/deploy.xml @@ -3,7 +3,7 @@ ~/FileCabinet/SuiteApps/com.extend.extendproductprotection/* - ~/Objects/* + ~/Objects/Fields/* ~/Translations/* From e2a087c2bb4bcb8a6d6738f23e34aa93236c5fc2 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Thu, 16 Jun 2022 09:06:11 -0500 Subject: [PATCH 06/33] typo fix --- .../lib/customscript_ext_util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 0c44f2c..5d8c9fd 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -44,7 +44,7 @@ define([ //handle response if (objExtendResponse.code === 201) { var objExtendResponseBody = JSON.parse(objExtendResponse.body); - EXTEND_API.handleResponse(objExtendResponseBody, objSalesOrderRecord); + exports.handleResponse(objExtendResponseBody, objSalesOrderRecord); } else { log.error('EXTEND UTIL _createExtendContracts', objExtendResponse); objSalesOrderRecord.setValue({ fieldId: 'custbody_ext_process_error', value: true }); From 7c0855701dda047d7361bf23091deb900e4748b4 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Thu, 16 Jun 2022 09:25:24 -0500 Subject: [PATCH 07/33] order creation --- .../lib/customscript_ext_util.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 5d8c9fd..ce51d6d 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -60,13 +60,15 @@ define([ objSalesOrderRecord.save(); }; - exports.handleResponse = function (objExtendResponse, objSalesOrderRecord) { + exports.handleResponse = function (objExtendResponseBody, objSalesOrderRecord) { log.debug('EXTEND UTIL _createExtendOrder: Extend Response Body Parsed: ', objExtendResponseBody); var arrLineItems = objExtendResponseBody.lineItems; var objExtendResponseData = {}; for (var i = 0; i < arrLineItems.length; i++) { + objExtendResponseData[i] = {} + objExtendResponseData[i].contractIds = []; log.debug('EXTEND UTIL _createExtendOrder: arrLineItems: ', arrLineItems[i]); var line = arrLineItems[i].lineItemTransactionId; line = line.substring(objSalesOrderRecord.id.toString().length, line.length); @@ -81,13 +83,18 @@ define([ log.debug('EXTEND UTIL _createExtendOrder: contractid arrLineItems: ', arrLineItems[i].contractId); arrContractIds.push(arrLineItems[i].contractId) objExtendResponseData[stUniqueKey].contractIds = arrContractIds; + } + } + for(key in objExtendResponseData){ + log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData[key].contractIds: ', objExtendResponseData[key].contractIds); - // If Extend contract is created, populate the appropriate custom column field for contracts + // If Extend contract is created, populate the appropriate custom column field for contracts // on the Sales Order line - // objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: line, value: JSON.stringify(arrContractIds) }); - - } + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: key, value: JSON.stringify(objExtendResponseData[key].contractIds) }); + } + return objSalesOrderRecord; + }; //get Sales Order Info required for contract create exports.getSalesOrderInfo = function (objSalesOrderRecord) { From 3e8a3ae79e73d893d91fa1e4e8d0542dfdee01c0 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Tue, 21 Jun 2022 09:07:34 -0500 Subject: [PATCH 08/33] fulfillment mr --- .../lib/customscript_ext_util.js | 665 +++++++++--------- .../customscript_ext_fulfill_order_mr.js | 100 +++ 2 files changed, 439 insertions(+), 326 deletions(-) create mode 100644 com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index ce51d6d..8aa51be 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -44,7 +44,10 @@ define([ //handle response if (objExtendResponse.code === 201) { var objExtendResponseBody = JSON.parse(objExtendResponse.body); - exports.handleResponse(objExtendResponseBody, objSalesOrderRecord); + exports.handleOrderResponse(objExtendResponseBody, objSalesOrderRecord); + //make SO as extend order created + objSalesOrderRecord.setValue({ fieldId: 'custbody_ext_order_create', value: true }); + } else { log.error('EXTEND UTIL _createExtendContracts', objExtendResponse); objSalesOrderRecord.setValue({ fieldId: 'custbody_ext_process_error', value: true }); @@ -60,12 +63,18 @@ define([ objSalesOrderRecord.save(); }; - exports.handleResponse = function (objExtendResponseBody, objSalesOrderRecord) { + //fulfill items on order + exports.fulfillExtendOrder = function () { + + }; + /***********************************Support Functions********************************************/ + + exports.handleOrderResponse = function (objExtendResponseBody, objSalesOrderRecord) { log.debug('EXTEND UTIL _createExtendOrder: Extend Response Body Parsed: ', objExtendResponseBody); var arrLineItems = objExtendResponseBody.lineItems; var objExtendResponseData = {}; - + for (var i = 0; i < arrLineItems.length; i++) { objExtendResponseData[i] = {} objExtendResponseData[i].contractIds = []; @@ -75,7 +84,6 @@ define([ log.debug('EXTEND UTIL _createExtendOrder: line: ', line + '|' + typeof line); stUniqueKey = line; - if (arrLineItems[i].type == 'contract') { var arrContractIds = []; arrContractIds = objExtendResponseData[stUniqueKey].contractIds; @@ -85,366 +93,371 @@ define([ objExtendResponseData[stUniqueKey].contractIds = arrContractIds; } } - for(key in objExtendResponseData){ + for (key in objExtendResponseData) { log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData[key].contractIds: ', objExtendResponseData[key].contractIds); - // If Extend contract is created, populate the appropriate custom column field for contracts - // on the Sales Order line - objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: key, value: JSON.stringify(objExtendResponseData[key].contractIds) }); - + // If Extend contract is created, populate the appropriate custom column field for contracts + // on the Sales Order line + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: key, value: JSON.stringify(objExtendResponseData[key].contractIds) }); + } return objSalesOrderRecord; - + + }; + //get Sales Order Info required for contract create + exports.getSalesOrderInfo = function (objSalesOrderRecord) { + log.debug('EXTEND UTIL _getSalesOrderInfo:', '**ENTER**'); + var objExtendData = {}; + log.debug('EXTEND UTIL _getSalesOrderInfo: ExtendData Object', objExtendData); + var objCustomerInfo = exports.getCustomerInfo(objSalesOrderRecord.getValue({ fieldId: 'entity' })); + var objShipAddress = exports.getAddress(objSalesOrderRecord, 'shippingaddress'); + var objBillAddress = exports.getAddress(objSalesOrderRecord, 'billingaddress'); + //Build SO Info Object + objExtendData.id = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); + objExtendData.tran_date = exports.getepochDate(); + objExtendData.currency = 'USD'; + objExtendData.order_number = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); + objExtendData.total_amount = objSalesOrderRecord.getValue({ fieldId: 'total' }); + objExtendData.name = objSalesOrderRecord.getText({ fieldId: 'entity' }).replace(/[0-9]/g, ''); + objExtendData.email = objCustomerInfo.email; + objExtendData.phone = objCustomerInfo.phone; + objExtendData.bill_address1 = objBillAddress.address1; + objExtendData.bill_address2 = objBillAddress.address2; + objExtendData.bill_city = objBillAddress.city; + objExtendData.bill_state = objBillAddress.state; + objExtendData.bill_zip = objBillAddress.zip; + objExtendData.bill_country = objBillAddress.country; + objExtendData.ship_address1 = objShipAddress.address1; + objExtendData.ship_address2 = objShipAddress.address2; + objExtendData.ship_city = objShipAddress.city; + objExtendData.ship_state = objShipAddress.state; + objExtendData.ship_zip = objShipAddress.zip; + objExtendData.ship_country = objShipAddress.country; + return objExtendData; }; - //get Sales Order Info required for contract create - exports.getSalesOrderInfo = function (objSalesOrderRecord) { - log.debug('EXTEND UTIL _getSalesOrderInfo:', '**ENTER**'); - var objExtendData = {}; - log.debug('EXTEND UTIL _getSalesOrderInfo: ExtendData Object', objExtendData); - var objCustomerInfo = exports.getCustomerInfo(objSalesOrderRecord.getValue({ fieldId: 'entity' })); - var objShipAddress = exports.getAddress(objSalesOrderRecord, 'shippingaddress'); - var objBillAddress = exports.getAddress(objSalesOrderRecord, 'billingaddress'); - //Build SO Info Object - objExtendData.id = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); - objExtendData.tran_date = exports.getepochDate(); - objExtendData.currency = 'USD'; - objExtendData.order_number = objSalesOrderRecord.getValue({ fieldId: 'tranid' }); - objExtendData.total_amount = objSalesOrderRecord.getValue({ fieldId: 'total' }); - objExtendData.name = objSalesOrderRecord.getText({ fieldId: 'entity' }).replace(/[0-9]/g, ''); - objExtendData.email = objCustomerInfo.email; - objExtendData.phone = objCustomerInfo.phone; - objExtendData.bill_address1 = objBillAddress.address1; - objExtendData.bill_address2 = objBillAddress.address2; - objExtendData.bill_city = objBillAddress.city; - objExtendData.bill_state = objBillAddress.state; - objExtendData.bill_zip = objBillAddress.zip; - objExtendData.bill_country = objBillAddress.country; - objExtendData.ship_address1 = objShipAddress.address1; - objExtendData.ship_address2 = objShipAddress.address2; - objExtendData.ship_city = objShipAddress.city; - objExtendData.ship_state = objShipAddress.state; - objExtendData.ship_zip = objShipAddress.zip; - objExtendData.ship_country = objShipAddress.country; - return objExtendData; - }; - exports.getAddress = function (objSalesOrderRecord, addressField) { - var address = objSalesOrderRecord.getSubrecord({ - fieldId: addressField - }); - var objAddress = { - address1: address.getValue({ - fieldId: 'addr1' - }), - address2: address.getValue({ - fieldId: 'addr2' - }), - city: address.getValue({ - fieldId: 'city' - }), - state: address.getValue({ - fieldId: 'state' - }), - country: address.getValue({ - fieldId: 'country' - }), - zip: address.getValue({ - fieldId: 'zip' - }) - }; - return objAddress; - } - exports.getItemRefId = function (stItemId) { - var config = EXTEND_CONFIG.getConfig(); - var refIdValue = config.refId; - var stItemRefId = stItemId; - if (refIdValue) { - // Lookup to item to see if it is eligible for warranty offers - var arrItemLookup = search.lookupFields({ - type: 'item', - id: stItemId, - columns: refIdValue - }); - for (var prop in arrItemLookup) { - var stItemRefId = arrItemLookup[prop] - break; - } - } - return stItemRefId; - } - //get Transaction Date required for contract create - exports.getTransactionDate = function (stDate) { - var stTimeDate = new Date(stDate); - return stTimeDate.getTime() / 1000; - }; - //get Current Date in epoch format required for contract create - exports.getepochDate = function () { - var stTimeDate = new Date(); - return stTimeDate.getTime(); - }; - //get Customer Info required for contract create - exports.getCustomerInfo = function (stCustomerId) { - var objCustomerRecord = record.load({ - type: 'customer', - id: stCustomerId - }); - var objCustomerInfo = { - "email": objCustomerRecord.getValue({ fieldId: 'email' }), - "phone": objCustomerRecord.getValue({ fieldId: 'phone' }), - "bill_address1": objCustomerRecord.getValue({ fieldId: 'billaddr1' }), - "bill_address2": objCustomerRecord.getValue({ fieldId: 'billaddr2' }), - "bill_city": objCustomerRecord.getValue({ fieldId: 'billcity' }), - "bill_state": objCustomerRecord.getValue({ fieldId: 'billstate' }), - "bill_zip": objCustomerRecord.getValue({ fieldId: 'billzip' }), - "bill_country": "US", - "ship_address1": objCustomerRecord.getValue({ fieldId: 'shipaddr1' }), - "ship_address2": objCustomerRecord.getValue({ fieldId: 'shipaddr2' }), - "ship_city": objCustomerRecord.getValue({ fieldId: 'shipcity' }), - "ship_state": objCustomerRecord.getValue({ fieldId: 'shipstate' }), - "ship_zip": objCustomerRecord.getValue({ fieldId: 'shipzip' }), - "ship_country": "US", - } - return objCustomerInfo; - }; - //get Item Purchase Price - exports.getPurchasePrice = function (stItemId) { - var arrFilters = []; - arrFilters.push(search.createFilter({ name: 'internalid', operator: 'is', values: [stItemId] })); - var arrColumns = []; - arrColumns.push(search.createColumn({ name: 'baseprice' })); - - var arrSearchResults = exports.search('item', null, arrFilters, arrColumns); - var stPurchasePrice; - if (arrSearchResults.length) { - stPurchasePrice = arrSearchResults[0].getValue({ name: 'baseprice' }); + exports.getSalesOrderItemInfo = function (objSalesOrderRecord) { + //////////////////////////SUPPORT FUNCTIONS/////////////////////////// + var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); + + log.debug('EXTEND UTIL _createExtendOrder: Line Count', stLineCount); + log.debug('_getExtendData: Get Extend Data', '**ENTER**'); + + var objExtendItemData = {}; + + var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + for (var i = 0; i < stLineCount; i++) { + var stItemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); + stUniqueKey = i; + if (stExtendItemId !== stItemId) { + objExtendItemData[stUniqueKey] = {}; } - return stPurchasePrice; - }; - exports.getSalesOrderItemInfo = function (objSalesOrderRecord) { - //////////////////////////SUPPORT FUNCTIONS/////////////////////////// - var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); + //Check if item is one of the configured extend items + if (stExtendItemId === stItemId) { + log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); - log.debug('EXTEND UTIL _createExtendOrder: Line Count', stLineCount); - log.debug('_getExtendData: Get Extend Data', '**ENTER**'); + //get related item from extend line + var stExtendItemRefId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + for (var j = 0; j < stLineCount; j++) { + var stRelatedItem = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); + if (stRelatedItem === stExtendItemRefId) { + log.debug('_getExtendData: stRelatedItem| stExtendItemRefId ', stRelatedItem + ' | ' + stExtendItemRefId); - var objExtendItemData = {}; + stUniqueKey = j; + // Start building the Extend Order Plan Info Object + objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); + objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; + objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); + objExtendItemData[stUniqueKey].extend_line = i; - var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); - for (var i = 0; i < stLineCount; i++) { - var stItemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); - stUniqueKey = i; - if (stExtendItemId !== stItemId) { - objExtendItemData[stUniqueKey] = {}; - } - //Check if item is one of the configured extend items - if (stExtendItemId === stItemId) { - log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); - - //get related item from extend line - var stExtendItemRefId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - for (var j = 0; j < stLineCount; j++) { - var stRelatedItem = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); - if (stRelatedItem === stExtendItemRefId) { - log.debug('_getExtendData: stRelatedItem| stExtendItemRefId ', stRelatedItem + ' | ' + stExtendItemRefId); - - stUniqueKey = j; - // Start building the Extend Order Plan Info Object - objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); - objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; - objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); - - } } - } else { - // Start building the Extend Order Item Info Object - objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); - objExtendItemData[stUniqueKey].itemId = stItemId - objExtendItemData[stUniqueKey].line = i; - objExtendItemData[stUniqueKey].purchase_price = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); - objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + i; } + } else { + // Start building the Extend Order Item Info Object + objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); + objExtendItemData[stUniqueKey].itemId = stItemId + objExtendItemData[stUniqueKey].line = i; + objExtendItemData[stUniqueKey].purchase_price = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); + objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + i; + } + } + return objExtendItemData; + }; + exports.buildExtendItemJSON = function (objValues) { + //item json + var lineItems = []; + for (key in objValues) { + //get product refId + objValues.refId = exports.getItemRefId(objValues[key].itemId); + var item = { + 'product': { + 'id': objValues.refId, + // 'serialNumber': objValues.serial_number, + 'purchasePrice': parseInt(objValues[key].purchase_price * 100) + }, + 'quantity': objValues[key].quantity, + 'lineItemTransactionId': objValues[key].lineItemID } - return objExtendItemData; - }; - exports.buildExtendItemJSON = function (objValues) { - //item json - var lineItems = []; - for (key in objValues) { - //get product refId - objValues.refId = exports.getItemRefId(objValues[key].itemId); - var item = { - 'product': { - 'id': objValues.refId, - // 'serialNumber': objValues.serial_number, - 'purchasePrice': parseInt(objValues[key].purchase_price * 100) - }, - 'quantity': objValues[key].quantity, - 'lineItemTransactionId': objValues[key].lineItemID + if (objValues[key].extend_plan_id && objValues[key].plan_price) { + item.plan = { + 'id': objValues[key].extend_plan_id, + 'purchasePrice': objValues[key].plan_price } - if (objValues[key].extend_plan_id && objValues[key].plan_price) { - item.plan = { - 'id': objValues[key].extend_plan_id, - 'purchasePrice': objValues[key].plan_price - } - } - lineItems.push(item); - - } - log.debug('_buildExtendItemJSON: lineItems', lineItems); + lineItems.push(item); - return lineItems; - }; - // Build the Extend API JSON for contract creation - exports.buildExtendOrderJSON = function (objValues) { - log.debug('EXTEND UTIL _buildExtendOrderJSON:', '**ENTER**'); - // Date is a string and we need to format for extend - const stTranDate = new Date(objValues.tran_date); + } + log.debug('_buildExtendItemJSON: lineItems', lineItems); - //If Demo use demo email for contracts - var config = EXTEND_CONFIG.getConfig(); - if (config.email) { - objValues.email = config.email; - } + return lineItems; + }; + // Build the Extend API JSON for contract creation + exports.buildExtendOrderJSON = function (objValues) { + log.debug('EXTEND UTIL _buildExtendOrderJSON:', '**ENTER**'); - var objJSON = { - 'currency': objValues.currency, - 'customer': { - 'email': objValues.email, - 'name': objValues.name, - 'phone': objValues.phone, - 'billingAddress': { - 'address1': objValues.bill_address1, - 'address2': objValues.bill_address2, - 'city': objValues.bill_city, - 'postalCode': objValues.bill_zip, - 'countryCode': objValues.bill_country, - 'province': objValues.bill_state, - }, - 'shippingAddress': { - 'address1': objValues.ship_address1, - 'address2': objValues.ship_address2, - 'city': objValues.ship_city, - 'postalCode': objValues.ship_zip, - 'countryCode': objValues.ship_country, - 'province': objValues.ship_state + // Date is a string and we need to format for extend + const stTranDate = new Date(objValues.tran_date); - } + //If Demo use demo email for contracts + var config = EXTEND_CONFIG.getConfig(); + if (config.email) { + objValues.email = config.email; + } + + var objJSON = { + 'currency': objValues.currency, + 'customer': { + 'email': objValues.email, + 'name': objValues.name, + 'phone': objValues.phone, + 'billingAddress': { + 'address1': objValues.bill_address1, + 'address2': objValues.bill_address2, + 'city': objValues.bill_city, + 'postalCode': objValues.bill_zip, + 'countryCode': objValues.bill_country, + 'province': objValues.bill_state, }, - 'storeId': config.storeId, - 'lineItems': objValues.lineItems, - 'total': parseInt(objValues.total_amount * 100), - 'transactionId': objValues.id, - } + 'shippingAddress': { + 'address1': objValues.ship_address1, + 'address2': objValues.ship_address2, + 'city': objValues.ship_city, + 'postalCode': objValues.ship_zip, + 'countryCode': objValues.ship_country, + 'province': objValues.ship_state - return objJSON; - }; - /** - * Performs empty validations - */ - exports.objectIsEmpty = function (obj) { - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) - return false; - } - return true; - }; - exports.stringIsEmpty = function (stValue) { - if ((stValue == '') || (stValue == null) || (stValue == undefined)) { - return true; - } - return false; + } + }, + 'storeId': config.storeId, + 'lineItems': objValues.lineItems, + 'total': parseInt(objValues.total_amount * 100), + 'transactionId': objValues.id, + } + + return objJSON; + }; + /***********************************Support Functions********************************************/ + //get Address Subrecord fields from transaction + exports.getAddress = function (objSalesOrderRecord, addressField) { + var address = objSalesOrderRecord.getSubrecord({ + fieldId: addressField + }); + var objAddress = { + address1: address.getValue({ + fieldId: 'addr1' + }), + address2: address.getValue({ + fieldId: 'addr2' + }), + city: address.getValue({ + fieldId: 'city' + }), + state: address.getValue({ + fieldId: 'state' + }), + country: address.getValue({ + fieldId: 'country' + }), + zip: address.getValue({ + fieldId: 'zip' + }) }; - /** - * Createa Custom Error Object - */ - exports.createError = function (objErrorDetails) { - var objCustomError = error.create({ - name: objErrorDetails.title, - message: objErrorDetails.message, - notifyOff: true + return objAddress; + } + //get Item's reference ID + exports.getItemRefId = function (stItemId) { + var config = EXTEND_CONFIG.getConfig(); + var refIdValue = config.refId; + var stItemRefId = stItemId; + if (refIdValue) { + // Lookup to item to see if it is eligible for warranty offers + var arrItemLookup = search.lookupFields({ + type: 'item', + id: stItemId, + columns: refIdValue }); - return objCustomError; - }; - - /** - * Performs search with no size limitations - */ - exports.search = function (stRecordType, stSearchId, arrSearchFilter, arrSearchColumn, bUseFilterExpressions, arrSearchSetting) { - if (!stRecordType && !stSearchId) { - throw 'search: Missing a required argument. Either stRecordType or stSearchId should be provided.'; + for (var prop in arrItemLookup) { + var stItemRefId = arrItemLookup[prop] + break; } + } - var arrReturnSearchResults = []; - var objSavedSearch; - var intMaxResults = 1000; - if (stSearchId) { - objSavedSearch = search.load({ - id: stSearchId - }); - } - else { - objSavedSearch = search.create({ - type: stRecordType - }); - } + return stItemRefId; + } + //get Transaction Date required for contract create + exports.getTransactionDate = function (stDate) { + var stTimeDate = new Date(stDate); + return stTimeDate.getTime() / 1000; + }; + //get Current Date in epoch format required for contract create + exports.getepochDate = function () { + var stTimeDate = new Date(); + return stTimeDate.getTime(); + }; + //get Customer Info required for contract create + exports.getCustomerInfo = function (stCustomerId) { + var objCustomerRecord = record.load({ + type: 'customer', + id: stCustomerId + }); + var objCustomerInfo = { + "email": objCustomerRecord.getValue({ fieldId: 'email' }), + "phone": objCustomerRecord.getValue({ fieldId: 'phone' }), + "bill_address1": objCustomerRecord.getValue({ fieldId: 'billaddr1' }), + "bill_address2": objCustomerRecord.getValue({ fieldId: 'billaddr2' }), + "bill_city": objCustomerRecord.getValue({ fieldId: 'billcity' }), + "bill_state": objCustomerRecord.getValue({ fieldId: 'billstate' }), + "bill_zip": objCustomerRecord.getValue({ fieldId: 'billzip' }), + "bill_country": "US", + "ship_address1": objCustomerRecord.getValue({ fieldId: 'shipaddr1' }), + "ship_address2": objCustomerRecord.getValue({ fieldId: 'shipaddr2' }), + "ship_city": objCustomerRecord.getValue({ fieldId: 'shipcity' }), + "ship_state": objCustomerRecord.getValue({ fieldId: 'shipstate' }), + "ship_zip": objCustomerRecord.getValue({ fieldId: 'shipzip' }), + "ship_country": "US", + } + return objCustomerInfo; + }; + //get Item Purchase Price + exports.getPurchasePrice = function (stItemId) { + var arrFilters = []; + arrFilters.push(search.createFilter({ name: 'internalid', operator: 'is', values: [stItemId] })); + var arrColumns = []; + arrColumns.push(search.createColumn({ name: 'baseprice' })); - // add search filter if one is passed - if (arrSearchFilter) { - //Use Filter Expressions if that option has been enabled - if (bUseFilterExpressions) { - if (stSearchId) { - objSavedSearch.filterExpression = objSavedSearch.filters.concat(arrSearchFilter); - } - else { - objSavedSearch.filterExpression = arrSearchFilter; - } - } - else { - if (stSearchId) { - objSavedSearch.filters = objSavedSearch.filters.concat(arrSearchFilter); - } - else { - objSavedSearch.filters = arrSearchFilter; - } - } - } - // add search column if one is passed - if (arrSearchColumn) { + var arrSearchResults = exports.search('item', null, arrFilters, arrColumns); + var stPurchasePrice; + if (arrSearchResults.length) { + stPurchasePrice = arrSearchResults[0].getValue({ name: 'baseprice' }); + } + return stPurchasePrice; + }; + /***********************************Support Functions********************************************/ + /** + * Performs empty validations + */ + exports.objectIsEmpty = function (obj) { + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) + return false; + } + return true; + }; + exports.stringIsEmpty = function (stValue) { + if ((stValue == '') || (stValue == null) || (stValue == undefined)) { + return true; + } + return false; + }; + /** + * Createa Custom Error Object + */ + exports.createError = function (objErrorDetails) { + var objCustomError = error.create({ + name: objErrorDetails.title, + message: objErrorDetails.message, + notifyOff: true + }); + return objCustomError; + }; + /** + * Performs search with no size limitations + */ + exports.search = function (stRecordType, stSearchId, arrSearchFilter, arrSearchColumn, bUseFilterExpressions, arrSearchSetting) { + if (!stRecordType && !stSearchId) { + throw 'search: Missing a required argument. Either stRecordType or stSearchId should be provided.'; + } + + var arrReturnSearchResults = []; + var objSavedSearch; + var intMaxResults = 1000; + if (stSearchId) { + objSavedSearch = search.load({ + id: stSearchId + }); + } + else { + objSavedSearch = search.create({ + type: stRecordType + }); + } + + // add search filter if one is passed + if (arrSearchFilter) { + //Use Filter Expressions if that option has been enabled + if (bUseFilterExpressions) { if (stSearchId) { - objSavedSearch.columns = objSavedSearch.columns.concat(arrSearchColumn); + objSavedSearch.filterExpression = objSavedSearch.filters.concat(arrSearchFilter); } else { - objSavedSearch.columns = arrSearchColumn; + objSavedSearch.filterExpression = arrSearchFilter; } } - // add search settings if one is passed - if (arrSearchSetting && arrSearchSetting.length > 0) { + else { if (stSearchId) { - objSavedSearch.settings = objSavedSearch.columns.concat(arrSearchSetting); + objSavedSearch.filters = objSavedSearch.filters.concat(arrSearchFilter); } else { - objSavedSearch.settings = arrSearchSetting; + objSavedSearch.filters = arrSearchFilter; } } + } + // add search column if one is passed + if (arrSearchColumn) { + if (stSearchId) { + objSavedSearch.columns = objSavedSearch.columns.concat(arrSearchColumn); + } + else { + objSavedSearch.columns = arrSearchColumn; + } + } + // add search settings if one is passed + if (arrSearchSetting && arrSearchSetting.length > 0) { + if (stSearchId) { + objSavedSearch.settings = objSavedSearch.columns.concat(arrSearchSetting); + } + else { + objSavedSearch.settings = arrSearchSetting; + } + } - var objResultSet = objSavedSearch.run(); - var intSearchIndex = 0; - var arrResultSlice = null; - do { - arrResultSlice = objResultSet.getRange(intSearchIndex, intSearchIndex + intMaxResults); - if (arrResultSlice == null) { - break; - } - arrReturnSearchResults = arrReturnSearchResults.concat(arrResultSlice); - intSearchIndex = arrReturnSearchResults.length; + var objResultSet = objSavedSearch.run(); + var intSearchIndex = 0; + var arrResultSlice = null; + do { + arrResultSlice = objResultSet.getRange(intSearchIndex, intSearchIndex + intMaxResults); + if (arrResultSlice == null) { + break; } - while (arrResultSlice.length >= intMaxResults); + arrReturnSearchResults = arrReturnSearchResults.concat(arrResultSlice); + intSearchIndex = arrReturnSearchResults.length; + } + while (arrResultSlice.length >= intMaxResults); - return arrReturnSearchResults; - }; - return exports; - }); \ No newline at end of file + return arrReturnSearchResults; + }; + return exports; + }); \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js new file mode 100644 index 0000000..baf8ab7 --- /dev/null +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js @@ -0,0 +1,100 @@ +/** + *@name: EXTEND SUITESCRIPT SDK - Create Contract from Fulfillment JS + *@description: + * This script invokes a call to the Extend Contracts POST endpoint whenever + * an item with a protection plan is fulfilled + * + *@copyright Extend, Inc + *@author Michael Draper + * + *@NApiVersion 2.x + *@NScriptType MapReduceScript + *@ModuleScope Public + */ + define([ + 'N/runtime', + 'N/record', + 'N/search', + '../lib/customscript_ext_util' +], + function (runtime, record, search, EXTEND_UTIL) { + var exports = {}; + + exports.getInputData = function () { + try { + log.audit('getInputData', '** START **'); + //todo build search in getinput instead of param? + var stFulfillmentSearchID = runtime.getCurrentScript().getParameter('custscript_ext_fulfill_search'); + + log.debug('stFulfillmentSearchID', stFulfillmentSearchID); + var fulfillmentSearch = search.load({ + id: stFulfillmentSearchID + }); + + return fulfillmentSearch; + + } catch (e) { + log.error('getInputData', 'error: ' + e); + } + } + exports.reduce = function (context) { + try { + log.debug('reduce', '** START **'); + + var stFulfillmentId = context.key; + log.audit('reduce', 'stFulfillmentId: ' + stFulfillmentId); + //Load associated Saled Order Record + var objFulfillmentRecord = record.load({ + type: record.Type.ITEM_FULFILLMENT, + id: stFulfillmentId + }); + // Get Extend Details from Sales Order + objExtendData = EXTEND_UTIL.fulfillExtendOrder(objFulfillmentRecord); + + } catch (e) { + log.error('reduce', 'key: ' + context.key + ' error: ' + e); + record.submitFields({ + type: record.Type.ITEM_FULFILLMENT, + id: stFulfillmentId, + values: { + 'custbody_ext_process_error': true + }, + options: { + enableSourcing: false, + ignoreMandatoryFields: true + } + }); + // create user note attached to record + var objNoteRecord = record.create({ + type: record.Type.NOTE, + }) + objNoteRecord.setValue('transaction', stFulfillmentId); + objNoteRecord.setValue('title', 'Extend Error Order Create'); + objNoteRecord.setValue('note', JSON.stringify(e.message)); + var stNoteId = objNoteRecord.save(); + log.debug('reduce', 'stNoteId: ' + stNoteId); + + } + } + exports.summarize = function (summary) { + log.audit('summarize', '** START **'); + try { + var mapKeys = []; + summary.mapSummary.keys.iterator().each(function (key) { + mapKeys.push(key); + return true; + }); + if (mapKeys.length < 1) { + log.debug('summarize', 'No results were processed'); + } + log.debug('summarize', JSON.stringify(summary)); + + } catch (e) { + log.error('summarize', 'error: ' + e); + } + } + + + + return exports; + }); From f0cdb562960fa7fd388f487be42d9fce5574a60c Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Thu, 3 Nov 2022 07:03:52 -0500 Subject: [PATCH 09/33] updates to util for fulfillment --- .gitignore | 1 + .../lib/customscript_ext_api_lib.js | 4 +- .../lib/customscript_ext_util.js | 84 ++++++++++++++++--- .../customscript_ext_fulfill_order_mr.js | 1 + .../custbody_ext_process_error.xml | 0 .../custcol_ext_associated_item.xml | 0 .../{ => Fields}/custcol_ext_contract_id.xml | 0 .../{ => Fields}/custcol_ext_plan_id.xml | 0 .../{ => Fields}/custcol_ext_plan_term.xml | 0 .../customlist_ext_environment.xml | 0 .../customrecord_ext_configuration.xml | 0 .../customscript_ext_config_validate_ue.xml | 0 .../customscript_ext_create_contract_mr.xml | 0 .../customscript_ext_offer_modal_ue.xml | 0 ...customscript_ext_offer_presentation_sl.xml | 0 ...ustomscript_ext_so_offer_controller_cs.xml | 0 .../customsearch_ext_contract_create.xml | 0 .../src/Objects/custbody_ext_order_create.xml | 61 ++++++++++++++ .../src/Objects/custcol_ext_lead_token.xml | 53 ++++++++++++ .../src/Objects/custcol_ext_so_line.xml | 53 ++++++++++++ .../src/Objects/custitem_ext_item_ref_id.xml | 51 +++++++++++ .../customscript_ext_create_order_mr.xml | 59 +++++++++++++ .../customscript_ext_fulfill_order_mr.xml | 59 +++++++++++++ .../Objects/customsearch_ext_order_create.xml | 7 ++ .../src/deploy.xml | 2 +- .../src/manifest.xml | 1 + 26 files changed, 422 insertions(+), 14 deletions(-) create mode 100644 .gitignore rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custbody_ext_process_error.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_associated_item.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_contract_id.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_plan_id.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_plan_term.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/customlist_ext_environment.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/customrecord_ext_configuration.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/customscript_ext_config_validate_ue.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/customscript_ext_create_contract_mr.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/customscript_ext_offer_modal_ue.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/customscript_ext_offer_presentation_sl.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/customscript_ext_so_offer_controller_cs.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/customsearch_ext_contract_create.xml (100%) create mode 100644 com.extend.extendproductprotection/src/Objects/custbody_ext_order_create.xml create mode 100644 com.extend.extendproductprotection/src/Objects/custcol_ext_lead_token.xml create mode 100644 com.extend.extendproductprotection/src/Objects/custcol_ext_so_line.xml create mode 100644 com.extend.extendproductprotection/src/Objects/custitem_ext_item_ref_id.xml create mode 100644 com.extend.extendproductprotection/src/Objects/customscript_ext_create_order_mr.xml create mode 100644 com.extend.extendproductprotection/src/Objects/customscript_ext_fulfill_order_mr.xml create mode 100644 com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js index 4bbaa28..7e8db3b 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js @@ -216,11 +216,11 @@ * UPDATE ORDER LINE FULFILLMENT * API Documentation: https://docs.extend.com/reference/lineitemsfulfill */ - exports.fulfillOrderLine = function (objOrderDetails, stLineItemId) { + exports.fulfillOrderLine = function (objOrderDetails) { var config = extendConfig.getConfig(); try { var response = https.post({ - url: config.domain + '/line-items/' + stLineItemId + '/fulfill', + url: config.domain + '/line-items/fulfill', headers: { 'Content-Type': 'application/json', 'X-Extend-Access-Token': config.key, diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 8aa51be..fe2c983 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -64,7 +64,41 @@ define([ objSalesOrderRecord.save(); }; //fulfill items on order - exports.fulfillExtendOrder = function () { + exports.fulfillExtendOrder = function (objFulfillmentRecord) { + + for (key in objExtendData) { + //build fulfillment json obj + var objExtendFulfillRequestJSON = {}; + objExtendFulfillRequestJSON = exports.buildExtendFulfillJSON(objExtendData[key]); + log.audit('EXTEND UTIL _fulfillExtendOrder: objExtendOrderRequestJSON', objExtendFulfillRequestJSON); + // Create contract call for quantity fulfilled on the Extend item + for (var i = 0; i < objExtendData[key].quantity; i++) { + + //call api + var objExtendResponse = EXTEND_API.fulfillOrderLine(objExtendFulfillRequestJSON); + log.audit('EXTEND UTIL _fulfillExtendOrder: Extend Response Object: ', objExtendResponse); + //handle response + if (objExtendResponse.code === 201) { + var objExtendResponseBody = JSON.parse(objExtendResponse.body); + exports.handleOrderResponse(objExtendResponseBody, objFulfillmentRecord); + //make SO as extend order created + objFulfillmentRecord.setValue({ fieldId: 'custbody_ext_order_create', value: true }); + + } else { + log.error('EXTEND UTIL _fulfillExtendOrder', objExtendResponse); + objFulfillmentRecord.setValue({ fieldId: 'custbody_ext_process_error', value: true }); + // create user note attached to record + var objNoteRecord = record.create({ + type: record.Type.NOTE, + }) + objNoteRecord.setValue('transaction', objFulfillmentRecord.id); + objNoteRecord.setValue('title', 'Extend Order Create Error'); + objNoteRecord.setValue('note', JSON.stringify(objExtendResponse)); + var stNoteId = objNoteRecord.save(); + } + } + } + objFulfillmentRecord.save(); }; /***********************************Support Functions********************************************/ @@ -76,29 +110,47 @@ define([ var objExtendResponseData = {}; for (var i = 0; i < arrLineItems.length; i++) { - objExtendResponseData[i] = {} - objExtendResponseData[i].contractIds = []; log.debug('EXTEND UTIL _createExtendOrder: arrLineItems: ', arrLineItems[i]); var line = arrLineItems[i].lineItemTransactionId; line = line.substring(objSalesOrderRecord.id.toString().length, line.length); log.debug('EXTEND UTIL _createExtendOrder: line: ', line + '|' + typeof line); stUniqueKey = line; + objExtendResponseData[stUniqueKey] = {} + objExtendResponseData[stUniqueKey].contractIds = []; + objExtendResponseData[stUniqueKey].leadTokens = []; if (arrLineItems[i].type == 'contract') { var arrContractIds = []; arrContractIds = objExtendResponseData[stUniqueKey].contractIds; log.debug('EXTEND UTIL _createExtendOrder: arrContractIds: ', arrContractIds); log.debug('EXTEND UTIL _createExtendOrder: contractid arrLineItems: ', arrLineItems[i].contractId); - arrContractIds.push(arrLineItems[i].contractId) + if (arrLineItems[i].contractId) { + arrContractIds.push(arrLineItems[i].contractId) + } objExtendResponseData[stUniqueKey].contractIds = arrContractIds; } + if (arrLineItems[i].type == 'lead') { + var arrLeadIds = []; + arrLeadIds = objExtendResponseData[stUniqueKey].leadTokens; + log.debug('EXTEND UTIL _createExtendOrder: arrLeadIds: ', arrLeadIds); + log.debug('EXTEND UTIL _createExtendOrder: contractid arrLineItems: ', arrLineItems[i].leadToken); + if (arrLineItems[i].leadToken) { + arrLeadIds.push(arrLineItems[i].leadToken) + } + objExtendResponseData[stUniqueKey].leadTokens = arrLeadIds; + } } + log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData', objExtendResponseData); + for (key in objExtendResponseData) { - log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData[key].contractIds: ', objExtendResponseData[key].contractIds); + log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData[key].contractIds: ', key + '|' + objExtendResponseData[key].contractIds); + log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData[key].leadTokens: ', key + '|' + objExtendResponseData[key].leadTokens); // If Extend contract is created, populate the appropriate custom column field for contracts // on the Sales Order line objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: key, value: JSON.stringify(objExtendResponseData[key].contractIds) }); + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_lead_token', line: key, value: JSON.stringify(objExtendResponseData[key].leadTokens) }); + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_so_line', line: key, value: key}); } return objSalesOrderRecord; @@ -168,8 +220,8 @@ define([ objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; - objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); objExtendItemData[stUniqueKey].extend_line = i; + objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); } } @@ -178,13 +230,14 @@ define([ objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); objExtendItemData[stUniqueKey].itemId = stItemId objExtendItemData[stUniqueKey].line = i; - objExtendItemData[stUniqueKey].purchase_price = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); + objExtendItemData[stUniqueKey].purchase_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + i; } } return objExtendItemData; }; + // Build the Extend API JSON for order lines exports.buildExtendItemJSON = function (objValues) { //item json var lineItems = []; @@ -195,14 +248,15 @@ define([ 'product': { 'id': objValues.refId, // 'serialNumber': objValues.serial_number, - 'purchasePrice': parseInt(objValues[key].purchase_price * 100) + 'purchasePrice': objValues[key].purchase_price }, + 'status': 'unfulfilled', 'quantity': objValues[key].quantity, 'lineItemTransactionId': objValues[key].lineItemID } if (objValues[key].extend_plan_id && objValues[key].plan_price) { item.plan = { - 'id': objValues[key].extend_plan_id, + 'id': objValues[key].extend_plan_id.toString(), 'purchasePrice': objValues[key].plan_price } } @@ -214,7 +268,7 @@ define([ return lineItems; }; - // Build the Extend API JSON for contract creation + // Build the Extend API JSON for order creation exports.buildExtendOrderJSON = function (objValues) { log.debug('EXTEND UTIL _buildExtendOrderJSON:', '**ENTER**'); @@ -259,6 +313,13 @@ define([ return objJSON; }; + // Build the Extend API JSON for line fulfillment + exports.buildExtendFulfillJSON = function (objValues) { + var objJSON = { + 'lineItemTransactionId': objValues.lineItemID + } + return objJSON; + } /***********************************Support Functions********************************************/ //get Address Subrecord fields from transaction exports.getAddress = function (objSalesOrderRecord, addressField) { @@ -300,7 +361,8 @@ define([ columns: refIdValue }); for (var prop in arrItemLookup) { - var stItemRefId = arrItemLookup[prop] + //var stItemRefId = arrItemLookup[prop] + var stItemRefId = arrItemLookup[prop][0].text; break; } } diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js index baf8ab7..56c697f 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js @@ -40,6 +40,7 @@ exports.reduce = function (context) { try { log.debug('reduce', '** START **'); + log.audit('reduce', 'context: ' + context); var stFulfillmentId = context.key; log.audit('reduce', 'stFulfillmentId: ' + stFulfillmentId); diff --git a/com.extend.extendproductprotection/src/Objects/custbody_ext_process_error.xml b/com.extend.extendproductprotection/src/Objects/Fields/custbody_ext_process_error.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custbody_ext_process_error.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custbody_ext_process_error.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_associated_item.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_associated_item.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_associated_item.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_associated_item.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_contract_id.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_contract_id.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_contract_id.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_contract_id.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_plan_id.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_id.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_plan_id.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_id.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_plan_term.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_term.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_plan_term.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_term.xml diff --git a/com.extend.extendproductprotection/src/Objects/customlist_ext_environment.xml b/com.extend.extendproductprotection/src/Objects/Fields/customlist_ext_environment.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customlist_ext_environment.xml rename to com.extend.extendproductprotection/src/Objects/Fields/customlist_ext_environment.xml diff --git a/com.extend.extendproductprotection/src/Objects/customrecord_ext_configuration.xml b/com.extend.extendproductprotection/src/Objects/Fields/customrecord_ext_configuration.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customrecord_ext_configuration.xml rename to com.extend.extendproductprotection/src/Objects/Fields/customrecord_ext_configuration.xml diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_config_validate_ue.xml b/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_config_validate_ue.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customscript_ext_config_validate_ue.xml rename to com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_config_validate_ue.xml diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_create_contract_mr.xml b/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_create_contract_mr.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customscript_ext_create_contract_mr.xml rename to com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_create_contract_mr.xml diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_offer_modal_ue.xml b/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_modal_ue.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customscript_ext_offer_modal_ue.xml rename to com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_modal_ue.xml diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_offer_presentation_sl.xml b/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_presentation_sl.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customscript_ext_offer_presentation_sl.xml rename to com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_presentation_sl.xml diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_so_offer_controller_cs.xml b/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_so_offer_controller_cs.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customscript_ext_so_offer_controller_cs.xml rename to com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_so_offer_controller_cs.xml diff --git a/com.extend.extendproductprotection/src/Objects/customsearch_ext_contract_create.xml b/com.extend.extendproductprotection/src/Objects/Fields/customsearch_ext_contract_create.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customsearch_ext_contract_create.xml rename to com.extend.extendproductprotection/src/Objects/Fields/customsearch_ext_contract_create.xml diff --git a/com.extend.extendproductprotection/src/Objects/custbody_ext_order_create.xml b/com.extend.extendproductprotection/src/Objects/custbody_ext_order_create.xml new file mode 100644 index 0000000..20fa619 --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/custbody_ext_order_create.xml @@ -0,0 +1,61 @@ + + 2 + F + F + F + F + F + F + F + F + T + F + F + F + F + F + F + F + F + F + F + F + T + F + F + F + F + + + + + NORMAL + + + F + CHECKBOX + + F + + F + F + F + + + + + + + + + + 2 + + F + F + + + + T + + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_lead_token.xml b/com.extend.extendproductprotection/src/Objects/custcol_ext_lead_token.xml new file mode 100644 index 0000000..e6a5e6f --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/custcol_ext_lead_token.xml @@ -0,0 +1,53 @@ + + 2 + F + F + F + F + F + F + T + F + F + F + F + F + F + F + F + F + F + F + T + F + F + F + F + F + F + + + + + NORMAL + + + F + TEXT + + F + F + + + + + + + 2 + + F + + + + T + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_so_line.xml b/com.extend.extendproductprotection/src/Objects/custcol_ext_so_line.xml new file mode 100644 index 0000000..75d47f6 --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/custcol_ext_so_line.xml @@ -0,0 +1,53 @@ + + 2 + F + F + F + F + F + F + T + F + F + F + F + F + F + F + F + F + F + F + T + F + F + F + F + F + F + + + + + NORMAL + + + F + TEXT + + F + F + + + + + + + 2 + + F + + + + T + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/custitem_ext_item_ref_id.xml b/com.extend.extendproductprotection/src/Objects/custitem_ext_item_ref_id.xml new file mode 100644 index 0000000..6b3e5ff --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/custitem_ext_item_ref_id.xml @@ -0,0 +1,51 @@ + + 2 + F + T + T + T + F + F + F + F + F + F + F + F + F + + + + + NORMAL + + + F + TEXT + F + + F + F + F + F + F + BOTH + + + + + + + + + + 2 + + F + F + + + + T + ITEMMAIN + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_create_order_mr.xml b/com.extend.extendproductprotection/src/Objects/customscript_ext_create_order_mr.xml new file mode 100644 index 0000000..bb3916c --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/customscript_ext_create_order_mr.xml @@ -0,0 +1,59 @@ + + + F + Extend | MR | Order Create + F + + T + [/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js] + + + 2 + F + F + F + + + + + NORMAL + + + SELECT + + F + F + + + + + + NO_ACTION + 2 + -119 + + T + + + + + 1 + 1 + [scriptid=customsearch_ext_order_create] + T + DEBUG + T + ADMINISTRATOR + NOTSCHEDULED + Extend | MR | Order Create + 60 + + + + 2022-06-15 + 01:00:00Z + + + + + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_fulfill_order_mr.xml b/com.extend.extendproductprotection/src/Objects/customscript_ext_fulfill_order_mr.xml new file mode 100644 index 0000000..fbae4c7 --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/customscript_ext_fulfill_order_mr.xml @@ -0,0 +1,59 @@ + + + F + Extend | MR | Fulfill Order + F + + T + [/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js] + + + 2 + F + F + F + + + + + NORMAL + + + SELECT + + F + F + + + + + + NO_ACTION + 2 + -119 + + T + + + + + 1 + 1 + + T + DEBUG + T + ADMINISTRATOR + NOTSCHEDULED + Extend | MR | Fulfill Order + 60 + + + + 2022-06-25 + 01:00:00Z + + + + + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create.xml b/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create.xml new file mode 100644 index 0000000..740b9b7 --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create.xml @@ -0,0 +1,7 @@ + + + + [scriptid=custbody_ext_order_create] + + 757a6c116b72c899396d4d1a0380b7a865c6668f13fd0cebd7b2dd5b9ddf5c9d@GZC@2022.2.13@H4sIAAAAAAAA/+1c62+jxhb/Xqn/g0W+VWqcd1qLpMIwjml4WMOQxPcLYu1J162NI8DZzer+8ffMYBxswAmYyd62jlbKMgPnMef1m8MQ+bevs2nrmYbRZB5cSceHR1KLBqP5eBL8cSW5pPfzL9Jv1z/+IAdRNB91HBpO/OnkGx3bn/6ko1idB7E/CWjYAjJB1OF3XUmf4/ip025/+fLlMKBxtJjE9HA0n7Wj0Wc686M2v01qLSbjK4k4RMN3J+cnJ6fnZx3Hf6Zjh/rh6HNntIji+SziFx79GnvzcExDbxRSP6ad44uLi5OTo7PTy19Pz6RXFY4Oj6VWPJnRKPZnT6DS2n2gSqu1VGbmPz2B5GtPXoOYTOYpHf9BQxA6pIeJBPBrqXt4mDx5mMhp8gu5nSWaZTOmj5NgEgMLPgrjyXPa5jjMjGk0CidP8TxcjcFoSEGOMXl5oq3R1I+iKymhgFfj0rWDFKz2PWQRPJTbr09k6Tz70wWNMiMwdsfGWo8TOuW3p6R76YCUzF1Jt2joDRT1VrlBUqu9AxFHxfqAeLomMW2+fbuSojgEd4O132Zwuc251GT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1KW1XJ7GZwpq9Bn9dWR25vY1Z5ZYpeVywXpvE3GYzoaWbVihhkVyEZ08fb3nms7sk8NwaKPN0t2wer6yztpNOcOnl6mbkj8Gd0G2c+/2qVLcpUNsp7scNmZ5DddFYFO6y3WYqww9lHYId3Fei/PwKoZdbzxKznzZr1fG/W72vWi8SsF82a9WJv1u9r1svErJfNmvVyb9aKZs0NJxv2dLj0r1TBPT/+8D9B4tTE80oAAA== + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/deploy.xml b/com.extend.extendproductprotection/src/deploy.xml index 3e6c925..01c5c23 100644 --- a/com.extend.extendproductprotection/src/deploy.xml +++ b/com.extend.extendproductprotection/src/deploy.xml @@ -4,7 +4,7 @@ ~/Objects/Fields/* - + ~/Translations/* diff --git a/com.extend.extendproductprotection/src/manifest.xml b/com.extend.extendproductprotection/src/manifest.xml index 0ebe867..8d40b4b 100644 --- a/com.extend.extendproductprotection/src/manifest.xml +++ b/com.extend.extendproductprotection/src/manifest.xml @@ -24,6 +24,7 @@ WORKORDERS RECEIVABLES PAYABLES + MATRIXITEMS \ No newline at end of file From 9c90b09b6264888af9b0aed6964737185432bdb6 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Thu, 3 Nov 2022 07:04:26 -0500 Subject: [PATCH 10/33] fulfillment script updates --- .../lib/customscript_ext_util.js | 68 ++++++++++++++++++- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index fe2c983..f2a6179 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -47,6 +47,9 @@ define([ exports.handleOrderResponse(objExtendResponseBody, objSalesOrderRecord); //make SO as extend order created objSalesOrderRecord.setValue({ fieldId: 'custbody_ext_order_create', value: true }); + var stExtendOrderId = objExtendResponseBody.id; + log.debug('EXTEND UTIL _createExtendOrder: stExtendOrderId: ', stExtendOrderId); + objSalesOrderRecord.setValue({ fieldId: 'custbody_ext_order_id', value: stExtendOrderId }); } else { log.error('EXTEND UTIL _createExtendContracts', objExtendResponse); @@ -65,12 +68,20 @@ define([ }; //fulfill items on order exports.fulfillExtendOrder = function (objFulfillmentRecord) { + log.audit('EXTEND UTIL _fulfillExtendOrder:', '**ENTER**'); + log.audit('EXTEND UTIL _fulfillExtendOrder: IF ID', objFulfillmentRecord.id); + + //build order data obj + var objExtendData = {}; + //get fulfillment data + objExtendData = exports.getFulfillmentData(objFulfillmentRecord); + log.audit('EXTEND UTIL _fulfillExtendOrder: getFulfillmentData objExtendData', objExtendData); for (key in objExtendData) { //build fulfillment json obj var objExtendFulfillRequestJSON = {}; objExtendFulfillRequestJSON = exports.buildExtendFulfillJSON(objExtendData[key]); - log.audit('EXTEND UTIL _fulfillExtendOrder: objExtendOrderRequestJSON', objExtendFulfillRequestJSON); + log.audit('EXTEND UTIL _fulfillExtendOrder: objExtendFulfillRequestJSON', objExtendFulfillRequestJSON); // Create contract call for quantity fulfilled on the Extend item for (var i = 0; i < objExtendData[key].quantity; i++) { @@ -102,13 +113,63 @@ define([ }; /***********************************Support Functions********************************************/ +exports.getFulfillmentData = function (stLineCount, objNewRecord){ + //////////////////////////SUPPORT FUNCTIONS/////////////////////////// + log.debug('_getExtendData: Get Extend Data', '**ENTER**'); + var objExtendItemData = {}; + + var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + for (var i = 0; i < stLineCount; i++) { + var stItemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); + //Check if item is one of the configured extend items + if (stExtendItemId === stItemId) { + log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); + //get qty of contracts created & compare to extend item qty + var stContractQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_qty', line: i }); + var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); + + if (stContractQty < stExtendItemQty) { + + //get related item from extend line + var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + //check for new fulfillments + for (var j = 0; j < stLineCount; j++) { + var stRelatedItem = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); + if (stRelatedItem === stExtendItemRefId) { + + var stRelatedItemQtyFulfilled = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantityfulfilled', line: j }); + if (stRelatedItemQtyFulfilled <= stExtendItemQty && stRelatedItemQtyFulfilled > stContractQty) { + + var stUniqueKey = i; + // Start building the Extend Order Info Object + objExtendItemData[stUniqueKey] = {}; + objExtendItemData[stUniqueKey].quantity = Math.min(stRelatedItemQtyFulfilled, (stExtendItemQty - stContractQty)); + objExtendItemData[stUniqueKey].item = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + objExtendItemData[stUniqueKey].line = i; + objExtendItemData[stUniqueKey].purchase_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: j }); + objExtendItemData[stUniqueKey].extend_plan_id = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); + objExtendItemData[stUniqueKey].itemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; + objExtendItemData[stUniqueKey].plan_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); + + } + } + } + + } + } + } + log.debug('_getExtendData: return objExtendItemData', objExtendItemData); + + return objExtendItemData +}; exports.handleOrderResponse = function (objExtendResponseBody, objSalesOrderRecord) { log.debug('EXTEND UTIL _createExtendOrder: Extend Response Body Parsed: ', objExtendResponseBody); var arrLineItems = objExtendResponseBody.lineItems; var objExtendResponseData = {}; + for (var i = 0; i < arrLineItems.length; i++) { log.debug('EXTEND UTIL _createExtendOrder: arrLineItems: ', arrLineItems[i]); var line = arrLineItems[i].lineItemTransactionId; @@ -123,9 +184,9 @@ define([ var arrContractIds = []; arrContractIds = objExtendResponseData[stUniqueKey].contractIds; log.debug('EXTEND UTIL _createExtendOrder: arrContractIds: ', arrContractIds); - log.debug('EXTEND UTIL _createExtendOrder: contractid arrLineItems: ', arrLineItems[i].contractId); + log.debug('EXTEND UTIL _createExtendOrder: contractid arrLineItems: ', arrLineItems[i].id); if (arrLineItems[i].contractId) { - arrContractIds.push(arrLineItems[i].contractId) + arrContractIds.push(arrLineItems[i].id) } objExtendResponseData[stUniqueKey].contractIds = arrContractIds; } @@ -229,6 +290,7 @@ define([ // Start building the Extend Order Item Info Object objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); objExtendItemData[stUniqueKey].itemId = stItemId + objExtendItemData[stUniqueKey].uniqueLine = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'lineuniquekey', line: i }); objExtendItemData[stUniqueKey].line = i; objExtendItemData[stUniqueKey].purchase_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + i; From dcecd6a15579778bd992daf3b4dc391c61fe35fe Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Thu, 3 Nov 2022 07:17:43 -0500 Subject: [PATCH 11/33] returns script --- .../lib/customscript_ext_util.js | 84 +++++++------- .../customscript_ext_refund_contract_mr.js | 103 ++++++++++++++++++ 2 files changed, 144 insertions(+), 43 deletions(-) create mode 100644 com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index f2a6179..6b10e13 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -112,57 +112,55 @@ define([ objFulfillmentRecord.save(); }; - /***********************************Support Functions********************************************/ -exports.getFulfillmentData = function (stLineCount, objNewRecord){ - //////////////////////////SUPPORT FUNCTIONS/////////////////////////// - log.debug('_getExtendData: Get Extend Data', '**ENTER**'); - var objExtendItemData = {}; - - var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); - for (var i = 0; i < stLineCount; i++) { - var stItemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); - //Check if item is one of the configured extend items - if (stExtendItemId === stItemId) { - log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); - //get qty of contracts created & compare to extend item qty - var stContractQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_qty', line: i }); - var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); - - if (stContractQty < stExtendItemQty) { + exports.refundExtendOrder = function (objRefundRecord) { - //get related item from extend line - var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - //check for new fulfillments - for (var j = 0; j < stLineCount; j++) { - var stRelatedItem = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); - if (stRelatedItem === stExtendItemRefId) { + }; + /***********************************Support Functions********************************************/ + exports.getFulfillmentData = function (stLineCount, objNewRecord) { + log.debug('_getExtendData: Get Extend Data', '**ENTER**'); + var objExtendItemData = {}; - var stRelatedItemQtyFulfilled = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantityfulfilled', line: j }); - if (stRelatedItemQtyFulfilled <= stExtendItemQty && stRelatedItemQtyFulfilled > stContractQty) { - - var stUniqueKey = i; - // Start building the Extend Order Info Object - objExtendItemData[stUniqueKey] = {}; - objExtendItemData[stUniqueKey].quantity = Math.min(stRelatedItemQtyFulfilled, (stExtendItemQty - stContractQty)); - objExtendItemData[stUniqueKey].item = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - objExtendItemData[stUniqueKey].line = i; - objExtendItemData[stUniqueKey].purchase_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: j }); - objExtendItemData[stUniqueKey].extend_plan_id = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); - objExtendItemData[stUniqueKey].itemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; - objExtendItemData[stUniqueKey].plan_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); - + var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + for (var i = 0; i < stLineCount; i++) { + var stItemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); + //Check if item is one of the configured extend items + if (stExtendItemId === stItemId) { + log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); + //get qty of contracts created & compare to extend item qty + var stContractQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_qty', line: i }); + var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); + + if (stContractQty < stExtendItemQty) { + + //get related item from extend line + var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + //check for new fulfillments + for (var j = 0; j < stLineCount; j++) { + var stRelatedItem = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); + if (stRelatedItem === stExtendItemRefId) { + + var stRelatedItemQtyFulfilled = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantityfulfilled', line: j }); + if (stRelatedItemQtyFulfilled <= stExtendItemQty && stRelatedItemQtyFulfilled > stContractQty) { + + var stUniqueKey = i; + // Start building the Extend Order Info Object + objExtendItemData[stUniqueKey] = {}; + objExtendItemData[stUniqueKey].quantity = Math.min(stRelatedItemQtyFulfilled, (stExtendItemQty - stContractQty)); + objExtendItemData[stUniqueKey].line = i; + objExtendItemData[stUniqueKey].lineItemID = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: i }); + + } } } - } + } } } - } - log.debug('_getExtendData: return objExtendItemData', objExtendItemData); + log.debug('_getExtendData: return objExtendItemData', objExtendItemData); - return objExtendItemData -}; + return objExtendItemData + }; exports.handleOrderResponse = function (objExtendResponseBody, objSalesOrderRecord) { log.debug('EXTEND UTIL _createExtendOrder: Extend Response Body Parsed: ', objExtendResponseBody); @@ -211,7 +209,7 @@ exports.getFulfillmentData = function (stLineCount, objNewRecord){ // on the Sales Order line objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: key, value: JSON.stringify(objExtendResponseData[key].contractIds) }); objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_lead_token', line: key, value: JSON.stringify(objExtendResponseData[key].leadTokens) }); - objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_so_line', line: key, value: key}); + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_so_line', line: key, value: key }); } return objSalesOrderRecord; diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js new file mode 100644 index 0000000..423609b --- /dev/null +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js @@ -0,0 +1,103 @@ +/** + *@name: EXTEND SUITESCRIPT SDK - Create Contract from Fulfillment JS + *@description: + * This script invokes a call to the Extend Refunds POST endpoint whenever + * a protection plan is refunded + * + *@copyright Extend, Inc + *@author Michael Draper + * + *@NApiVersion 2.x + *@NScriptType MapReduceScript + *@ModuleScope Public + */ + define([ + 'N/runtime', + 'N/record', + 'N/search', + '../lib/customscript_ext_util' +], + function (runtime, record, search, EXTEND_UTIL) { + var exports = {}; + + exports.getInputData = function () { + try { + log.audit('getInputData', '** START **'); + //todo build search in getinput instead of param? + var stRefundSearchID = runtime.getCurrentScript().getParameter('custscript_ext_refund_search'); + + log.debug('stRefundSearchID', stRefundSearchID); + var refundSearch = search.load({ + id: stRefundSearchID + }); + + return refundSearch; + + } catch (e) { + log.error('getInputData', 'error: ' + e); + } + } + exports.reduce = function (context) { + try { + log.debug('reduce', '** START **'); + log.audit('reduce', 'context: ' + context); + + var stRefundId = context.key; + var stRefundType = context.values.type; + log.audit('reduce', 'stRefundId: ' + stRefundId); + log.audit('reduce', 'stRefundType: ' + stRefundType); + //Load associated Saled Order Record + var objRefundRecord = record.load({ + type: stRefundType, + id: stRefundId + }); + // Get Extend Details from Sales Order + objExtendData = EXTEND_UTIL.refundExtendOrder(objRefundRecord); + + } catch (e) { + log.error('reduce', 'key: ' + context.key + ' error: ' + e); + record.submitFields({ + type: stRefundType, + id: stRefundId, + values: { + 'custbody_ext_process_error': true + }, + options: { + enableSourcing: false, + ignoreMandatoryFields: true + } + }); + // create user note attached to record + var objNoteRecord = record.create({ + type: record.Type.NOTE, + }) + objNoteRecord.setValue('transaction', stFulfillmentId); + objNoteRecord.setValue('title', 'Extend Error Order Create'); + objNoteRecord.setValue('note', JSON.stringify(e.message)); + var stNoteId = objNoteRecord.save(); + log.debug('reduce', 'stNoteId: ' + stNoteId); + + } + } + exports.summarize = function (summary) { + log.audit('summarize', '** START **'); + try { + var mapKeys = []; + summary.mapSummary.keys.iterator().each(function (key) { + mapKeys.push(key); + return true; + }); + if (mapKeys.length < 1) { + log.debug('summarize', 'No results were processed'); + } + log.debug('summarize', JSON.stringify(summary)); + + } catch (e) { + log.error('summarize', 'error: ' + e); + } + } + + + + return exports; + }); From b370cee619e43402f5acecd3f4e46c60c71bd9a8 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Mon, 7 Nov 2022 11:50:04 -0600 Subject: [PATCH 12/33] refunds script --- .../client/customscript_ext_so_offer_controller_cs.js | 4 ++-- .../suitelet/customscript_ext_offer_modal_sl.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_so_offer_controller_cs.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_so_offer_controller_cs.js index e2b5fb3..39ee35f 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_so_offer_controller_cs.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_so_offer_controller_cs.js @@ -82,7 +82,7 @@ define([ columns: refIdValue }); for (var prop in arrItemLookup) { - var stItemRefId = arrItemLookup[prop]; + var stItemRefId = arrItemLookup[prop][0].text; break; } } @@ -149,7 +149,7 @@ define([ }); for (var prop in arrItemLookup) { - var stItemRefId = arrItemLookup[prop]; + var stItemRefId = arrItemLookup[prop][0].text; break; } } diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js index fa9adc8..90201c4 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js @@ -334,7 +334,7 @@ define([ */ if (stItemRefId) { try { - var objResponse = api.getPlansByItem(stItemRefId); + var objResponse = api.getOffers(stItemRefId); log.debug('OFFER MODAL SUITELET: Offers JSON Response', objResponse); if (objResponse.code == 200) { var objResponseBody = JSON.parse(objResponse.body); From ee3de5f484635294461f08c39a1e1595a2d3352b Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Mon, 7 Nov 2022 12:45:03 -0600 Subject: [PATCH 13/33] move config calls --- .../lib/customscript_ext_api_lib.js | 48 +++++++++---------- .../lib/customscript_ext_util.js | 6 +-- .../customscript_ext_create_order_mr.js | 9 ++-- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js index 7e8db3b..f3073b6 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js @@ -19,8 +19,8 @@ * CREATE PRODUCTS * API Documentation: https://developers.extend.com/default#tag/Products/paths/~1stores~1{storeId}~1products/post */ - exports.createProduct = function (arrProducts, bIsBatch, bIsUpsert) { - var config = extendConfig.getConfig(); + exports.createProduct = function (arrProducts, bIsBatch, bIsUpsert, config) { + // var config = extendConfig.getConfig(); try { var response = https.post({ url: config.domain + '/stores/' + config.storeId + '/products?upsert=' + bIsUpsert + '?batch=' + bIsBatch, @@ -43,9 +43,9 @@ * UPDATE PRODUCT * API Documentation: https://developers.extend.com/default#tag/Products/paths/~1stores~1{storeId}~1products~1{productId}/put */ - exports.updateProduct = function (objProductDetails, stItemId) { + exports.updateProduct = function (objProductDetails, stItemId, config) { // log.debug('Extend Product Details', objProductDetails); - var config = extendConfig.getConfig(); + // var config = extendConfig.getConfig(); try { var response = https.put({ url: config.domain + '/stores/' + config.storeId + '/products/' + stItemId, @@ -68,8 +68,8 @@ * GET PRODUCT * API Documentation: https://developers.helloextend.com/2020-08-01#tag/Products/paths/~1stores~1{storeId}~1products~1{productId}/get */ - exports.getProduct = function (stItemId) { - var config = extendConfig.getConfig(); + exports.getProduct = function (stItemId, config) { + //var config = extendConfig.getConfig(); try { var response = https.get({ url: config.domain + '/stores/' + config.storeId + '/products/' + stItemId, @@ -91,8 +91,8 @@ * DELETE PRODUCT * API Documentation: https://developers.extend.com/default#tag/Products/paths/~1stores~1{storeId}~1products~1{productId}/delete */ - exports.deleteProduct = function (stItemId) { - var config = extendConfig.getConfig(); + exports.deleteProduct = function (stItemId, config) { + //var config = extendConfig.getConfig(); try { var response = https.get({ url: config.domain + '/stores/' + config.storeId + '/products/' + stItemId, @@ -116,8 +116,8 @@ * GET OFFERS * API Documentation: https://developers.extend.com/default#operation/getOffer */ - exports.getOffers= function (stItemId) { - var config = extendConfig.getConfig(); + exports.getOffers= function (stItemId, config) { + // var config = extendConfig.getConfig(); try { var response = https.get({ url: config.domain + '/offers?storeId=' + config.storeId + '&productId=' + stItemId, @@ -141,8 +141,8 @@ * CREATE LEAD * API Documentation: https://developers.helloextend.com/2020-08-01#tag/Leads/paths/~1stores~1{storeId}~1leads/post */ - exports.createLead = function (objLeadDetails) { - var config = extendConfig.getConfig(); + exports.createLead = function (objLeadDetails, config) { + // var config = extendConfig.getConfig(); try { var response = https.post({ url: config.domain + '/stores/' + config.storeId + '/leads', @@ -165,8 +165,8 @@ * GET LEAD OFFERS * API Documentation: https://developers.helloextend.com/2020-08-01#tag/Leads/paths/~1leads~1{leadToken}~1offers/get */ - exports.getLeadOffers = function (objLeadDetails) { - var config = extendConfig.getConfig(); + exports.getLeadOffers = function (objLeadDetails, config) { + //var config = extendConfig.getConfig(); try { var response = https.get({ url: config.domain + '/leads/' + config.storeId + '/offers', @@ -191,8 +191,8 @@ * CREATE ORDER * API Documentation: https://docs.extend.com/reference/orderscreate */ - exports.createOrder = function (objOrderDetails) { - var config = extendConfig.getConfig(); + exports.createOrder = function (objOrderDetails, config) { + // var config = extendConfig.getConfig(); try { var response = https.post({ @@ -216,8 +216,8 @@ * UPDATE ORDER LINE FULFILLMENT * API Documentation: https://docs.extend.com/reference/lineitemsfulfill */ - exports.fulfillOrderLine = function (objOrderDetails) { - var config = extendConfig.getConfig(); + exports.fulfillOrderLine = function (objOrderDetails, config) { + // var config = extendConfig.getConfig(); try { var response = https.post({ url: config.domain + '/line-items/fulfill', @@ -241,8 +241,8 @@ * REFUND CONTRACT * API Documentation: https://docs.extend.com/reference/refundscreate */ - exports.refundContract = function (objRefundDetails) { - var config = extendConfig.getConfig(); + exports.refundContract = function (objRefundDetails, config) { + // var config = extendConfig.getConfig(); try { var response = https.post({ url: config.domain + '/refunds', @@ -265,8 +265,8 @@ * GET REFUND QUOTE * API Documentation: https://docs.extend.com/reference/refundsget */ - exports.getRefundQuote = function (objRefundDetails) { - var config = extendConfig.getConfig(); + exports.getRefundQuote = function (objRefundDetails, config) { + // var config = extendConfig.getConfig(); try { var response = https.get({ url: config.domain + '/refunds', @@ -289,8 +289,8 @@ * REQUEST REFUND * API Documentation: https://docs.extend.com/reference/refundscreate */ - exports.requestRefund = function (objRefundDetails) { - var config = extendConfig.getConfig(); + exports.requestRefund = function (objRefundDetails, config) { + // var config = extendConfig.getConfig(); try { var response = https.post({ url: config.domain + '/refunds', diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 6b10e13..b5a88ae 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -18,7 +18,7 @@ define([ * Order Functions */ //create extend order - exports.createExtendOrder = function (objSalesOrderRecord) { + exports.createExtendOrder = function (objSalesOrderRecord, objExtendConfig) { log.audit('EXTEND UTIL _createExtendOrder:', '**ENTER**'); log.audit('EXTEND UTIL _createExtendOrder: SO ID', objSalesOrderRecord.id); var objExtendOrderRequestJSON = {}; @@ -39,7 +39,7 @@ define([ objExtendOrderRequestJSON = exports.buildExtendOrderJSON(objExtendData); log.audit('EXTEND UTIL _createExtendOrder: objExtendOrderRequestJSON', objExtendOrderRequestJSON); //call api - var objExtendResponse = EXTEND_API.createOrder(objExtendOrderRequestJSON); + var objExtendResponse = EXTEND_API.createOrder(objExtendOrderRequestJSON, config); log.audit('EXTEND UTIL _createExtendOrder: Extend Response Object: ', objExtendResponse); //handle response if (objExtendResponse.code === 201) { @@ -86,7 +86,7 @@ define([ for (var i = 0; i < objExtendData[key].quantity; i++) { //call api - var objExtendResponse = EXTEND_API.fulfillOrderLine(objExtendFulfillRequestJSON); + var objExtendResponse = EXTEND_API.fulfillOrderLine(objExtendFulfillRequestJSON, config); log.audit('EXTEND UTIL _fulfillExtendOrder: Extend Response Object: ', objExtendResponse); //handle response if (objExtendResponse.code === 201) { diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js index d24dd44..f8cff6a 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js @@ -15,9 +15,11 @@ define([ 'N/runtime', 'N/record', 'N/search', - '../lib/customscript_ext_util' + '../lib/customscript_ext_util', + '../lib/customscript_ext_config_lib' + ], - function (runtime, record, search, EXTEND_UTIL) { + function (runtime, record, search, EXTEND_UTIL, EXTEND_CONFIG) { var exports = {}; exports.getInputData = function () { @@ -49,7 +51,8 @@ define([ id: stSalesOrderId }); // Get Extend Details from Sales Order - objExtendData = EXTEND_UTIL.createExtendOrder(objSalesOrderRecord); + var objExtendConfig = EXTEND_CONFIG.getConfig(); + objExtendData = EXTEND_UTIL.createExtendOrder(objSalesOrderRecord, objExtendConfig); } catch (e) { log.error('reduce', 'key: ' + context.key + ' error: ' + e); From 6cbad97e57fe9e81c3efd68fbc43b834db1275b4 Mon Sep 17 00:00:00 2001 From: alopez-extend <87334339+alopez-extend@users.noreply.github.com> Date: Tue, 8 Nov 2022 10:12:07 -0600 Subject: [PATCH 14/33] Refunds first draft --- .../lib/customscript_ext_util.js | 47 ++++++++++++++++++- .../customscript_ext_refund_contract_mr.js | 44 +++++++++++++---- .../customscript_ext_offer_modal_sl.js | 11 +++-- 3 files changed, 87 insertions(+), 15 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index b5a88ae..69cda7f 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -112,9 +112,54 @@ define([ objFulfillmentRecord.save(); }; - exports.refundExtendOrder = function (objRefundRecord) { + + //refund item by line item transaction id + exports.refundExtendOrder = function (objRefundData) { + log.audit('EXTEND UTIL _refundExtendOrder:', '**ENTER**'); + log.audit('EXTEND UTIL _refundExtendOrder: objRefundData', JSON.stringify(objRefundData)); + + var config = EXTEND_CONFIG.getConfig(); + var objLineToRefund = {'lineItemTransactionId': objRefundData['lineItemTransactionId']} + var objExtendResponse = EXTEND_API.refundContract(objLineToRefund, config); + log.audit('EXTEND UTIL _refundExtendOrder: Extend Response Object: ', objExtendResponse); + + var objRefundedRecord = record.load({ + type: objRefundData.TYPE, + id: objRefundData.ID + }); + + //handle response + if (objExtendResponse.code === 201) { + var objExtendResponseBody = JSON.parse(objExtendResponse.body); + log.debug('EXTEND UTIL _refundExtendOrder: objExtendResponseBody: ', JSON.stringify(objExtendResponseBody)); + + // exports.handleOrderResponse(objExtendResponseBody, objRefundedRecord); + + //make transaction as extend order processed + objRefundedRecord.setValue({ fieldId: 'custbody_ext_order_create', value: true }); + // var stExtendOrderId = objExtendResponseBody.id; + + // log.debug('EXTEND UTIL _refundExtendOrder: stExtendOrderId: ', stExtendOrderId); + // objRefundedRecord.setValue({ fieldId: 'custbody_ext_order_id', value: stExtendOrderId }); + + } else { + log.error('EXTEND UTIL _refundExtendOrder', objExtendResponse); + objRefundedRecord.setValue({ fieldId: 'custbody_ext_process_error', value: true }); + // create user note attached to record + var objNoteRecord = record.create({ + type: record.Type.NOTE, + }) + objNoteRecord.setValue('transaction', objRefundedRecord.id); + objNoteRecord.setValue('title', 'Extend Refund Error'); + objNoteRecord.setValue('note', JSON.stringify(objExtendResponse.body)); + var stNoteId = objNoteRecord.save(); + } + + objRefundedRecord.save(); + }; + /***********************************Support Functions********************************************/ exports.getFulfillmentData = function (stLineCount, objNewRecord) { log.debug('_getExtendData: Get Extend Data', '**ENTER**'); diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js index 423609b..3f2cdcb 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js @@ -37,25 +37,49 @@ log.error('getInputData', 'error: ' + e); } } + exports.reduce = function (context) { try { log.debug('reduce', '** START **'); - log.audit('reduce', 'context: ' + context); var stRefundId = context.key; - var stRefundType = context.values.type; log.audit('reduce', 'stRefundId: ' + stRefundId); + + var objContextValues = JSON.parse(context.values[0]); + log.audit('reduce', 'objContextValues: ' + JSON.stringify(objContextValues)); + + var stRefundType = objContextValues['recordType'] log.audit('reduce', 'stRefundType: ' + stRefundType); + + var stLineTranID = objContextValues.values.custcol_ext_so_line + log.audit('reduce', 'stLineTranID: ' + stLineTranID); + + var stLineSequenceNum = objContextValues.values.linesequencenumber - 1; + log.audit('reduce', 'stLineSequenceNum: ' + stLineSequenceNum); + + var objRefundData = { + 'ID' : stRefundId, + 'TYPE' : stRefundType, + 'lineItemTransactionId' : stLineTranID, + 'LINE_NUM' : stLineSequenceNum + } + + //call to refund by line item transaction id + objExtendData = EXTEND_UTIL.refundExtendOrder(objRefundData); + //Load associated Saled Order Record - var objRefundRecord = record.load({ - type: stRefundType, - id: stRefundId - }); + // var objRefundRecord = record.load({ + // type: stRefundType, + // id: stRefundId + // }); + + // log.debug('reduce', 'objRefundRecord - '+ JSON.stringify(objRefundRecord)); // Get Extend Details from Sales Order - objExtendData = EXTEND_UTIL.refundExtendOrder(objRefundRecord); + // objExtendData = EXTEND_UTIL.refundExtendOrder(objRefundRecord); } catch (e) { log.error('reduce', 'key: ' + context.key + ' error: ' + e); + record.submitFields({ type: stRefundType, id: stRefundId, @@ -67,10 +91,12 @@ ignoreMandatoryFields: true } }); + // create user note attached to record var objNoteRecord = record.create({ type: record.Type.NOTE, }) + objNoteRecord.setValue('transaction', stFulfillmentId); objNoteRecord.setValue('title', 'Extend Error Order Create'); objNoteRecord.setValue('note', JSON.stringify(e.message)); @@ -79,6 +105,7 @@ } } + exports.summarize = function (summary) { log.audit('summarize', '** START **'); try { @@ -87,6 +114,7 @@ mapKeys.push(key); return true; }); + if (mapKeys.length < 1) { log.debug('summarize', 'No results were processed'); } @@ -97,7 +125,5 @@ } } - - return exports; }); diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js index 90201c4..3765290 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js @@ -18,9 +18,10 @@ define([ 'N/runtime', 'N/http', 'N/error', - '../lib/customscript_ext_api_lib' + '../lib/customscript_ext_api_lib', + '../lib/customscript_ext_config_lib' ], - function (ui, runtime, http, error, api) { + function (ui, runtime, http, error, api, EXTEND_CONFIG) { var exports = {}; @@ -334,11 +335,12 @@ define([ */ if (stItemRefId) { try { - var objResponse = api.getOffers(stItemRefId); + var config = EXTEND_CONFIG.getConfig(); + var objResponse = api.getOffers(stItemRefId, config); log.debug('OFFER MODAL SUITELET: Offers JSON Response', objResponse); + if (objResponse.code == 200) { var objResponseBody = JSON.parse(objResponse.body); - log.debug('OFFER MODAL SUITELET: Offers JSON Response', objResponseBody); var objPlans = objResponseBody.plans; @@ -350,7 +352,6 @@ define([ if (arrPlans.length == 0) { var arrPlans = objPlans.adh; } - log.debug('arrPlans', arrPlans); //Populate Sublist Values From a0268b65e4239e4f39ad5f9d151162c63ed7811b Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Tue, 8 Nov 2022 11:16:38 -0600 Subject: [PATCH 15/33] fulfillment updates --- .../lib/customscript_ext_api_lib.js | 24 +++- .../lib/customscript_ext_config_lib.js | 6 +- .../lib/customscript_ext_util.js | 132 ++++++++++++------ .../customscript_ext_fulfill_order_mr.js | 64 +++++++-- 4 files changed, 166 insertions(+), 60 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js index f3073b6..cdd2d01 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js @@ -200,7 +200,8 @@ headers: { 'Content-Type': 'application/json', 'X-Extend-Access-Token': config.key, - 'Accept': 'application/json;version=' + config.version + 'Accept': 'application/json;version=' + config.version, + 'X-Idempotency-Key': exports.generateUUID() }, body: JSON.stringify(objOrderDetails), }); @@ -219,12 +220,16 @@ exports.fulfillOrderLine = function (objOrderDetails, config) { // var config = extendConfig.getConfig(); try { + var guid = exports.generateUUID(); + log.debug('guid', guid); + var response = https.post({ url: config.domain + '/line-items/fulfill', headers: { 'Content-Type': 'application/json', 'X-Extend-Access-Token': config.key, - 'Accept': 'application/json;version=' + config.version + 'Accept': 'application/json;version=' + config.version, + 'X-Idempotency-Key' : exports.generateUUID() }, body: JSON.stringify(objOrderDetails), }); @@ -309,6 +314,21 @@ return; } }; +exports.generateUUID = function () { + var d = new Date().getTime();//Timestamp + var d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now()*1000)) || 0;//Time in microseconds since page-load or 0 if unsupported + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random() * 16;//random number between 0 and 16 + if(d > 0){//Use timestamp until depleted + r = (d + r)%16 | 0; + d = Math.floor(d/16); + } else {//Use microseconds since page-load if supported + r = (d2 + r)%16 | 0; + d2 = Math.floor(d2/16); + } + return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); + }); +} return exports; }); diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js index 81fe50b..272d0a2 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js @@ -23,11 +23,13 @@ var API_KEY; var API_VERSION = 'latest'; var REF_ID; - + + var arrFilters = ["isinactive","is","F"]; + var customrecord_ext_configurationSearchObj = search.create({ type: "customrecord_ext_configuration", filters:[ - ["isinactive","is","F"] + arrFilters ], columns: [ diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index b5a88ae..edafcae 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -32,14 +32,14 @@ define([ var objExtendItemData = exports.getSalesOrderItemInfo(objSalesOrderRecord); log.audit('EXTEND UTIL _createExtendOrder: objExtendItemData', objExtendItemData); //format items - objExtendData.lineItems = exports.buildExtendItemJSON(objExtendItemData); + objExtendData.lineItems = exports.buildExtendItemJSON(objExtendItemData, objExtendConfig); log.audit('EXTEND UTIL _createExtendOrder: objExtendData', objExtendData); //build order json obj - objExtendOrderRequestJSON = exports.buildExtendOrderJSON(objExtendData); + objExtendOrderRequestJSON = exports.buildExtendOrderJSON(objExtendData, objExtendConfig); log.audit('EXTEND UTIL _createExtendOrder: objExtendOrderRequestJSON', objExtendOrderRequestJSON); //call api - var objExtendResponse = EXTEND_API.createOrder(objExtendOrderRequestJSON, config); + var objExtendResponse = EXTEND_API.createOrder(objExtendOrderRequestJSON, objExtendConfig); log.audit('EXTEND UTIL _createExtendOrder: Extend Response Object: ', objExtendResponse); //handle response if (objExtendResponse.code === 201) { @@ -67,14 +67,14 @@ define([ objSalesOrderRecord.save(); }; //fulfill items on order - exports.fulfillExtendOrder = function (objFulfillmentRecord) { + exports.fulfillExtendOrder = function (objSalesOrderRecord, stFulfillmentId, objExtendConfig) { log.audit('EXTEND UTIL _fulfillExtendOrder:', '**ENTER**'); - log.audit('EXTEND UTIL _fulfillExtendOrder: IF ID', objFulfillmentRecord.id); + log.audit('EXTEND UTIL _fulfillExtendOrder: SO ID', objSalesOrderRecord.id); //build order data obj var objExtendData = {}; //get fulfillment data - objExtendData = exports.getFulfillmentData(objFulfillmentRecord); + objExtendData = exports.getFulfillmentData(objSalesOrderRecord); log.audit('EXTEND UTIL _fulfillExtendOrder: getFulfillmentData objExtendData', objExtendData); for (key in objExtendData) { @@ -86,23 +86,44 @@ define([ for (var i = 0; i < objExtendData[key].quantity; i++) { //call api - var objExtendResponse = EXTEND_API.fulfillOrderLine(objExtendFulfillRequestJSON, config); + var objExtendResponse = EXTEND_API.fulfillOrderLine(objExtendFulfillRequestJSON, objExtendConfig); log.audit('EXTEND UTIL _fulfillExtendOrder: Extend Response Object: ', objExtendResponse); //handle response if (objExtendResponse.code === 201) { var objExtendResponseBody = JSON.parse(objExtendResponse.body); - exports.handleOrderResponse(objExtendResponseBody, objFulfillmentRecord); - //make SO as extend order created - objFulfillmentRecord.setValue({ fieldId: 'custbody_ext_order_create', value: true }); + exports.handleFulfillResponse(objExtendResponseBody, objSalesOrderRecord); + //submit fields to IF + record.submitFields({ + type: record.Type.ITEM_FULFILLMENT, + id: stFulfillmentId, + values: { + 'custbody_ext_order_create': true + }, + options: { + enableSourcing: false, + ignoreMandatoryFields : true + } + }); } else { log.error('EXTEND UTIL _fulfillExtendOrder', objExtendResponse); - objFulfillmentRecord.setValue({ fieldId: 'custbody_ext_process_error', value: true }); + //submit fields + record.submitFields({ + type: record.Type.ITEM_FULFILLMENT, + id: stFulfillmentId, + values: { + 'custbody_ext_process_error': true + }, + options: { + enableSourcing: false, + ignoreMandatoryFields : true + } + }); // create user note attached to record var objNoteRecord = record.create({ type: record.Type.NOTE, }) - objNoteRecord.setValue('transaction', objFulfillmentRecord.id); + objNoteRecord.setValue('transaction', stFulfillmentId); objNoteRecord.setValue('title', 'Extend Order Create Error'); objNoteRecord.setValue('note', JSON.stringify(objExtendResponse)); var stNoteId = objNoteRecord.save(); @@ -116,18 +137,26 @@ define([ }; /***********************************Support Functions********************************************/ - exports.getFulfillmentData = function (stLineCount, objNewRecord) { + exports.getFulfillmentData = function (objNewRecord) { log.debug('_getExtendData: Get Extend Data', '**ENTER**'); var objExtendItemData = {}; var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + var stLineCount = objNewRecord.getLineCount({ sublistId: 'item' }); + for (var i = 0; i < stLineCount; i++) { var stItemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); //Check if item is one of the configured extend items if (stExtendItemId === stItemId) { log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); //get qty of contracts created & compare to extend item qty - var stContractQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_qty', line: i }); + var stContractID = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i }); + log.debug('_getExtendData: stContractID', stContractID + '|' + typeof arrContracyQty); + var arrContracyQty = JSON.parse(stContractID); + log.debug('_getExtendData: arrContracyQty', arrContracyQty + '|' + typeof arrContracyQty); + var stContractQty = arrContracyQty.length; + log.debug('_getExtendData: stContractQty', stContractQty + '|' + typeof arrContracyQty); + var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); if (stContractQty < stExtendItemQty) { @@ -166,39 +195,47 @@ define([ log.debug('EXTEND UTIL _createExtendOrder: Extend Response Body Parsed: ', objExtendResponseBody); var arrLineItems = objExtendResponseBody.lineItems; var objExtendResponseData = {}; - + log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData: ', objExtendResponseData); + var arrContractID = []; + var arrLeadToken = []; for (var i = 0; i < arrLineItems.length; i++) { log.debug('EXTEND UTIL _createExtendOrder: arrLineItems: ', arrLineItems[i]); var line = arrLineItems[i].lineItemTransactionId; - line = line.substring(objSalesOrderRecord.id.toString().length, line.length); + // line = line.substring(objSalesOrderRecord.id.toString().length, line.length); + line = line.split('-'); + line = line[1]; log.debug('EXTEND UTIL _createExtendOrder: line: ', line + '|' + typeof line); stUniqueKey = line; - objExtendResponseData[stUniqueKey] = {} - objExtendResponseData[stUniqueKey].contractIds = []; - objExtendResponseData[stUniqueKey].leadTokens = []; - - if (arrLineItems[i].type == 'contract') { - var arrContractIds = []; - arrContractIds = objExtendResponseData[stUniqueKey].contractIds; - log.debug('EXTEND UTIL _createExtendOrder: arrContractIds: ', arrContractIds); - log.debug('EXTEND UTIL _createExtendOrder: contractid arrLineItems: ', arrLineItems[i].id); - if (arrLineItems[i].contractId) { - arrContractIds.push(arrLineItems[i].id) + objExtendResponseData[stUniqueKey] = {}; + log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData: ', objExtendResponseData); + log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData[stUniqueKey]: ', objExtendResponseData[stUniqueKey]); + + + objExtendResponseData[stUniqueKey].lineItemTransactionId = arrLineItems[i].lineItemTransactionId; + + for (var j = 0; j < arrLineItems.length; j++) { + if (arrLineItems[j].type == 'contract') { + log.debug('EXTEND UTIL _createExtendOrder: contractid arrLineItems: ', arrLineItems[j].id); + if (arrLineItems[i].id) { + objExtendResponseData[stUniqueKey].contractIds.push(arrLineItems[j].id); } - objExtendResponseData[stUniqueKey].contractIds = arrContractIds; } - if (arrLineItems[i].type == 'lead') { - var arrLeadIds = []; - arrLeadIds = objExtendResponseData[stUniqueKey].leadTokens; - log.debug('EXTEND UTIL _createExtendOrder: arrLeadIds: ', arrLeadIds); - log.debug('EXTEND UTIL _createExtendOrder: contractid arrLineItems: ', arrLineItems[i].leadToken); - if (arrLineItems[i].leadToken) { - arrLeadIds.push(arrLineItems[i].leadToken) + if (arrLineItems[j].type == 'lead') { + // var arrLeadIds = []; + // arrLeadIds = objExtendResponseData[stUniqueKey].leadTokens; + // log.debug('EXTEND UTIL _createExtendOrder: arrLeadIds: ', arrLeadIds); + // log.debug('EXTEND UTIL _createExtendOrder: leadTokens arrLineItems: ', arrLineItems[i].leadToken); + if (arrLineItems[j].leadToken) { + objExtendResponseData[stUniqueKey].leadTokens.push(arrLineItems[j].leadToken); + // arrLeadIds.push(arrLineItems[i].leadToken) } - objExtendResponseData[stUniqueKey].leadTokens = arrLeadIds; + //objExtendResponseData[stUniqueKey].leadTokens = arrLeadIds; } } + objExtendResponseData[stUniqueKey].contractIds = []; + objExtendResponseData[stUniqueKey].leadTokens = []; + } log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData', objExtendResponseData); for (key in objExtendResponseData) { @@ -209,7 +246,7 @@ define([ // on the Sales Order line objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: key, value: JSON.stringify(objExtendResponseData[key].contractIds) }); objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_lead_token', line: key, value: JSON.stringify(objExtendResponseData[key].leadTokens) }); - objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_so_line', line: key, value: key }); + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: key, value: JSON.stringify(objExtendResponseData[key].lineItemTransactionId) }); } return objSalesOrderRecord; @@ -281,29 +318,32 @@ define([ objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; objExtendItemData[stUniqueKey].extend_line = i; objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); - + //set Extend Line Item Transaction ID of related product on Extend Line + var stRelatedItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; + log.debug('_getExtendData: stRelatedItemID ', stRelatedItemID); + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_so_line', line: i, value: stRelatedItemID }); } } } else { // Start building the Extend Order Item Info Object objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); objExtendItemData[stUniqueKey].itemId = stItemId - objExtendItemData[stUniqueKey].uniqueLine = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'lineuniquekey', line: i }); + //objExtendItemData[stUniqueKey].uniqueLine = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'lineuniquekey', line: i }); objExtendItemData[stUniqueKey].line = i; objExtendItemData[stUniqueKey].purchase_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); - objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + i; + objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; } } return objExtendItemData; }; // Build the Extend API JSON for order lines - exports.buildExtendItemJSON = function (objValues) { + exports.buildExtendItemJSON = function (objValues, objExtendConfig) { //item json var lineItems = []; for (key in objValues) { //get product refId - objValues.refId = exports.getItemRefId(objValues[key].itemId); + objValues.refId = exports.getItemRefId(objValues[key].itemId, objExtendConfig); var item = { 'product': { 'id': objValues.refId, @@ -329,14 +369,14 @@ define([ return lineItems; }; // Build the Extend API JSON for order creation - exports.buildExtendOrderJSON = function (objValues) { + exports.buildExtendOrderJSON = function (objValues, config) { log.debug('EXTEND UTIL _buildExtendOrderJSON:', '**ENTER**'); // Date is a string and we need to format for extend const stTranDate = new Date(objValues.tran_date); //If Demo use demo email for contracts - var config = EXTEND_CONFIG.getConfig(); +// var config = EXTEND_CONFIG.getConfig(); if (config.email) { objValues.email = config.email; } @@ -409,8 +449,8 @@ define([ return objAddress; } //get Item's reference ID - exports.getItemRefId = function (stItemId) { - var config = EXTEND_CONFIG.getConfig(); + exports.getItemRefId = function (stItemId, config) { + // var config = EXTEND_CONFIG.getConfig(); var refIdValue = config.refId; var stItemRefId = stItemId; if (refIdValue) { diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js index 56c697f..87ed6d5 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js @@ -11,13 +11,15 @@ *@NScriptType MapReduceScript *@ModuleScope Public */ - define([ +define([ 'N/runtime', 'N/record', 'N/search', - '../lib/customscript_ext_util' + '../lib/customscript_ext_util', + '../lib/customscript_ext_config_lib' + ], - function (runtime, record, search, EXTEND_UTIL) { + function (runtime, record, search, EXTEND_UTIL, EXTEND_CONFIG) { var exports = {}; exports.getInputData = function () { @@ -37,20 +39,62 @@ log.error('getInputData', 'error: ' + e); } } + + exports.map = function (context) { + try { + log.debug('map', '** START **'); + log.audit('map context', context); + + var contextValues = JSON.parse(context.value); + var stFulfillmentId = contextValues.id; + var stSalesOrderId = contextValues.values.createdfrom.value; + log.audit('stSalesOrderId | stFulfillmentId', stSalesOrderId + '|' + stFulfillmentId); + + context.write({ + key: stSalesOrderId, + value: stFulfillmentId + }); + + } catch (e) { + log.error('map', 'error: ' + e); + var id = record.submitFields({ + type: record.Type.SALES_ORDER, + id: stSalesOrderId, + values: { + 'custbody_ext_process_error': true + }, + options: { + enableSourcing: false, + ignoreMandatoryFields: true + } + }); + //create user note attached to record + var objNoteRecord = record.create({ + type: record.Type.NOTE, + }) + objNoteRecord.setValue('transaction', stSalesOrderId); + objNoteRecord.setValue('title', stSalesOrderId); + objNoteRecord.setValue('note', e.message); + objNoteRecord.save(); + + } + } exports.reduce = function (context) { try { log.debug('reduce', '** START **'); log.audit('reduce', 'context: ' + context); - var stFulfillmentId = context.key; - log.audit('reduce', 'stFulfillmentId: ' + stFulfillmentId); + var stSalesOrderId = context.key; + log.audit('reduce', 'stSalesOrderId: ' + stSalesOrderId); + var stFulfillmentId = context.value; //Load associated Saled Order Record - var objFulfillmentRecord = record.load({ - type: record.Type.ITEM_FULFILLMENT, - id: stFulfillmentId + var objSalesOrderRecord = record.load({ + type: 'salesorder', + id: stSalesOrderId }); - // Get Extend Details from Sales Order - objExtendData = EXTEND_UTIL.fulfillExtendOrder(objFulfillmentRecord); + // Get Extend Details from Fulfillment + var objExtendConfig = EXTEND_CONFIG.getConfig(); + objExtendData = EXTEND_UTIL.fulfillExtendOrder(objSalesOrderRecord, stFulfillmentId, objExtendConfig); } catch (e) { log.error('reduce', 'key: ' + context.key + ' error: ' + e); From c430b163ac8b59c62ed24e2a4b44157966ceafe2 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Tue, 8 Nov 2022 11:23:48 -0600 Subject: [PATCH 16/33] fulfillment updates --- .../lib/customscript_ext_util.js | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index edafcae..782d967 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -84,14 +84,17 @@ define([ log.audit('EXTEND UTIL _fulfillExtendOrder: objExtendFulfillRequestJSON', objExtendFulfillRequestJSON); // Create contract call for quantity fulfilled on the Extend item for (var i = 0; i < objExtendData[key].quantity; i++) { - + //get extend contract array for line + log.debug('EXTEND UTIL _fulfillExtendOrder: objExtendFulfillRequestJSON',objExtendData[key].contractIds); //call api var objExtendResponse = EXTEND_API.fulfillOrderLine(objExtendFulfillRequestJSON, objExtendConfig); log.audit('EXTEND UTIL _fulfillExtendOrder: Extend Response Object: ', objExtendResponse); //handle response if (objExtendResponse.code === 201) { var objExtendResponseBody = JSON.parse(objExtendResponse.body); - exports.handleFulfillResponse(objExtendResponseBody, objSalesOrderRecord); + //push new contract id to contracts array + objExtendData[key].contractIds.push(); + //submit fields to IF record.submitFields({ type: record.Type.ITEM_FULFILLMENT, @@ -129,6 +132,8 @@ define([ var stNoteId = objNoteRecord.save(); } } + //set contract column on SO line + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: key, value: JSON.stringify(objExtendData[key].contractIds) }); } objFulfillmentRecord.save(); @@ -150,16 +155,13 @@ define([ if (stExtendItemId === stItemId) { log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); //get qty of contracts created & compare to extend item qty - var stContractID = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i }); - log.debug('_getExtendData: stContractID', stContractID + '|' + typeof arrContracyQty); - var arrContracyQty = JSON.parse(stContractID); - log.debug('_getExtendData: arrContracyQty', arrContracyQty + '|' + typeof arrContracyQty); - var stContractQty = arrContracyQty.length; - log.debug('_getExtendData: stContractQty', stContractQty + '|' + typeof arrContracyQty); + var arrContracyQty = JSON.parse(objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i })); + log.debug('_getExtendData: stContractID', arrContracyQty + '|' + typeof arrContracyQty); + objExtendItemData[stUniqueKey].contractIds = arrContracyQty; var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); - if (stContractQty < stExtendItemQty) { + if (arrContracyQty.length < stExtendItemQty) { //get related item from extend line var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); @@ -177,7 +179,6 @@ define([ objExtendItemData[stUniqueKey].quantity = Math.min(stRelatedItemQtyFulfilled, (stExtendItemQty - stContractQty)); objExtendItemData[stUniqueKey].line = i; objExtendItemData[stUniqueKey].lineItemID = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: i }); - } } } From bb434d51887342cc5e384722c367b968f5c8b84b Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Tue, 8 Nov 2022 17:19:41 -0600 Subject: [PATCH 17/33] order/fulfill updates --- .../lib/customscript_ext_util.js | 126 ++++++++++-------- .../customscript_ext_fulfill_order_mr.js | 51 +------ 2 files changed, 78 insertions(+), 99 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index d73910d..e7aa19a 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -69,7 +69,7 @@ define([ //fulfill items on order exports.fulfillExtendOrder = function (objSalesOrderRecord, stFulfillmentId, objExtendConfig) { log.audit('EXTEND UTIL _fulfillExtendOrder:', '**ENTER**'); - log.audit('EXTEND UTIL _fulfillExtendOrder: SO ID', objSalesOrderRecord.id); + log.audit('EXTEND UTIL _fulfillExtendOrder: SO ID', objSalesOrderRecord.id + '|' + stFulfillmentId); //build order data obj var objExtendData = {}; @@ -82,33 +82,22 @@ define([ var objExtendFulfillRequestJSON = {}; objExtendFulfillRequestJSON = exports.buildExtendFulfillJSON(objExtendData[key]); log.audit('EXTEND UTIL _fulfillExtendOrder: objExtendFulfillRequestJSON', objExtendFulfillRequestJSON); + var bSuccess = true; // Create contract call for quantity fulfilled on the Extend item for (var i = 0; i < objExtendData[key].quantity; i++) { //get extend contract array for line - log.debug('EXTEND UTIL _fulfillExtendOrder: objExtendFulfillRequestJSON',objExtendData[key].contractIds); + log.debug('EXTEND UTIL _fulfillExtendOrder: objExtendFulfillRequestJSON', objExtendData[key].contractIds + typeof objExtendData[key].contractIds); //call api var objExtendResponse = EXTEND_API.fulfillOrderLine(objExtendFulfillRequestJSON, objExtendConfig); log.audit('EXTEND UTIL _fulfillExtendOrder: Extend Response Object: ', objExtendResponse); //handle response - if (objExtendResponse.code === 201) { + if (objExtendResponse.code === 200 || objExtendResponse.code === 201) { var objExtendResponseBody = JSON.parse(objExtendResponse.body); //push new contract id to contracts array - objExtendData[key].contractIds.push(); - - //submit fields to IF - record.submitFields({ - type: record.Type.ITEM_FULFILLMENT, - id: stFulfillmentId, - values: { - 'custbody_ext_order_create': true - }, - options: { - enableSourcing: false, - ignoreMandatoryFields : true - } - }); + objExtendData[key].contractIds.push(objExtendResponseBody.contractId); } else { + bSuccess = false; log.error('EXTEND UTIL _fulfillExtendOrder', objExtendResponse); //submit fields record.submitFields({ @@ -119,7 +108,7 @@ define([ }, options: { enableSourcing: false, - ignoreMandatoryFields : true + ignoreMandatoryFields: true } }); // create user note attached to record @@ -131,11 +120,27 @@ define([ objNoteRecord.setValue('note', JSON.stringify(objExtendResponse)); var stNoteId = objNoteRecord.save(); } + //submit fields to IF + if(bSuccess){ + record.submitFields({ + type: record.Type.ITEM_FULFILLMENT, + id: stFulfillmentId, + values: { + 'custbody_ext_order_create': true + }, + options: { + enableSourcing: false, + ignoreMandatoryFields: true + } + }); + } } + log.debug('EXTEND UTIL _fulfillExtendOrder: contractIDs', key + '|' + objExtendData[key].contractIds); + //set contract column on SO line objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: key, value: JSON.stringify(objExtendData[key].contractIds) }); } - objFulfillmentRecord.save(); + objSalesOrderRecord.save(); }; @@ -145,14 +150,14 @@ define([ log.audit('EXTEND UTIL _refundExtendOrder: objRefundData', JSON.stringify(objRefundData)); var config = EXTEND_CONFIG.getConfig(); - var objLineToRefund = {'lineItemTransactionId': objRefundData['lineItemTransactionId']} + var objLineToRefund = { 'lineItemTransactionId': objRefundData['lineItemTransactionId'] } var objExtendResponse = EXTEND_API.refundContract(objLineToRefund, config); log.audit('EXTEND UTIL _refundExtendOrder: Extend Response Object: ', objExtendResponse); var objRefundedRecord = record.load({ - type: objRefundData.TYPE, - id: objRefundData.ID - }); + type: objRefundData.TYPE, + id: objRefundData.ID + }); //handle response if (objExtendResponse.code === 201) { @@ -200,14 +205,14 @@ define([ if (stExtendItemId === stItemId) { log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); //get qty of contracts created & compare to extend item qty - var arrContracyQty = JSON.parse(objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i })); - log.debug('_getExtendData: stContractID', arrContracyQty + '|' + typeof arrContracyQty); - objExtendItemData[stUniqueKey].contractIds = arrContracyQty; - + var stContractIDs = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i }); + var arrContractIDs = JSON.parse(stContractIDs); + log.debug('_getExtendData: stContractID', arrContractIDs + '|' + typeof arrContractIDs); + // var arrContracyQty = JSON.parse(objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i })); var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); - if (arrContracyQty.length < stExtendItemQty) { - + if (arrContractIDs.length < stExtendItemQty) { +var stContractQty = arrContractIDs.length; //get related item from extend line var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); //check for new fulfillments @@ -224,6 +229,8 @@ define([ objExtendItemData[stUniqueKey].quantity = Math.min(stRelatedItemQtyFulfilled, (stExtendItemQty - stContractQty)); objExtendItemData[stUniqueKey].line = i; objExtendItemData[stUniqueKey].lineItemID = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: i }); + objExtendItemData[stUniqueKey].contractIds = arrContractIDs; + } } } @@ -241,59 +248,64 @@ define([ log.debug('EXTEND UTIL _createExtendOrder: Extend Response Body Parsed: ', objExtendResponseBody); var arrLineItems = objExtendResponseBody.lineItems; var objExtendResponseData = {}; + log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData: ', objExtendResponseData); - var arrContractID = []; - var arrLeadToken = []; for (var i = 0; i < arrLineItems.length; i++) { log.debug('EXTEND UTIL _createExtendOrder: arrLineItems: ', arrLineItems[i]); var line = arrLineItems[i].lineItemTransactionId; - // line = line.substring(objSalesOrderRecord.id.toString().length, line.length); + // line = line.substring(objSalesOrderRecord.id.toString().length, line.length); line = line.split('-'); - line = line[1]; + log.debug('EXTEND UTIL _createExtendOrder: line: ', line + '|' + typeof line); - stUniqueKey = line; + stUniqueKey = line[1]; + objExtendResponseData[stUniqueKey] = {}; - log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData: ', objExtendResponseData); + objExtendResponseData[stUniqueKey].contractIds = []; + objExtendResponseData[stUniqueKey].leadTokens = []; + objExtendResponseData[stUniqueKey].lineItemTransactionId = arrLineItems[i].lineItemTransactionId; + if (line[2]) { + objExtendResponseData[stUniqueKey].extendLine = line[2]; + } log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData[stUniqueKey]: ', objExtendResponseData[stUniqueKey]); + } + for (var j = 0; j < arrLineItems.length; j++) { + log.debug('EXTEND UTIL _createExtendOrder: j loop arrLineItems: ', arrLineItems[j]); + var line = arrLineItems[j].lineItemTransactionId; + // line = line.substring(objSalesOrderRecord.id.toString().length, line.length); + line = line.split('-'); + stUniqueKey = line[1]; - objExtendResponseData[stUniqueKey].lineItemTransactionId = arrLineItems[i].lineItemTransactionId; - - for (var j = 0; j < arrLineItems.length; j++) { if (arrLineItems[j].type == 'contract') { - log.debug('EXTEND UTIL _createExtendOrder: contractid arrLineItems: ', arrLineItems[j].id); - if (arrLineItems[i].id) { - objExtendResponseData[stUniqueKey].contractIds.push(arrLineItems[j].id); + log.debug('EXTEND UTIL _createExtendOrder: j loop contractid arrLineItems: ', arrLineItems[j].contractId); + if (arrLineItems[j].contractId) { + objExtendResponseData[stUniqueKey].contractIds.push(arrLineItems[j].contractId); } } if (arrLineItems[j].type == 'lead') { - // var arrLeadIds = []; - // arrLeadIds = objExtendResponseData[stUniqueKey].leadTokens; - // log.debug('EXTEND UTIL _createExtendOrder: arrLeadIds: ', arrLeadIds); - // log.debug('EXTEND UTIL _createExtendOrder: leadTokens arrLineItems: ', arrLineItems[i].leadToken); + log.debug('EXTEND UTIL _createExtendOrder: j loop leadTokens arrLineItems: ', arrLineItems[j].leadToken); if (arrLineItems[j].leadToken) { objExtendResponseData[stUniqueKey].leadTokens.push(arrLineItems[j].leadToken); - // arrLeadIds.push(arrLineItems[i].leadToken) } - //objExtendResponseData[stUniqueKey].leadTokens = arrLeadIds; } } - objExtendResponseData[stUniqueKey].contractIds = []; - objExtendResponseData[stUniqueKey].leadTokens = []; - } log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData', objExtendResponseData); for (key in objExtendResponseData) { log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData[key].contractIds: ', key + '|' + objExtendResponseData[key].contractIds); log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData[key].leadTokens: ', key + '|' + objExtendResponseData[key].leadTokens); + log.debug('EXTEND UTIL _createExtendOrder: objExtendResponseData[key].lineItemTransactionId: ', key + '|' + objExtendResponseData[key].lineItemTransactionId); // If Extend contract is created, populate the appropriate custom column field for contracts // on the Sales Order line objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: key, value: JSON.stringify(objExtendResponseData[key].contractIds) }); objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_lead_token', line: key, value: JSON.stringify(objExtendResponseData[key].leadTokens) }); - objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: key, value: JSON.stringify(objExtendResponseData[key].lineItemTransactionId) }); + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: key, value: objExtendResponseData[key].lineItemTransactionId }); + if (objExtendResponseData[key].extendLine) { + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: objExtendResponseData[key].extendLine, value: JSON.stringify(objExtendResponseData[key].contractIds) }); + } } return objSalesOrderRecord; @@ -352,6 +364,7 @@ define([ //get related item from extend line var stExtendItemRefId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + for (var j = 0; j < stLineCount; j++) { var stRelatedItem = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); if (stRelatedItem === stExtendItemRefId) { @@ -365,9 +378,9 @@ define([ objExtendItemData[stUniqueKey].extend_line = i; objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); //set Extend Line Item Transaction ID of related product on Extend Line + objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; var stRelatedItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; - log.debug('_getExtendData: stRelatedItemID ', stRelatedItemID); - objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_so_line', line: i, value: stRelatedItemID }); + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: i, value: stRelatedItemID }); } } } else { @@ -378,6 +391,9 @@ define([ objExtendItemData[stUniqueKey].line = i; objExtendItemData[stUniqueKey].purchase_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; + if (objExtendItemData[stUniqueKey].extend_line) { + objExtendItemData[stUniqueKey].lineItemID = objExtendItemData[stUniqueKey].lineItemID + "-" + objExtendItemData[stUniqueKey].extend_line; + } } } @@ -422,7 +438,7 @@ define([ const stTranDate = new Date(objValues.tran_date); //If Demo use demo email for contracts -// var config = EXTEND_CONFIG.getConfig(); + // var config = EXTEND_CONFIG.getConfig(); if (config.email) { objValues.email = config.email; } @@ -496,7 +512,7 @@ define([ } //get Item's reference ID exports.getItemRefId = function (stItemId, config) { - // var config = EXTEND_CONFIG.getConfig(); + // var config = EXTEND_CONFIG.getConfig(); var refIdValue = config.refId; var stItemRefId = stItemId; if (refIdValue) { diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js index 87ed6d5..68846c5 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js @@ -50,43 +50,6 @@ define([ var stSalesOrderId = contextValues.values.createdfrom.value; log.audit('stSalesOrderId | stFulfillmentId', stSalesOrderId + '|' + stFulfillmentId); - context.write({ - key: stSalesOrderId, - value: stFulfillmentId - }); - - } catch (e) { - log.error('map', 'error: ' + e); - var id = record.submitFields({ - type: record.Type.SALES_ORDER, - id: stSalesOrderId, - values: { - 'custbody_ext_process_error': true - }, - options: { - enableSourcing: false, - ignoreMandatoryFields: true - } - }); - //create user note attached to record - var objNoteRecord = record.create({ - type: record.Type.NOTE, - }) - objNoteRecord.setValue('transaction', stSalesOrderId); - objNoteRecord.setValue('title', stSalesOrderId); - objNoteRecord.setValue('note', e.message); - objNoteRecord.save(); - - } - } - exports.reduce = function (context) { - try { - log.debug('reduce', '** START **'); - log.audit('reduce', 'context: ' + context); - - var stSalesOrderId = context.key; - log.audit('reduce', 'stSalesOrderId: ' + stSalesOrderId); - var stFulfillmentId = context.value; //Load associated Saled Order Record var objSalesOrderRecord = record.load({ type: 'salesorder', @@ -96,9 +59,10 @@ define([ var objExtendConfig = EXTEND_CONFIG.getConfig(); objExtendData = EXTEND_UTIL.fulfillExtendOrder(objSalesOrderRecord, stFulfillmentId, objExtendConfig); + } catch (e) { - log.error('reduce', 'key: ' + context.key + ' error: ' + e); - record.submitFields({ + log.error('map', 'error: ' + e); + var id = record.submitFields({ type: record.Type.ITEM_FULFILLMENT, id: stFulfillmentId, values: { @@ -109,15 +73,14 @@ define([ ignoreMandatoryFields: true } }); - // create user note attached to record + //create user note attached to record var objNoteRecord = record.create({ type: record.Type.NOTE, }) objNoteRecord.setValue('transaction', stFulfillmentId); - objNoteRecord.setValue('title', 'Extend Error Order Create'); - objNoteRecord.setValue('note', JSON.stringify(e.message)); - var stNoteId = objNoteRecord.save(); - log.debug('reduce', 'stNoteId: ' + stNoteId); + objNoteRecord.setValue('title', stFulfillmentId); + objNoteRecord.setValue('note', e.message); + objNoteRecord.save(); } } From 854317d921bb43f7a71ee8ee3428a3488534d70a Mon Sep 17 00:00:00 2001 From: alopez-extend <87334339+alopez-extend@users.noreply.github.com> Date: Wed, 9 Nov 2022 08:30:02 -0600 Subject: [PATCH 18/33] Updates to Refund by Contract ID --- .../lib/customscript_ext_api_lib.js | 27 +++++++- .../lib/customscript_ext_util.js | 64 ++++++++++++++++--- .../customscript_ext_refund_contract_mr.js | 30 ++++++--- 3 files changed, 103 insertions(+), 18 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js index f3073b6..9dedfb5 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_api_lib.js @@ -200,7 +200,8 @@ headers: { 'Content-Type': 'application/json', 'X-Extend-Access-Token': config.key, - 'Accept': 'application/json;version=' + config.version + 'Accept': 'application/json;version=' + config.version, + 'X-Idempotency-Key': exports.generateUUID() }, body: JSON.stringify(objOrderDetails), }); @@ -219,12 +220,16 @@ exports.fulfillOrderLine = function (objOrderDetails, config) { // var config = extendConfig.getConfig(); try { + var guid = exports.generateUUID(); + log.debug('guid', guid); + var response = https.post({ url: config.domain + '/line-items/fulfill', headers: { 'Content-Type': 'application/json', 'X-Extend-Access-Token': config.key, - 'Accept': 'application/json;version=' + config.version + 'Accept': 'application/json;version=' + config.version, + 'X-Idempotency-Key' : exports.generateUUID() }, body: JSON.stringify(objOrderDetails), }); @@ -243,6 +248,9 @@ */ exports.refundContract = function (objRefundDetails, config) { // var config = extendConfig.getConfig(); + + log.debug('requestRefund', "objRefundDetails - "+JSON.stringify(objRefundDetails)) + try { var response = https.post({ url: config.domain + '/refunds', @@ -309,6 +317,21 @@ return; } }; +exports.generateUUID = function () { + var d = new Date().getTime();//Timestamp + var d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now()*1000)) || 0;//Time in microseconds since page-load or 0 if unsupported + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random() * 16;//random number between 0 and 16 + if(d > 0){//Use timestamp until depleted + r = (d + r)%16 | 0; + d = Math.floor(d/16); + } else {//Use microseconds since page-load if supported + r = (d2 + r)%16 | 0; + d2 = Math.floor(d2/16); + } + return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); + }); +} return exports; }); diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 69cda7f..2aaaaf3 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -118,10 +118,47 @@ define([ log.audit('EXTEND UTIL _refundExtendOrder:', '**ENTER**'); log.audit('EXTEND UTIL _refundExtendOrder: objRefundData', JSON.stringify(objRefundData)); - var config = EXTEND_CONFIG.getConfig(); - var objLineToRefund = {'lineItemTransactionId': objRefundData['lineItemTransactionId']} - var objExtendResponse = EXTEND_API.refundContract(objLineToRefund, config); - log.audit('EXTEND UTIL _refundExtendOrder: Extend Response Object: ', objExtendResponse); + var intQuantityToRefund = parseInt(objRefundData['QTY']); + var arrActiveIDs = objRefundData['activeIDs']; + var arrCanceledIDs = objRefundData['canceledIDs']; + // var objLineToRefund = {'lineItemTransactionId' : objRefundData['lineItemTransactionId']} + // var objContractToRefund = {'contractId' : objRefundData['lineItemTransactionId']} + + //check if contract id has been canceled + function checkIfCanceled(contractToCancel, arrCanceledIDs){ + return arrCanceledIDs.length >0 ? arrCanceledIDs.includes(contractToCancel) : false; + } + + var intContractsCanceled = arrCanceledIDs ? arrCanceledIDs.length : 0; + var intContractsStillActive = arrActiveIDs ? arrActiveIDs.length - intContractsCanceled : 0; + + if(intContractsStillActive>0){ + log.debug('refundExtendOrder', "There is/are still "+intContractsStillActive+" active contract(s)."); + + var config = EXTEND_CONFIG.getConfig(); + + for (var index = 0; index < arrActiveIDs.length; index++) { + var contractId = arrActiveIDs[index]; + var bIsCanceled = checkIfCanceled(contractId, arrCanceledIDs); + + if(bIsCanceled){ + log.debug('refundExtendOrder', contractId + " has been canceled."); + continue; + }else{ + log.debug('refundExtendOrder', "Attempting to cancel "+contractId); + var objContractToRefund = {'contractId' : contractId} + var objExtendResponse = EXTEND_API.refundContract(objContractToRefund, config); + + if (objExtendResponse.code === 201) { + arrCanceledIDs.push(contractId); + log.debug("refundExtendOrder", JSON.stringify(arrCanceledIDs)); + } + + } + } + }else{ + log.error('refundExtendOrder', "All contracts have been refunded/canceled."); + } var objRefundedRecord = record.load({ type: objRefundData.TYPE, @@ -133,8 +170,20 @@ define([ var objExtendResponseBody = JSON.parse(objExtendResponse.body); log.debug('EXTEND UTIL _refundExtendOrder: objExtendResponseBody: ', JSON.stringify(objExtendResponseBody)); + var lineNumber = objRefundedRecord.findSublistLineWithValue({ + sublistId: 'item', + fieldId: 'lineuniquekey', + value: objRefundData['UNIQUE_KEY'] + }); + log.debug("refundExtendOrder", "lineNumber - "+ lineNumber) // exports.handleOrderResponse(objExtendResponseBody, objRefundedRecord); + objRefundedRecord.setSublistValue({ + sublistId: 'item', + fieldId: 'custcol_ext_canceled_contract_ids', + line: lineNumber, + value: JSON.stringify(arrCanceledIDs) + }); //make transaction as extend order processed objRefundedRecord.setValue({ fieldId: 'custbody_ext_order_create', value: true }); // var stExtendOrderId = objExtendResponseBody.id; @@ -291,7 +340,6 @@ define([ objExtendData.ship_country = objShipAddress.country; return objExtendData; }; - exports.getSalesOrderItemInfo = function (objSalesOrderRecord) { //////////////////////////SUPPORT FUNCTIONS/////////////////////////// var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); @@ -424,7 +472,7 @@ define([ 'lineItemTransactionId': objValues.lineItemID } return objJSON; - } + }; /***********************************Support Functions********************************************/ //get Address Subrecord fields from transaction exports.getAddress = function (objSalesOrderRecord, addressField) { @@ -452,7 +500,7 @@ define([ }) }; return objAddress; - } + }; //get Item's reference ID exports.getItemRefId = function (stItemId) { var config = EXTEND_CONFIG.getConfig(); @@ -473,7 +521,7 @@ define([ } return stItemRefId; - } + }; //get Transaction Date required for contract create exports.getTransactionDate = function (stDate) { var stTimeDate = new Date(stDate); diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js index 3f2cdcb..2aa33aa 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js @@ -43,25 +43,39 @@ log.debug('reduce', '** START **'); var stRefundId = context.key; - log.audit('reduce', 'stRefundId: ' + stRefundId); + log.debug('reduce', 'stRefundId: ' + stRefundId); var objContextValues = JSON.parse(context.values[0]); - log.audit('reduce', 'objContextValues: ' + JSON.stringify(objContextValues)); + log.debug('reduce', 'objContextValues: ' + JSON.stringify(objContextValues)); var stRefundType = objContextValues['recordType'] - log.audit('reduce', 'stRefundType: ' + stRefundType); + log.debug('reduce', 'stRefundType: ' + stRefundType); - var stLineTranID = objContextValues.values.custcol_ext_so_line - log.audit('reduce', 'stLineTranID: ' + stLineTranID); + var stLineUniqueKey = objContextValues.values.lineuniquekey; + log.debug('reduce', 'stLineUniqueKey: ' + stLineUniqueKey); - var stLineSequenceNum = objContextValues.values.linesequencenumber - 1; - log.audit('reduce', 'stLineSequenceNum: ' + stLineSequenceNum); + var stQuantityToRefund = objContextValues.values.quantity + log.debug('reduce', 'stQuantityToRefund: ' + stQuantityToRefund); + + var stLineTranID = objContextValues.values.custcol_ext_line_id + log.debug('reduce', 'stLineTranID: ' + stLineTranID); + + var arrActiveIDs = objContextValues.values.custcol_ext_contract_id; + log.debug('reduce', 'arrActiveIDs: ' + arrActiveIDs + " type - "+typeof arrActiveIDs); + arrActiveIDs = arrActiveIDs ? JSON.parse(arrActiveIDs) : []; + + var arrCanceledIDs = objContextValues.values.custcol_ext_canceled_contract_ids; + log.debug('reduce', 'arrCanceledIDs: ' + arrCanceledIDs + " type - "+typeof arrCanceledIDs); + arrCanceledIDs = arrCanceledIDs ? JSON.parse(arrCanceledIDs) : []; var objRefundData = { 'ID' : stRefundId, 'TYPE' : stRefundType, + 'UNIQUE_KEY' : stLineUniqueKey, + 'QTY' : stQuantityToRefund, 'lineItemTransactionId' : stLineTranID, - 'LINE_NUM' : stLineSequenceNum + 'activeIDs' : arrActiveIDs, + 'canceledIDs' : arrCanceledIDs } //call to refund by line item transaction id From 920bcc759ec53f8c36428f16b2511c5483c7ad15 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Thu, 8 Dec 2022 12:55:28 -0800 Subject: [PATCH 19/33] leadtoken contract --- .../lib/customscript_ext_util.js | 137 +++++++++++------- 1 file changed, 84 insertions(+), 53 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index a10dce1..f4a5794 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -121,7 +121,7 @@ define([ var stNoteId = objNoteRecord.save(); } //submit fields to IF - if(bSuccess){ + if (bSuccess) { record.submitFields({ type: record.Type.ITEM_FULFILLMENT, id: stFulfillmentId, @@ -156,38 +156,38 @@ define([ // var objContractToRefund = {'contractId' : objRefundData['lineItemTransactionId']} //check if contract id has been canceled - function checkIfCanceled(contractToCancel, arrCanceledIDs){ - return arrCanceledIDs.length >0 ? arrCanceledIDs.includes(contractToCancel) : false; + function checkIfCanceled(contractToCancel, arrCanceledIDs) { + return arrCanceledIDs.length > 0 ? arrCanceledIDs.includes(contractToCancel) : false; } var intContractsCanceled = arrCanceledIDs ? arrCanceledIDs.length : 0; var intContractsStillActive = arrActiveIDs ? arrActiveIDs.length - intContractsCanceled : 0; - if(intContractsStillActive>0){ - log.debug('refundExtendOrder', "There is/are still "+intContractsStillActive+" active contract(s)."); + if (intContractsStillActive > 0) { + log.debug('refundExtendOrder', "There is/are still " + intContractsStillActive + " active contract(s)."); var config = EXTEND_CONFIG.getConfig(); for (var index = 0; index < arrActiveIDs.length; index++) { var contractId = arrActiveIDs[index]; var bIsCanceled = checkIfCanceled(contractId, arrCanceledIDs); - - if(bIsCanceled){ + + if (bIsCanceled) { log.debug('refundExtendOrder', contractId + " has been canceled."); continue; - }else{ - log.debug('refundExtendOrder', "Attempting to cancel "+contractId); - var objContractToRefund = {'contractId' : contractId} + } else { + log.debug('refundExtendOrder', "Attempting to cancel " + contractId); + var objContractToRefund = { 'contractId': contractId } var objExtendResponse = EXTEND_API.refundContract(objContractToRefund, config); if (objExtendResponse.code === 201) { arrCanceledIDs.push(contractId); log.debug("refundExtendOrder", JSON.stringify(arrCanceledIDs)); } - + } } - }else{ + } else { log.error('refundExtendOrder', "All contracts have been refunded/canceled."); } @@ -206,7 +206,7 @@ define([ fieldId: 'lineuniquekey', value: objRefundData['UNIQUE_KEY'] }); - log.debug("refundExtendOrder", "lineNumber - "+ lineNumber) + log.debug("refundExtendOrder", "lineNumber - " + lineNumber) // exports.handleOrderResponse(objExtendResponseBody, objRefundedRecord); objRefundedRecord.setSublistValue({ @@ -255,13 +255,13 @@ define([ log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); //get qty of contracts created & compare to extend item qty var stContractIDs = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i }); - var arrContractIDs = JSON.parse(stContractIDs); - log.debug('_getExtendData: stContractID', arrContractIDs + '|' + typeof arrContractIDs); - // var arrContracyQty = JSON.parse(objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i })); + var arrContractIDs = JSON.parse(stContractIDs); + log.debug('_getExtendData: stContractID', arrContractIDs + '|' + typeof arrContractIDs); + // var arrContracyQty = JSON.parse(objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i })); var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); if (arrContractIDs.length < stExtendItemQty) { -var stContractQty = arrContractIDs.length; + var stContractQty = arrContractIDs.length; //get related item from extend line var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); //check for new fulfillments @@ -409,29 +409,54 @@ var stContractQty = arrContractIDs.length; //Check if item is one of the configured extend items if (stExtendItemId === stItemId) { log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); + //get value of leadtoken column on extend line + var stLeadToken = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_lead_token', line: i }); + log.debug('_getExtendData: stLeadToken', stLeadToken + '|' + typeof stLeadToken); + + //if extend line has lead token mark isLead = T + if (stLeadToken) { + log.debug('_getExtendData: stLeadToken ', stLeadToken); + objExtendItemData[stUniqueKey] = {}; + objExtendItemData[stUniqueKey].isLead = true; + // Start building the Extend Order Plan Info Object + objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); + objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; + objExtendItemData[stUniqueKey].extend_line = i; + objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); + //set Extend Line Item Transaction ID on Extend Line + objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; + if (objExtendItemData[stUniqueKey].extend_line) { + objExtendItemData[stUniqueKey].lineItemID = objExtendItemData[stUniqueKey].lineItemID + "-" + objExtendItemData[stUniqueKey].extend_line; + } + + } + } + // + else { + //get related item from extend line + var stExtendItemRefId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - //get related item from extend line - var stExtendItemRefId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - - for (var j = 0; j < stLineCount; j++) { - var stRelatedItem = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); - if (stRelatedItem === stExtendItemRefId) { - log.debug('_getExtendData: stRelatedItem| stExtendItemRefId ', stRelatedItem + ' | ' + stExtendItemRefId); - - stUniqueKey = j; - // Start building the Extend Order Plan Info Object - objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); - objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; - objExtendItemData[stUniqueKey].extend_line = i; - objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); - //set Extend Line Item Transaction ID of related product on Extend Line - objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; - var stRelatedItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; - objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: i, value: stRelatedItemID }); + for (var j = 0; j < stLineCount; j++) { + var stRelatedItem = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); + if (stRelatedItem === stExtendItemRefId) { + log.debug('_getExtendData: stRelatedItem| stExtendItemRefId ', stRelatedItem + ' | ' + stExtendItemRefId); + + stUniqueKey = j; + // Start building the Extend Order Plan Info Object + objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); + objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; + objExtendItemData[stUniqueKey].extend_line = i; + objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); + //set Extend Line Item Transaction ID of related product on Extend Line + objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; + var stRelatedItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: i, value: stRelatedItemID }); + } } } - } else { + } + + else { // Start building the Extend Order Item Info Object objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); objExtendItemData[stUniqueKey].itemId = stItemId @@ -452,24 +477,30 @@ var stContractQty = arrContractIDs.length; //item json var lineItems = []; for (key in objValues) { - //get product refId - objValues.refId = exports.getItemRefId(objValues[key].itemId, objExtendConfig); - var item = { - 'product': { - 'id': objValues.refId, - // 'serialNumber': objValues.serial_number, - 'purchasePrice': objValues[key].purchase_price - }, - 'status': 'unfulfilled', - 'quantity': objValues[key].quantity, - 'lineItemTransactionId': objValues[key].lineItemID - } - if (objValues[key].extend_plan_id && objValues[key].plan_price) { - item.plan = { - 'id': objValues[key].extend_plan_id.toString(), - 'purchasePrice': objValues[key].plan_price + //if line is leadToken contract + if (objValues.isLead) { + + } else { + //get product refId + objValues.refId = exports.getItemRefId(objValues[key].itemId, objExtendConfig); + var item = { + 'product': { + 'id': objValues.refId, + // 'serialNumber': objValues.serial_number, + 'purchasePrice': objValues[key].purchase_price + }, + 'status': 'unfulfilled', + 'quantity': objValues[key].quantity, + 'lineItemTransactionId': objValues[key].lineItemID + } + if (objValues[key].extend_plan_id && objValues[key].plan_price) { + item.plan = { + 'id': objValues[key].extend_plan_id.toString(), + 'purchasePrice': objValues[key].plan_price + } } } + lineItems.push(item); From adbefb9160a7bd47fb2c06b1f807eb3c846481f6 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Thu, 8 Dec 2022 12:58:44 -0800 Subject: [PATCH 20/33] leadtoken contract support --- .../lib/customscript_ext_util.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index f4a5794..8d75dcf 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -424,12 +424,7 @@ define([ objExtendItemData[stUniqueKey].extend_line = i; objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); //set Extend Line Item Transaction ID on Extend Line - objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; - if (objExtendItemData[stUniqueKey].extend_line) { - objExtendItemData[stUniqueKey].lineItemID = objExtendItemData[stUniqueKey].lineItemID + "-" + objExtendItemData[stUniqueKey].extend_line; - } - - } + objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; } // else { @@ -460,7 +455,6 @@ define([ // Start building the Extend Order Item Info Object objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); objExtendItemData[stUniqueKey].itemId = stItemId - //objExtendItemData[stUniqueKey].uniqueLine = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'lineuniquekey', line: i }); objExtendItemData[stUniqueKey].line = i; objExtendItemData[stUniqueKey].purchase_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; From fea401ff61e372badb3a360211762f5c9563b2d7 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:52:59 -0600 Subject: [PATCH 21/33] steeda updates --- .../lib/customscript_ext_util.js | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index a10dce1..925a46b 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -3,7 +3,7 @@ *@description: Structures the various JSON request bodies to the Extend API * @NApiVersion 2.x */ -define([ + define([ 'N/runtime', 'N/search', 'N/record', @@ -253,9 +253,13 @@ define([ //Check if item is one of the configured extend items if (stExtendItemId === stItemId) { log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); + var arrContractIDs = []; //get qty of contracts created & compare to extend item qty var stContractIDs = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i }); - var arrContractIDs = JSON.parse(stContractIDs); + if(stContractIDs){ + arrContractIDs = JSON.parse(stContractIDs); + + } log.debug('_getExtendData: stContractID', arrContractIDs + '|' + typeof arrContractIDs); // var arrContracyQty = JSON.parse(objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i })); var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); @@ -264,13 +268,17 @@ define([ var stContractQty = arrContractIDs.length; //get related item from extend line var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + log.debug('_getExtendData: stExtendItemRefId', stExtendItemRefId); + //check for new fulfillments for (var j = 0; j < stLineCount; j++) { var stRelatedItem = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); if (stRelatedItem === stExtendItemRefId) { - var stRelatedItemQtyFulfilled = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantityfulfilled', line: j }); + log.debug('_getExtendData: stRelatedItemQtyFulfilled', stRelatedItemQtyFulfilled); + if (stRelatedItemQtyFulfilled <= stExtendItemQty && stRelatedItemQtyFulfilled > stContractQty) { + log.debug('_getExtendData: in if line 281'); var stUniqueKey = i; // Start building the Extend Order Info Object @@ -403,7 +411,8 @@ var stContractQty = arrContractIDs.length; for (var i = 0; i < stLineCount; i++) { var stItemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); stUniqueKey = i; - if (stExtendItemId !== stItemId) { + //if (stExtendItemId !== stItemId) { + if(!objExtendItemData[stUniqueKey]){ objExtendItemData[stUniqueKey] = {}; } //Check if item is one of the configured extend items @@ -419,8 +428,11 @@ var stContractQty = arrContractIDs.length; log.debug('_getExtendData: stRelatedItem| stExtendItemRefId ', stRelatedItem + ' | ' + stExtendItemRefId); stUniqueKey = j; + if(!objExtendItemData[stUniqueKey]){ + objExtendItemData[stUniqueKey] = {}; + } // Start building the Extend Order Plan Info Object - objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + //objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; objExtendItemData[stUniqueKey].extend_line = i; @@ -443,17 +455,26 @@ var stContractQty = arrContractIDs.length; objExtendItemData[stUniqueKey].lineItemID = objExtendItemData[stUniqueKey].lineItemID + "-" + objExtendItemData[stUniqueKey].extend_line; } } - + } return objExtendItemData; }; // Build the Extend API JSON for order lines exports.buildExtendItemJSON = function (objValues, objExtendConfig) { + log.debug('_buildExtendItemJSON: objExtendConfig ', objExtendConfig); + //item json var lineItems = []; for (key in objValues) { + log.debug('_buildExtendItemJSON: objValues[key ', objValues[key]); + + if(!exports.objectIsEmpty(objValues[key])){ + log.debug('_buildExtendItemJSON: objValues[key ', objValues[key]); + //get product refId objValues.refId = exports.getItemRefId(objValues[key].itemId, objExtendConfig); + log.debug('_buildExtendItemJSON: objValues.refId ', objValues.refId); + var item = { 'product': { 'id': objValues.refId, @@ -471,9 +492,9 @@ var stContractQty = arrContractIDs.length; } } lineItems.push(item); - - } + } + log.debug('_buildExtendItemJSON: lineItems', lineItems); return lineItems; @@ -570,9 +591,14 @@ var stContractQty = arrContractIDs.length; id: stItemId, columns: refIdValue }); + log.debug('EXTEND UTIL _getItemRefId:', arrItemLookup); + for (var prop in arrItemLookup) { - //var stItemRefId = arrItemLookup[prop] - var stItemRefId = arrItemLookup[prop][0].text; + if(arrItemLookup[prop][0].text){ + var stItemRefId = arrItemLookup[prop][0].text; + }else{ + var stItemRefId = arrItemLookup[prop] + } break; } } From 61e77f8f8fdbaabc084ed89018db3c5b692bbfd8 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Tue, 20 Dec 2022 18:08:04 -0600 Subject: [PATCH 22/33] steeda updates --- .../lib/customscript_ext_util.js | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 8d75dcf..fd3055c 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -29,7 +29,7 @@ define([ objExtendData = exports.getSalesOrderInfo(objSalesOrderRecord); log.audit('EXTEND UTIL _createExtendOrder: getSalesOrderInfo objExtendData', objExtendData); //build array of items - var objExtendItemData = exports.getSalesOrderItemInfo(objSalesOrderRecord); + var objExtendItemData = exports.getSalesOrderItemInfo(objSalesOrderRecord, objExtendConfig); log.audit('EXTEND UTIL _createExtendOrder: objExtendItemData', objExtendItemData); //format items objExtendData.lineItems = exports.buildExtendItemJSON(objExtendItemData, objExtendConfig); @@ -241,11 +241,14 @@ define([ }; /***********************************Support Functions********************************************/ - exports.getFulfillmentData = function (objNewRecord) { + exports.getFulfillmentData = function (objNewRecord, objExtendConfig) { log.debug('_getExtendData: Get Extend Data', '**ENTER**'); var objExtendItemData = {}; var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + //move extend item to config record instead of param +// var stExtendItemId = objExtendConfig.protection_plan_item; + var stLineCount = objNewRecord.getLineCount({ sublistId: 'item' }); for (var i = 0; i < stLineCount; i++) { @@ -390,7 +393,7 @@ define([ objExtendData.ship_country = objShipAddress.country; return objExtendData; }; - exports.getSalesOrderItemInfo = function (objSalesOrderRecord) { + exports.getSalesOrderItemInfo = function (objSalesOrderRecord, objExtendConfig) { //////////////////////////SUPPORT FUNCTIONS/////////////////////////// var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); @@ -399,15 +402,17 @@ define([ var objExtendItemData = {}; - var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + var stExtendProductItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + //move extend item to config record instead of param + // var stExtendProductItemId = objExtendConfig.protection_plan_item; for (var i = 0; i < stLineCount; i++) { var stItemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); stUniqueKey = i; - if (stExtendItemId !== stItemId) { + if(!objExtendItemData[stUniqueKey] && (stExtendProductItemId !== stItemId)){ objExtendItemData[stUniqueKey] = {}; } //Check if item is one of the configured extend items - if (stExtendItemId === stItemId) { + if (stExtendProductItemId === stItemId) { log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); //get value of leadtoken column on extend line var stLeadToken = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_lead_token', line: i }); @@ -420,7 +425,7 @@ define([ objExtendItemData[stUniqueKey].isLead = true; // Start building the Extend Order Plan Info Object objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); - objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; + //objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; objExtendItemData[stUniqueKey].extend_line = i; objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); //set Extend Line Item Transaction ID on Extend Line @@ -437,6 +442,9 @@ define([ log.debug('_getExtendData: stRelatedItem| stExtendItemRefId ', stRelatedItem + ' | ' + stExtendItemRefId); stUniqueKey = j; + if(!objExtendItemData[stUniqueKey]){ + objExtendItemData[stUniqueKey] = {}; + } // Start building the Extend Order Plan Info Object objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; @@ -504,7 +512,7 @@ define([ return lineItems; }; // Build the Extend API JSON for order creation - exports.buildExtendOrderJSON = function (objValues, config) { + exports.buildExtendOrderJSON = function (objValues, objExtendConfig) { log.debug('EXTEND UTIL _buildExtendOrderJSON:', '**ENTER**'); // Date is a string and we need to format for extend @@ -512,8 +520,8 @@ define([ //If Demo use demo email for contracts // var config = EXTEND_CONFIG.getConfig(); - if (config.email) { - objValues.email = config.email; + if (objExtendConfig.email) { + objValues.email = objExtendConfig.email; } var objJSON = { @@ -540,7 +548,7 @@ define([ } }, - 'storeId': config.storeId, + 'storeId': objExtendConfig.storeId, 'lineItems': objValues.lineItems, 'total': parseInt(objValues.total_amount * 100), 'transactionId': objValues.id, @@ -584,9 +592,9 @@ define([ return objAddress; }; //get Item's reference ID - exports.getItemRefId = function (stItemId, config) { + exports.getItemRefId = function (stItemId, objExtendConfig) { // var config = EXTEND_CONFIG.getConfig(); - var refIdValue = config.refId; + var refIdValue = objExtendConfig.refId; var stItemRefId = stItemId; if (refIdValue) { // Lookup to item to see if it is eligible for warranty offers From d30160658a79dd71f1e43171eec64eed42f3e29f Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Tue, 3 Jan 2023 23:35:59 +0200 Subject: [PATCH 23/33] leads fixes --- .../lib/customscript_ext_util.js | 64 +++++++++++++------ 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index fd3055c..bf5af5d 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -3,7 +3,7 @@ *@description: Structures the various JSON request bodies to the Extend API * @NApiVersion 2.x */ -define([ + define([ 'N/runtime', 'N/search', 'N/record', @@ -247,7 +247,7 @@ define([ var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); //move extend item to config record instead of param -// var stExtendItemId = objExtendConfig.protection_plan_item; + // var stExtendItemId = objExtendConfig.protection_plan_item; var stLineCount = objNewRecord.getLineCount({ sublistId: 'item' }); @@ -273,7 +273,7 @@ define([ if (stRelatedItem === stExtendItemRefId) { var stRelatedItemQtyFulfilled = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantityfulfilled', line: j }); - if (stRelatedItemQtyFulfilled <= stExtendItemQty && stRelatedItemQtyFulfilled > stContractQty) { + if (stContractQty <= stExtendItemQty && stRelatedItemQtyFulfilled > stContractQty) { var stUniqueKey = i; // Start building the Extend Order Info Object @@ -396,26 +396,34 @@ define([ exports.getSalesOrderItemInfo = function (objSalesOrderRecord, objExtendConfig) { //////////////////////////SUPPORT FUNCTIONS/////////////////////////// var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); - - log.debug('EXTEND UTIL _createExtendOrder: Line Count', stLineCount); log.debug('_getExtendData: Get Extend Data', '**ENTER**'); var objExtendItemData = {}; var stExtendProductItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); - //move extend item to config record instead of param - // var stExtendProductItemId = objExtendConfig.protection_plan_item; + //move extend item to config record instead of param + // var stExtendProductItemId = objExtendConfig.product_plan_item; + var stExtendShippingItemId = objExtendConfig.shipping_plan_item; for (var i = 0; i < stLineCount; i++) { var stItemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); stUniqueKey = i; - if(!objExtendItemData[stUniqueKey] && (stExtendProductItemId !== stItemId)){ + if (!objExtendItemData[stUniqueKey] && (stExtendProductItemId !== stItemId)) { objExtendItemData[stUniqueKey] = {}; } //Check if item is one of the configured extend items + if (stExtendShippingItemId === stItemId) { + //if line is shipping proection + objExtendItemData[stUniqueKey] = {}; + objExtendItemData[stUniqueKey].isShipping = true; + // Start building the Extend Order Plan Info Object + objExtendItemData[stUniqueKey].quoteId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_quote_id', line: i }); + //set Extend Line Item Transaction ID on Extend Line + objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; + } if (stExtendProductItemId === stItemId) { log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); //get value of leadtoken column on extend line - var stLeadToken = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_lead_token', line: i }); + var stLeadToken = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_lead_token', line: i }); log.debug('_getExtendData: stLeadToken', stLeadToken + '|' + typeof stLeadToken); //if extend line has lead token mark isLead = T @@ -423,13 +431,14 @@ define([ log.debug('_getExtendData: stLeadToken ', stLeadToken); objExtendItemData[stUniqueKey] = {}; objExtendItemData[stUniqueKey].isLead = true; + objExtendItemData[stUniqueKey].leadToken = stLeadToken; + objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); // Start building the Extend Order Plan Info Object objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); - //objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; - objExtendItemData[stUniqueKey].extend_line = i; + objExtendItemData[stUniqueKey].extend_line = ""+i; objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); //set Extend Line Item Transaction ID on Extend Line - objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; + objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; } // else { @@ -442,13 +451,13 @@ define([ log.debug('_getExtendData: stRelatedItem| stExtendItemRefId ', stRelatedItem + ' | ' + stExtendItemRefId); stUniqueKey = j; - if(!objExtendItemData[stUniqueKey]){ + if (!objExtendItemData[stUniqueKey]) { objExtendItemData[stUniqueKey] = {}; } // Start building the Extend Order Plan Info Object objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; - objExtendItemData[stUniqueKey].extend_line = i; + objExtendItemData[stUniqueKey].extend_line = ""+i; objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); //set Extend Line Item Transaction ID of related product on Extend Line objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; @@ -480,11 +489,30 @@ define([ var lineItems = []; for (key in objValues) { //if line is leadToken contract - if (objValues.isLead) { - - } else { + if (objValues[key].isLead) { + //objValues.refId = exports.getItemRefId(objValues[key].itemId, objExtendConfig); + var item = { + 'leadToken': objValues[key].leadToken, + 'quantity': objValues[key].quantity, + 'lineItemTransactionId': objValues[key].lineItemID + } + if (objValues[key].extend_plan_id && objValues[key].plan_price) { + item.plan = { + 'id': objValues[key].extend_plan_id.toString(), + 'purchasePrice': objValues[key].plan_price + } + } + } else if (objValues.isShipping) { + var item = { + "quoteId": objValues[key].quoteId, + "shipmentInfo": [] + } + } + else { //get product refId - objValues.refId = exports.getItemRefId(objValues[key].itemId, objExtendConfig); + log.debug('_buildExtendItemJSON: objValues', objValues); + + objValues[key].refId = exports.getItemRefId(objValues[key].itemId, objExtendConfig); var item = { 'product': { 'id': objValues.refId, From 2b9870815c0419526e0df5008d335a7fdee5a118 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Thu, 12 Jan 2023 23:14:46 +0200 Subject: [PATCH 24/33] removed contract api scripts --- .../lib/customscript_ext_util.js | 8 +- .../customscript_ext_create_contract_mr.js | 204 ------------------ .../customscript_ext_create_contract_mr.xml | 59 ----- .../customsearch_ext_contract_create.xml | 4 - 4 files changed, 6 insertions(+), 269 deletions(-) delete mode 100644 com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_contract_mr.js delete mode 100644 com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_create_contract_mr.xml delete mode 100644 com.extend.extendproductprotection/src/Objects/Fields/customsearch_ext_contract_create.xml diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index bf5af5d..b3ea0a9 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -351,6 +351,10 @@ // If Extend contract is created, populate the appropriate custom column field for contracts // on the Sales Order line + var stContractIds = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: key }); + var stLeadTokens = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_lead_token', line: key }); + log.debug('EXTEND UTIL _createExtendOrder: stContractIds | stLeadTokens: ', stContractIds + '|' + stLeadTokens); + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: key, value: JSON.stringify(objExtendResponseData[key].contractIds) }); objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_lead_token', line: key, value: JSON.stringify(objExtendResponseData[key].leadTokens) }); objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: key, value: objExtendResponseData[key].lineItemTransactionId }); @@ -400,9 +404,9 @@ var objExtendItemData = {}; - var stExtendProductItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + //var stExtendProductItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); //move extend item to config record instead of param - // var stExtendProductItemId = objExtendConfig.product_plan_item; + var stExtendProductItemId = objExtendConfig.product_plan_item; var stExtendShippingItemId = objExtendConfig.shipping_plan_item; for (var i = 0; i < stLineCount; i++) { var stItemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_contract_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_contract_mr.js deleted file mode 100644 index 6deebf4..0000000 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_contract_mr.js +++ /dev/null @@ -1,204 +0,0 @@ -/** - *@name: EXTEND SUITESCRIPT SDK - Create Contract from Fulfillment JS - *@description: - * This script invokes a call to the Extend Contracts POST endpoint whenever - * an item with a protection plan is fulfilled - * - *@copyright Extend, Inc - *@author Michael Draper - * - *@NApiVersion 2.x - *@NScriptType MapReduceScript - *@ModuleScope Public - */ - define([ - 'N/runtime', - 'N/record', - 'N/search', - '../lib/customscript_ext_util' -], - function (runtime, record, search, EXTEND_UTIL) { - var exports = {}; - - exports.getInputData = function () { - try { - log.audit('getInputData', '** START **'); - //todo build search in getinput instead of param? - var stSalesOrderSearchID = runtime.getCurrentScript().getParameter('custscript_ext_so_search'); - - log.debug('stSalesOrderSearchID', stSalesOrderSearchID); - var salesOrderSearch = search.load({ - id: stSalesOrderSearchID - }); - - return salesOrderSearch; - - } catch (e) { - log.error('getInputData', 'error: ' + e); - } - } - exports.map = function (context) { - try { - log.debug('map', '** START **'); - var contextValues = JSON.parse(context.value); - var stFulfillmentId = contextValues.id; - var stSalesOrderId = contextValues.values.createdfrom.value; - log.audit('stSalesOrderId | stFulfillmentId', stSalesOrderId + '|' + stFulfillmentId); - - context.write({ - key: stSalesOrderId, - value: stFulfillmentId - }); - - } catch (e) { - log.error('map', 'error: ' + e); - var id = record.submitFields({ - type: record.Type.SALES_ORDER, - id: stSalesOrderId, - values: { - 'custbody_ext_process_error': true - }, - options: { - enableSourcing: false, - ignoreMandatoryFields: true - } - }); - //create user note attached to record - var objNoteRecord = record.create({ - type: record.Type.NOTE, - }) - objNoteRecord.setValue('transaction', stSalesOrderId); - objNoteRecord.setValue('title', stSalesOrderId); - objNoteRecord.setValue('note', e.message); - objNoteRecord.save(); - - } - } - exports.reduce = function (context) { - try { - log.debug('reduce', '** START **'); - - var stSalesOrderId = context.key; - log.audit('reduce', 'stSalesOrderId: ' + stSalesOrderId); - - //Load associated Saled Order Record - var objSalesOrderRecord = record.load({ - type: 'salesorder', - id: stSalesOrderId - }); - - var stLineCount = objSalesOrderRecord.getLineCount({ sublistId: 'item' }); - - log.debug('reduce: Line Count', stLineCount); - - if (stLineCount > 0) { - log.debug('reduce: Get Extend Data', '**START**'); - var objExtendData = _getExtendData(stLineCount, objSalesOrderRecord); - log.audit('reduce: Line Data to Extend Object', objExtendData); - - if (!EXTEND_UTIL.objectIsEmpty(objExtendData)) { - log.audit('reduce: Item object not empty: PASS', EXTEND_UTIL.objectIsEmpty(objExtendData)); - // Get Extend Details from Sales Order - objExtendData = EXTEND_UTIL.getSalesOrderInfo(objExtendData, objSalesOrderRecord); - log.audit('reduce: SO Data to Extend Object', objExtendData); - EXTEND_UTIL.createExtendContracts(objExtendData, objSalesOrderRecord); - } - } - - } catch (e) { - log.error('reduce', 'key: ' + context.key + ' error: ' + e); - record.submitFields({ - type: record.Type.SALES_ORDER, - id: stSalesOrderId, - values: { - 'custbody_ext_process_error': true - }, - options: { - enableSourcing: false, - ignoreMandatoryFields: true - } - }); - // create user note attached to record - var objNoteRecord = record.create({ - type: record.Type.NOTE, - }) - objNoteRecord.setValue('transaction', stSalesOrderId); - objNoteRecord.setValue('title', 'Extend Error Contract Create'); - objNoteRecord.setValue('note', JSON.stringify(e.message)); - var stNoteId = objNoteRecord.save(); - log.debug('reduce', 'stNoteId: ' + stNoteId); - - } - } - exports.summarize = function (summary) { - log.audit('summarize', '** START **'); - try { - var mapKeys = []; - summary.mapSummary.keys.iterator().each(function (key) { - mapKeys.push(key); - return true; - }); - if (mapKeys.length < 1) { - log.debug('summarize', 'No results were processed'); - } - log.debug('summarize', JSON.stringify(summary)); - - } catch (e) { - log.error('summarize', 'error: ' + e); - } - } - - //////////////////////////SUPPORT FUNCTIONS/////////////////////////// - - function _getExtendData(stLineCount, objNewRecord) { - log.debug('_getExtendData: Get Extend Data', '**ENTER**'); - var objExtendItemData = {}; - - var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); - for (var i = 0; i < stLineCount; i++) { - var stItemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); - //Check if item is one of the configured extend items - if (stExtendItemId === stItemId) { - log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); - //get qty of contracts created & compare to extend item qty - var stContractQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_qty', line: i }); - var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); - - if (stContractQty < stExtendItemQty) { - - //get related item from extend line - var stExtendItemRefId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - //check for new fulfillments - for (var j = 0; j < stLineCount; j++) { - var stRelatedItem = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); - if (stRelatedItem === stExtendItemRefId) { - - var stRelatedItemQtyFulfilled = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantityfulfilled', line: j }); - if (stRelatedItemQtyFulfilled <= stExtendItemQty && stRelatedItemQtyFulfilled > stContractQty) { - - var stUniqueKey = i; - // Start building the Extend Order Info Object - objExtendItemData[stUniqueKey] = {}; - objExtendItemData[stUniqueKey].quantity = Math.min(stRelatedItemQtyFulfilled, (stExtendItemQty - stContractQty)); - objExtendItemData[stUniqueKey].item = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - objExtendItemData[stUniqueKey].line = i; - objExtendItemData[stUniqueKey].purchase_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: j }); - objExtendItemData[stUniqueKey].extend_plan_id = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); - objExtendItemData[stUniqueKey].itemId = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; - objExtendItemData[stUniqueKey].plan_price = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }); - - } - } - } - - } - } - } - - log.debug('_getExtendData: return objExtendItemData', objExtendItemData); - - return objExtendItemData - }; - - return exports; - }); diff --git a/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_create_contract_mr.xml b/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_create_contract_mr.xml deleted file mode 100644 index 0e27417..0000000 --- a/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_create_contract_mr.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - F - Extend | MR | Contract Create - F - - T - [/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_contract_mr.js] - - - 2 - F - F - F - - - - - NORMAL - - - SELECT - - F - F - - - - - - NO_ACTION - 2 - -119 - - T - - - - - 1 - 1 - [scriptid=customsearch_ext_contract_create] - T - DEBUG - T - ADMINISTRATOR - NOTSCHEDULED - Extend | MR | Contract Create - 60 - - - - 2022-03-01 - 02:00:00Z - - - - - \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/Fields/customsearch_ext_contract_create.xml b/com.extend.extendproductprotection/src/Objects/Fields/customsearch_ext_contract_create.xml deleted file mode 100644 index 52be189..0000000 --- a/com.extend.extendproductprotection/src/Objects/Fields/customsearch_ext_contract_create.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - 4e3200cde4c015a64d1deaa05f16607d13418615f6c2a2fdd8ea7f35d5d4d491@GZC@2022.1.12@H4sIAAAAAAAA/+1dW2+jSBZ+H2n+A6LfVmrfOlfLyQhDOWbCxYIiifcF0XZlwi7GFuB0p7U/fg9gHMzFCRjiyS6tViem4FzqO7c6pqoHf/xcWNQzcVxzaV/R3VaHpog9W85N+68rWsOjrxf0H9e//zawXXc566vEMQ3L/EXm8vd/kZnHLm3PMG3iUEDGdvvBXVf0k+et+u32jx8/Wjbx3LXpkdZsuWi7syeyMNx2cBtNrc35FY1VzCl3vdNe79vpSV81nslcJYYze+rP1q63XLjBB5389PQZcHOMGfziEMMj/e7ZyflZt3N22Tu/uKRftei0ujTlmQviesZiBVrt3AfaUNRGn4WxWoHwO09eg6S+2BaZ/0UckNshrVAI+LFR32mFT7ZCUcXgw6AdJxpnMyePpm16wCK4CtfD57jkdRiZE3fmmCtv6WyvwVWHgBxz/LIi1MwyXPeKDiko2+v0tYoYhR3rSMLKdNB+fSJO59mw1sSNXYFrd/416tEkVnB7RHoUXaDDsSv6Fk31CcPeMjeIptoHEFFZhZ9gnedoX5tfv65o13PA4mDu38B80A4YleQ94pHA6RwaMZqAdYkRQY85WRF7Djb/cktermhhOTMswm1B6G9mFfNYQF86KYH/4f8J9aE0FQUfKfTTA5rUfyh2Iz3FBtJToWBVKBGJNZ2glEzYMWwXuIJdHchKYG70iTYUeHbL5PtyaRHDpq89Z30oHD55gVdxmvijYblVUJ/ICuBWIwORYce8hOpjoCCRlzik1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bZPm8My+D9j5OHzAn+7dP+M99Kz4tmduucmbmdUtGrTPz3uyd/D7Sv+mkSPbebXVkZe+Tj8je78qPnz8Bl4L1NIT1tFpYTxtYjwvrWQjrWbWwnjWwHhfW8xDW82phPW9gPS6sFyGsF9XCetHAelxYL0NYL6uF9bKB9biwdjeNrG6hTtbbwHY/pJXVILv/e7gA2W7FyHYbZAsim7ocNqWjy7n/tQ7c8/tv/wUxfuQxqGcAAA== - \ No newline at end of file From d473611de1260da3a550ee2f8a80278abb81b65a Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Fri, 13 Jan 2023 21:57:38 +0200 Subject: [PATCH 25/33] updates --- .../lib/customscript_ext_config_lib.js | 137 ++++++++---------- .../lib/customscript_ext_util.js | 1 - 2 files changed, 59 insertions(+), 79 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js index 272d0a2..93d5c87 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js @@ -2,7 +2,7 @@ * keyconfig * @NApiVersion 2.1 */ - define([ +define([ 'N/runtime', 'N/search' ], @@ -10,109 +10,90 @@ var exports = {}; const objExtendEnvironment = { SANDBOX: 1, - PRODUCTION: 2 + PRODUCTION: 2 } exports.getConfig = function () { //Get storeId & APIkey from config custom record - var SB_STORE_ID; - var SB_API_KEY; - var SB_API_VERSION = 'latest'; - var SB_EMAIL; - var SB_REF_ID; + var STORE_ID; var API_KEY; var API_VERSION = 'latest'; var REF_ID; + var EMAIL; + var ENVIRONMENT = 'demo'; + var PRODUCT_ITEM; + var SHIPPING_ITEM; + var DOMAIN = 'https://api-demo.helloextend.com'; + + + var stExtendConfigRecId = runtime.getCurrentScript().getParameter('custscript_ext_config_rec'); + log.debug('_getConfig: stExtendConfigRecId ', stExtendConfigRecId); - var arrFilters = ["isinactive","is","F"]; + var arrFilters = ["internalId", "is", stExtendConfigRecId]; var customrecord_ext_configurationSearchObj = search.create({ type: "customrecord_ext_configuration", - filters:[ + filters: [ arrFilters ], columns: - [ - search.createColumn({name: "custrecord_ext_environment", label: "Environment "}), - search.createColumn({name: "custrecord_ext_api_key", label: "API Key"}), - search.createColumn({name: "custrecord_ext_api_version", label: "API Version"}), - search.createColumn({name: "custrecord_ext_demo_email", label: "Email"}), - search.createColumn({name: "custrecord_ext_store_id", label: "Store ID"}), - search.createColumn({name: "custrecord_ext_ref_id", label: "Ref ID"}), - ] - }); - var searchResultCount = customrecord_ext_configurationSearchObj.runPaged().count; - customrecord_ext_configurationSearchObj.run().each(function(result){ - var stEnvironment = result.getValue({ name: 'custrecord_ext_environment' }); - if(stEnvironment == objExtendEnvironment.SANDBOX){ - SB_STORE_ID = result.getValue({ name: 'custrecord_ext_store_id' }); - SB_API_KEY = result.getValue({ name: 'custrecord_ext_api_key' }); - SB_EMAIL = result.getValue({ name: 'custrecord_ext_demo_email' }); - SB_REF_ID = result.getValue({ name: 'custrecord_ext_ref_id' }); - if(result.getValue({ name: 'custrecord_ext_api_version' })){ - SB_API_VERSION = result.getValue({ name: 'custrecord_ext_api_version' }); + [ + search.createColumn({ name: "custrecord_ext_environment", label: "Environment " }), + search.createColumn({ name: "custrecord_ext_api_key", label: "API Key" }), + search.createColumn({ name: "custrecord_ext_api_version", label: "API Version" }), + search.createColumn({ name: "custrecord_ext_demo_email", label: "Email" }), + search.createColumn({ name: "custrecord_ext_store_id", label: "Store ID" }), + search.createColumn({ name: "custrecord_ext_ref_id", label: "Ref ID" }), + search.createColumn({ name: "custrecord_ext_pp_item", label: "Product Protection Item" }), + search.createColumn({ name: "custrecord_ext_sp_item", label: "Shipping Protection Item" }), + search.createColumn({ name: "custrecord_ext_sp_enabled", label: "Shipping Enabled" }) - } - - }else{ - STORE_ID = result.getValue({ name: 'custrecord_ext_store_id' }); - API_KEY = result.getValue({ name: 'custrecord_ext_api_key' }); - REF_ID = result.getValue({ name: 'custrecord_ext_ref_id' }); - if(result.getValue({ name: 'custrecord_ext_api_version' })){ - API_VERSION = result.getValue({ name: 'custrecord_ext_api_version' }); - } + ] + }); + var searchResultCount = customrecord_ext_configurationSearchObj.runPaged().count; + customrecord_ext_configurationSearchObj.run().each(function (result) { + ENVIRONMENT = result.getValue({ name: 'custrecord_ext_environment' }); + log.debug('_getConfig: ENVIRONMENT ', ENVIRONMENT); + switch (Number(ENVIRONMENT)) { + case objExtendEnvironment.SANDBOX: + DOMAIN = 'https://api-demo.helloextend.com' + break; + case objExtendEnvironment.PRODUCTION: + DOMAIN = 'https://api.helloextend.com' + break; + default: + DOMAIN = 'https://api-demo.helloextend.com' + }; + log.debug('_getConfig: DOMAIN ', DOMAIN); + STORE_ID = result.getValue({ name: 'custrecord_ext_store_id' }); + API_KEY = result.getValue({ name: 'custrecord_ext_api_key' }); + EMAIL = result.getValue({ name: 'custrecord_ext_demo_email' }); + REF_ID = result.getValue({ name: 'custrecord_ext_ref_id' }); + if (result.getValue({ name: 'custrecord_ext_api_version' })) { + API_VERSION = result.getValue({ name: 'custrecord_ext_api_version' }); } + PRODUCT_ITEM = result.getValue({ name: 'custrecord_ext_pp_item' }); + SHIPPING_ITEM = result.getValue({ name: 'custrecord_ext_sp_item' }); + SHIPPING_ENABLED = result.getValue({ name: 'custrecord_ext_sp_enabled' }); return true; - }); + }); - var objSandbox = { - storeId: SB_STORE_ID, - key: SB_API_KEY, - domain: 'https://api-demo.helloextend.com', - version: SB_API_VERSION, - email: SB_EMAIL, //IMPORTATN: SB and Testing environemnts requires manual assignment of a test email - refId: SB_REF_ID - }; - var objProd = { + var objExtendConfig = { storeId: STORE_ID, key: API_KEY, - domain: 'https://api.helloextend.com', + domain: DOMAIN, version: API_VERSION, - refId: REF_ID - + email: EMAIL, //IMPORTATN: SB and Testing environemnts requires manual assignment of a test email + refId: REF_ID, + product_plan_item: PRODUCT_ITEM, + shipping_plan_item: SHIPPING_ITEM, + shipping_enabled: SHIPPING_ENABLED }; - //param is custom record extend config - var stEnvironment = runtime.getCurrentScript().getParameter('custscript_ext_environment'); - log.audit('stEnvironment', stEnvironment); - switch(Number(stEnvironment)){ - case objExtendEnvironment.SANDBOX: - stEnvironment = 'SANDBOX' - break; - case objExtendEnvironment.PRODUCTION: - stEnvironment = 'PRODUCTION'; - break; - default: - stEnvironment = 'SANDBOX'; - }; - - var objKeys = {}; - - objKeys['SANDBOX'] = objSandbox; - //objKeys['PRODUCTION'] = objSandbox; //Demo Purposes - objKeys['PRODUCTION'] = objProd; - //by runtime or by global param - //runtime - /* - return objKeys[runtime.envType]; - */ - //global param - return objKeys[stEnvironment]; - - + return objExtendConfig; } return exports; diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index b3ea0a9..82b8a18 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -360,7 +360,6 @@ objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: key, value: objExtendResponseData[key].lineItemTransactionId }); if (objExtendResponseData[key].extendLine) { objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: objExtendResponseData[key].extendLine, value: JSON.stringify(objExtendResponseData[key].contractIds) }); - } } return objSalesOrderRecord; From 2a9afda73d3d28e4c50d2faf034d7c75bf2c2603 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Wed, 18 Jan 2023 00:31:43 +0200 Subject: [PATCH 26/33] moved config param to script --- .../lib/customscript_ext_config_lib.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js index 93d5c87..ebc9f55 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js @@ -12,7 +12,7 @@ define([ SANDBOX: 1, PRODUCTION: 2 } - exports.getConfig = function () { + exports.getConfig = function (stExtendConfigRecId) { //Get storeId & APIkey from config custom record var STORE_ID; @@ -26,7 +26,7 @@ define([ var DOMAIN = 'https://api-demo.helloextend.com'; - var stExtendConfigRecId = runtime.getCurrentScript().getParameter('custscript_ext_config_rec'); + //var stExtendConfigRecId = runtime.getCurrentScript().getParameter('custscript_ext_config_rec'); log.debug('_getConfig: stExtendConfigRecId ', stExtendConfigRecId); var arrFilters = ["internalId", "is", stExtendConfigRecId]; From 141b423b0f4a5f899eee847e12ceb53cf9c4786f Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Mon, 6 Feb 2023 09:14:34 -0800 Subject: [PATCH 27/33] netsuite integrator ID --- .../lib/customscript_ext_util.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 925a46b..c9b255a 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -540,6 +540,9 @@ var stContractQty = arrContractIDs.length; 'lineItems': objValues.lineItems, 'total': parseInt(objValues.total_amount * 100), 'transactionId': objValues.id, + 'saleOrigin': { + 'integratorId': 'netsuite' + } } return objJSON; From 3ba2b9e6254779f0087d6ab744b34ed2391296af Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:43:33 -0800 Subject: [PATCH 28/33] base orders suiteapp --- ...customscript_ext_offer_modal_controller.js | 137 ------ ...customscript_ext_so_offer_controller_cs.js | 194 --------- .../lib/customscript_ext_util.js | 2 - .../customscript_ext_offer_modal_sl.js | 397 ------------------ .../customscript_ext_offer_modal_ue.js | 52 --- .../customscript_ext_offer_modal_ue.xml | 26 -- ...customscript_ext_offer_presentation_sl.xml | 83 ---- ...ustomscript_ext_so_offer_controller_cs.xml | 25 -- .../src/Objects/custbody_ext_order_id.xml | 61 +++ .../custbody_ext_process_error.xml | 0 .../custcol_ext_associated_item.xml | 0 .../custcol_ext_canceled_contract_ids.xml | 53 +++ .../{Fields => }/custcol_ext_contract_id.xml | 0 ...ntract_qty.xml => custcol_ext_line_id.xml} | 8 +- .../{Fields => }/custcol_ext_plan_id.xml | 0 .../{Fields => }/custcol_ext_plan_term.xml | 0 .../customlist_ext_environment.xml | 0 .../customrecord_ext_configuration.xml | 0 .../customscript_ext_config_validate_ue.xml | 0 .../customscript_ext_create_order_mr.xml | 48 +++ .../customscript_ext_fulfill_order_mr.xml | 2 +- .../customscript_ext_refund_create_mr.xml | 59 +++ .../Objects/customsearch_ext_fulfillment.xml | 11 + .../Objects/customsearch_ext_order_create.xml | 2 +- .../customsearch_ext_order_create_2.xml | 7 + .../Objects/customsearch_ext_order_refund.xml | 13 + 26 files changed, 258 insertions(+), 922 deletions(-) delete mode 100644 com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_offer_modal_controller.js delete mode 100644 com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_so_offer_controller_cs.js delete mode 100644 com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js delete mode 100644 com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/userevent/customscript_ext_offer_modal_ue.js delete mode 100644 com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_modal_ue.xml delete mode 100644 com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_presentation_sl.xml delete mode 100644 com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_so_offer_controller_cs.xml create mode 100644 com.extend.extendproductprotection/src/Objects/custbody_ext_order_id.xml rename com.extend.extendproductprotection/src/Objects/{Fields => }/custbody_ext_process_error.xml (100%) rename com.extend.extendproductprotection/src/Objects/{Fields => }/custcol_ext_associated_item.xml (100%) create mode 100644 com.extend.extendproductprotection/src/Objects/custcol_ext_canceled_contract_ids.xml rename com.extend.extendproductprotection/src/Objects/{Fields => }/custcol_ext_contract_id.xml (100%) rename com.extend.extendproductprotection/src/Objects/{custcol_ext_contract_qty.xml => custcol_ext_line_id.xml} (90%) rename com.extend.extendproductprotection/src/Objects/{Fields => }/custcol_ext_plan_id.xml (100%) rename com.extend.extendproductprotection/src/Objects/{Fields => }/custcol_ext_plan_term.xml (100%) rename com.extend.extendproductprotection/src/Objects/{Fields => }/customlist_ext_environment.xml (100%) rename com.extend.extendproductprotection/src/Objects/{Fields => }/customrecord_ext_configuration.xml (100%) rename com.extend.extendproductprotection/src/Objects/{Fields => }/customscript_ext_config_validate_ue.xml (100%) create mode 100644 com.extend.extendproductprotection/src/Objects/customscript_ext_refund_create_mr.xml create mode 100644 com.extend.extendproductprotection/src/Objects/customsearch_ext_fulfillment.xml create mode 100644 com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create_2.xml create mode 100644 com.extend.extendproductprotection/src/Objects/customsearch_ext_order_refund.xml diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_offer_modal_controller.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_offer_modal_controller.js deleted file mode 100644 index eedda50..0000000 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_offer_modal_controller.js +++ /dev/null @@ -1,137 +0,0 @@ -/** - *@name: EXTEND SUITESCRIPT SDK - Sales Order Trigger Offer Controller - *@description: - * Plan presentation suitelet controller - * - *@copyright Aimpoint Technology Services, LLC - *@author Michael Draper - * - *@NApiVersion 2.x - *@NScriptType ClientScript - *@NModuleScope Public -*/ -define(['N/url', - '../lib/customscript_ext_util' -], - function (url, EXTEND_UTIL) { - var exports = {}; - exports.fieldChanged = function (context) { - - console.log('Event Handler', context); - const objEventRouter = { - 'custpage_select': _handleSelectInput, - 'custpage_item_select': _handleItemInput - } - console.log('objEventRouter', objEventRouter); - - if (typeof objEventRouter[context.fieldId] !== 'function') { - return; - } - try { - objEventRouter[context.fieldId](context); - } catch (e) { } - return true; - - }; - exports.saveRecord = function (context) { - var objCurrentRec = context.currentRecord; - const planCount = objCurrentRec.getLineCount({ sublistId: 'custpage_plans' }); - var stItemId = ''; - // Get line information from selected line - for (var i = 0; i < planCount; i++) { - - var isSelected = objCurrentRec.getSublistValue({ - sublistId: 'custpage_plans', - fieldId: 'custpage_select', - line: i - }); - - if (isSelected) { - stItemId = objCurrentRec.getSublistValue({ - sublistId: 'custpage_plans', - fieldId: 'custpage_item_id', - line: i - }); - break; - } - } - if (!stItemId) { - alert('You have not selected a plan. Please select a plan before submitting.'); - return false; - } - else { - return true; - } - }; - function _handleSelectInput(context) { - - var objCurrentRec = context.currentRecord; - var stLineIndex = objCurrentRec.getCurrentSublistIndex({ sublistId: 'custpage_plans' }); - var stLineCount = objCurrentRec.getLineCount({ sublistId: 'custpage_plans' }); - var bTrue = objCurrentRec.getCurrentSublistValue({ sublistId: 'custpage_plans', fieldId: 'custpage_select' }); - - if (bTrue == true) { - for (var i = 0; i < stLineCount; i++) { - if (i == stLineIndex) continue; - objCurrentRec.selectLine({ sublistId: 'custpage_plans', line: i }); - objCurrentRec.setCurrentSublistValue({ sublistId: 'custpage_plans', fieldId: 'custpage_select', value: false }); - objCurrentRec.commitLine({ sublistId: 'custpage_plans' }); - } - } - - return true; - } - function _handleItemInput(context) { - //update sublist on item field change - var objCurrentRec = context.currentRecord; - var stItemId = objCurrentRec.getValue({ fieldId: 'custpage_item_select' }); - console.log('stItemId', stItemId); - var stItemName = objCurrentRec.getText({ fieldId: 'custpage_item_select' }); - var stItemList = objCurrentRec.getValue({ fieldId: 'custpage_item_list' }); - var stItemQty; - var stLineNum; - var stItemRefId; - - if (!EXTEND_UTIL.objectIsEmpty(stItemId)) { - var arrItemList = JSON.parse(stItemList); - //var stItemQty = arrItemList.find(x => x.id === stItemId).quantity; - var objItem = _searchArray(stItemId, 'id', arrItemList); - stItemQty = objItem.qty; - stLineNum = objItem.line; - stItemRefId = objItem.refId; - } - - var URL = url.resolveScript({ - scriptId: 'customscript_ext_offer_presentation_sl', - deploymentId: 'customdeploy_ext_offer_presentation_sl', - params: { - 'itemid': stItemId, - 'itemtext': stItemName, - 'arrItemid': stItemList, - 'line': stLineNum, - 'quantity': stItemQty, - 'refid': stItemRefId - } - }); - - //avoid the standard NetSuite warning message when navigating away - if (window.onbeforeunload) { - window.onbeforeunload = function () { null; }; - }; - //refresh window - window.open(URL, '_self', false); - return true; - } - function _searchArray(nameKey, prop, myArray) { - for (var i = 0; i < myArray.length; i++) { - if (myArray[i][prop] === nameKey) { - return myArray[i]; - } - } - } - exports.handleClose = function () { - window.close(); - } - - return exports; - }); \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_so_offer_controller_cs.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_so_offer_controller_cs.js deleted file mode 100644 index 39ee35f..0000000 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_so_offer_controller_cs.js +++ /dev/null @@ -1,194 +0,0 @@ -/** - *@name: EXTEND SUITESCRIPT SDK - Offer Modal Controller - *@description: - * Client script that supoorts button on Sales Order. The script - * checks if the items are protection plan items and calls a popup suitelet - * for the user to select the appropriate protection plan. - * - *@copyright Extend, Inc. - *@author Michael Draper - * - *@NApiVersion 2.0 - *@NScriptType ClientScript - *@NModuleScope Public -*/ -define([ - 'N/url', - 'N/runtime', - 'N/search', - 'N/currentRecord', - '../lib/customscript_ext_util', - '../lib/customscript_ext_config_lib' -], - function (url, runtime, search, currentRecord, EXTEND_UTIL, EXTEND_CONFIG) { - var exports = {}; - exports.pageInit = function () { - - }; - exports.validateLine = function (context) { - log.debug('Validating Line', context); - - var objEventRouter = { - 'item': _handleItemInput - } - - if (typeof objEventRouter[context.sublistId] !== 'function') { - return true; - } - try { - objEventRouter[context.sublistId](context); - } catch (e) { - - } - return true; - }; - function _handleItemInput(context) { - - log.debug('Handling Input', context); - log.debug('Sublist', context.currentRecord.getSublist({ sublistId: context.sublistId })); - log.debug('config', EXTEND_CONFIG.getConfig()); - var refIdValue = EXTEND_CONFIG.getConfig().refId; - - var objCurrentRecord = context.currentRecord; - - var arrItemList = []; - var stExtendItem = runtime.getCurrentScript().getParameter({ name: 'custscript_ext_protection_plan' }); - - var stItemId = objCurrentRecord.getCurrentSublistValue({ - sublistId: context.sublistId, - fieldId: 'item' - }); - if (stExtendItem == stItemId) { - return; - } - - var stItemRefId = stItemId; - var stLineNum = objCurrentRecord.getCurrentSublistIndex({ - sublistId: context.sublistId - }); - var stItemName = objCurrentRecord.getCurrentSublistText({ - sublistId: context.sublistId, - fieldId: 'item' - }); - var intQty = objCurrentRecord.getCurrentSublistValue({ - sublistId: context.sublistId, - fieldId: 'quantity' - }); - if (refIdValue) { - // Lookup to item to see if it is eligible for warranty offers - var arrItemLookup = search.lookupFields({ - type: 'item', - id: stItemId, - columns: refIdValue - }); - for (var prop in arrItemLookup) { - var stItemRefId = arrItemLookup[prop][0].text; - break; - } - } - - - var objItem = {}; - objItem.id = stItemId; - objItem.name = stItemName; - objItem.qty = intQty; - objItem.line = stLineNum; - objItem.refId = stItemRefId; - //log.debug('objItem', objItem); - //push to array - arrItemList.push(objItem); - arrItemList = JSON.stringify(arrItemList); - log.debug('arrItemList', arrItemList); - - _callSuitelet(arrItemList, stItemId, stItemName, stLineNum, intQty, stItemRefId); - - return true; - } - - exports.openSuitelet = function (context) { - log.debug('Open Suitelet', context); - - var objCurrentRecord = currentRecord.get(); - //create item array - var arrItemList = []; - var stSublistId = 'item'; - var linecount = objCurrentRecord.getLineCount({ - sublistId: stSublistId - }); - log.debug('linecount', linecount); - log.debug('config', EXTEND_CONFIG.getConfig()); - var refIdValue = EXTEND_CONFIG.getConfig().refId; - //get extend item - var stExtendItem = runtime.getCurrentScript().getParameter({ name: 'custscript_ext_protection_plan' }); - - //loop item sublist or retrieve for single line item if validate line function - for (var i = 0; i < linecount; i++) { - var stItemId = objCurrentRecord.getSublistValue({ - sublistId: stSublistId, - fieldId: 'item', - line: i - }); - - var stItemRefId = stItemId; - var stItemName = objCurrentRecord.getSublistText({ - sublistId: stSublistId, - fieldId: 'item', - line: i - }); - var intQty = objCurrentRecord.getSublistText({ - sublistId: stSublistId, - fieldId: 'quantity', - line: i - }); - if (refIdValue) { - // Lookup to item to see if it is eligible for warranty offers - var arrItemLookup = search.lookupFields({ - type: 'item', - id: stItemId, - columns: refIdValue - }); - - for (var prop in arrItemLookup) { - var stItemRefId = arrItemLookup[prop][0].text; - break; - } - } - - var objItem = {}; - objItem.id = stItemId; - objItem.name = stItemName; - objItem.qty = intQty; - objItem.line = i; - objItem.refId = stItemRefId; - //log.debug('objItem', objItem); - //push to array - if (stExtendItem != stItemId) { - arrItemList.push(objItem); - } - } - var stArrayItemList = JSON.stringify(arrItemList); - log.debug('stArrayItemList', stArrayItemList); - _callSuitelet(stArrayItemList, arrItemList[0].id, arrItemList[0].name, arrItemList[0].line, arrItemList[0].qty, arrItemList[0].refId); - } - - function _callSuitelet(arrItemList, stItemId, stItemName, stLineNum, stItemQty, stItemRefId) { - //Resolve suitelet URL - var slUrl = url.resolveScript({ - scriptId: 'customscript_ext_offer_presentation_sl', - deploymentId: 'customdeploy_ext_offer_presentation_sl', - params: { - 'itemid': stItemId, - 'itemtext': stItemName, - 'arrItemid': arrItemList, - 'line': stLineNum, - 'quantity': stItemQty, - 'refid': stItemRefId - } - }); - //Call the pop up suitelet - window.open(slUrl, '_blank', 'screenX=300,screenY=300,width=900,height=500,titlebar=0,status=no,menubar=no,resizable=0,scrollbars=0'); - - } - return exports; - - }); \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 05fc5a5..bf2ef12 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -332,13 +332,11 @@ stUniqueKey = line[1]; if (arrLineItems[j].type == 'contract') { - log.debug('EXTEND UTIL _createExtendOrder: j loop contractid arrLineItems: ', arrLineItems[j].contractId); if (arrLineItems[j].contractId) { objExtendResponseData[stUniqueKey].contractIds.push(arrLineItems[j].contractId); } } if (arrLineItems[j].type == 'lead') { - log.debug('EXTEND UTIL _createExtendOrder: j loop leadTokens arrLineItems: ', arrLineItems[j].leadToken); if (arrLineItems[j].leadToken) { objExtendResponseData[stUniqueKey].leadTokens.push(arrLineItems[j].leadToken); } diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js deleted file mode 100644 index 3765290..0000000 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js +++ /dev/null @@ -1,397 +0,0 @@ -/** - *@name: EXTEND SUITESCRIPT SDK - Offer Modal Suitelet - *@description: - * Suitelet called by Sales Order client script to display protection plans - * in a popup window. The user can then select a warranty and on submit, - * the suitelet will post and append a new line for the Warranty non-inventory item - * with the description and pricing. - * - *@copyright Extend, Inc. - *@author Michael Draper - * - *@NApiVersion 2.x - *@NScriptType Suitelet - *@NModuleScope Public - */ -define([ - 'N/ui/serverWidget', - 'N/runtime', - 'N/http', - 'N/error', - '../lib/customscript_ext_api_lib', - '../lib/customscript_ext_config_lib' -], - function (ui, runtime, http, error, api, EXTEND_CONFIG) { - - var exports = {}; - - exports.onRequest = function (context) { - var objEventRouter = {}; - - objEventRouter[http.Method.GET] = _handleGet; - objEventRouter[http.Method.POST] = _handlePost; - - if (!objEventRouter[context.request.method]) { - _handleError(context); - } - try { - objEventRouter[context.request.method](context); - } catch (e) { } - }; - - - function _handleGet(context) { - - _renderForm(context); - } - // Post Handler - function _handlePost(context) { - try { - log.debug('POST: Context Object', JSON.stringify(context)); - - var objRequest = context.request; - - var objExtendItem = {}; - - var stPlanCount = objRequest.getLineCount({ group: 'custpage_plans' }); - objExtendItem.stWarrantyItemId = runtime.getCurrentScript().getParameter({ name: 'custscript_ext_protection_plan' }); - - //Line Number - // var stProductLine = objRequest.parameters.custpage_line_num; - // log.debug('POST: Product Line', stProductLine); - - objExtendItem.stItemId = objRequest.parameters.custpage_item_select; - objExtendItem.stItemName = objRequest.parameters.custpage_item_name.trim(); - objExtendItem.stItemQty = objRequest.parameters.custpage_item_qty; - objExtendItem.stPlanId = ''; - objExtendItem.stPrice = 0; - objExtendItem.stDescription = ''; - - // Get line information from selected line - for (var i = 0; i < stPlanCount; i++) { - - var bSelected = objRequest.getSublistValue({ group: 'custpage_plans', name: 'custpage_select', line: i }) == "T" ? true : false; - - if (bSelected) { - - objExtendItem.stPlanId = objRequest.getSublistValue({ group: 'custpage_plans', name: 'custpage_item_id', line: i }); - objExtendItem.stPrice = objRequest.getSublistValue({ group: 'custpage_plans', name: 'custpage_plan_price', line: i }); - - objExtendItem.stTerm = objRequest.getSublistValue({ group: 'custpage_plans', name: 'custpage_plan_term', line: i }); - objExtendItem.stDescription = _getDescription(objExtendItem.stTerm); - objExtendItem.stDescription += ' | ' + objExtendItem.stItemName; - break; - } - } - log.debug('objExtendItem', objExtendItem); - - var html = _buildhtml(objExtendItem); - // Write repsponse - context.response.write(html); - - } catch (e) { - log.error('POST error', e); - } - } - function _buildhtml(objExtendItem) { - // Prepare window.opener html to post values back to the line - try { - var html = ""; - html += " "; - html += " "; - html += " "; - html += ""; - - return html; - } catch (e) { - log.error('POST error', e); - - } - }; - function _getDescription(stTerm) { - var stText = ''; - //term change to formula instead of case - var stTermYears = parseInt(stTerm) / 12; - log.debug('stTermYears', stTermYears); - stText = "Extend " + stTermYears + "yr Protection Plan"; - return stText; - }; - function _handleError(context) { - - throw error.create({ - name: "SSS_UNSUPPORTED_REQUEST_TYPE", - message: "Suitelet only supports GET and POST", - notifyOff: true - }); - }; - // Builds Suitelet Form - function _renderForm(context) { - try { - log.debug('GET Params', context.request.parameters); - // Get plans and populate sublist - log.debug('arrItemList', context.request.parameters.arrItemid + typeof context.request.parameters.arrItemid); - var arrItemList = []; - arrItemList = JSON.parse(context.request.parameters.arrItemid); - var stItemInternalId = context.request.parameters.itemid; - var stItemRefId = context.request.parameters.refid; - log.debug('stItemRefId', stItemRefId); - - // Create the form - var objForm = ui.createForm({ - title: 'Extend Protection Plans', - hideNavBar: true - }); - /** - * HEADER FIELDS - */ - //Hidden field of line number - var objLineNumField = objForm.addField({ - id: 'custpage_line_num', - type: ui.FieldType.INTEGER, - label: 'Line Number' - }); - objLineNumField.updateDisplayType({ - displayType: ui.FieldDisplayType.HIDDEN - }); - //Hidden field of item array - var objItemListField = objForm.addField({ - id: 'custpage_item_list', - type: ui.FieldType.TEXTAREA, - label: 'Item List' - }); - objItemListField.updateDisplayType({ - displayType: ui.FieldDisplayType.HIDDEN - }); - if (context.request.parameters.arrItemid) { - objItemListField.defaultValue = context.request.parameters.arrItemid; - - } - //Hidden field of item name - var objItemNameField = objForm.addField({ - id: 'custpage_item_name', - type: ui.FieldType.TEXT, - label: 'Item Name' - }); - objItemNameField.updateDisplayType({ - displayType: ui.FieldDisplayType.HIDDEN - }); - if (context.request.parameters.itemtext) { - objItemNameField.defaultValue = context.request.parameters.itemtext; - - } - //Hidden field of item refid - var objItemRefIdField = objForm.addField({ - id: 'custpage_item_ref_id', - type: ui.FieldType.TEXT, - label: 'Item Ref ID' - }); - objItemRefIdField.updateDisplayType({ - displayType: ui.FieldDisplayType.HIDDEN - }); - if (context.request.parameters.refid) { - objItemRefIdField.defaultValue = context.request.parameters.refid; - - } - //Hidden field of item name - var objItemQtyField = objForm.addField({ - id: 'custpage_item_qty', - type: ui.FieldType.TEXT, - label: 'Item Quantity' - }); - objItemQtyField.updateDisplayType({ - displayType: ui.FieldDisplayType.HIDDEN - }); - if (context.request.parameters.quantity) { - objItemQtyField.defaultValue = context.request.parameters.quantity; - - } - //Telesales Script Group - var objScriptGroup = objForm.addFieldGroup({ - id: 'custpage_script', - label: 'Telesales Script' - }); - //OFFER TELESALES ASK SCRIPT - var objOfferTextField = objForm.addField({ - id: 'custpage_offer_text', - type: ui.FieldType.TEXTAREA, - label: 'Customer Ask:', - container: 'custpage_script' - }); - objOfferTextField.updateBreakType({ - breakType: ui.FieldBreakType.STARTCOL - }); - objOfferTextField.updateDisplayType({ - displayType: ui.FieldDisplayType.INLINE - }); - objOfferTextField.defaultValue = "We have several protection plans available for your purchase \n These protection plans cover accidental damage in addition to standard defects \n Would you be interested in protecting your purchase with us today? \n "; - //Next Steps Group - var objProcessGroup = objForm.addFieldGroup({ - id: 'custpage_process', - label: 'Adding an Extend Protection Plan' - }); - //OFFER TELESALES INSTRUCTION SCRIPT - var objProcessScript = objForm.addField({ - id: 'custpage_process_text', - type: ui.FieldType.TEXTAREA, - label: 'Instructions', - container: 'custpage_process' - }); - objProcessScript.updateBreakType({ - breakType: ui.FieldBreakType.STARTCOL - }); - objProcessScript.updateDisplayType({ - displayType: ui.FieldDisplayType.INLINE - }); - objProcessScript.defaultValue = "1. Select an Item from the drop down list \n 2.Check the box next to the protection plan your customer has selected \n 3. Click on the blue submit button to add the protection plan and return to the order \n 4. If the customer does not want a protection plan, simply click cancel"; - var objItemGroup = objForm.addFieldGroup({ - id: 'custpage_item', - label: 'Item' - }); - var objItemSelectField = objForm.addField({ - id: 'custpage_item_select', - type: ui.FieldType.SELECT, - label: 'Select Item', - container: 'custpage_item' - }); - //Iterate Items from params - for (var i = 0; i < arrItemList.length; i++) { - objItemSelectField.addSelectOption({ - value: arrItemList[i].id, - text: arrItemList[i].name - }); - } - if (stItemInternalId) { - objItemSelectField.defaultValue = stItemInternalId; - } - /** - * BUILD SUBLIST - */ - // Add plans sublist - var objPlanList = objForm.addSublist({ - id: 'custpage_plans', - type: ui.SublistType.LIST, - label: 'Eligble Plans' - }); - objPlanList.addField({ - id: 'custpage_select', - type: ui.FieldType.CHECKBOX, - label: 'Select' - }); - var objItemIdField = objPlanList.addField({ - id: 'custpage_item_id', - type: ui.FieldType.TEXT, - label: 'ID' - }); - objItemIdField.updateDisplayType({ - displayType: ui.FieldDisplayType.HIDDEN - }); - objPlanList.addField({ - id: 'custpage_plan_title', - type: ui.FieldType.TEXT, - label: 'Title' - }); - objPlanList.addField({ - id: 'custpage_plan_term', - type: ui.FieldType.TEXT, - label: 'Coverage Term (Months)' - }); - objPlanList.addField({ - id: 'custpage_plan_price', - type: ui.FieldType.CURRENCY, - label: 'Price' - }); - - // Add Submit Button - objForm.addButton({ - id: 'custpage_cancel', - label: 'Cancel', - functionName: 'handleClose()' - }); - objForm.addSubmitButton('Submit'); - /** - * POPULATE SUBLIST - */ - if (stItemRefId) { - try { - var config = EXTEND_CONFIG.getConfig(); - var objResponse = api.getOffers(stItemRefId, config); - log.debug('OFFER MODAL SUITELET: Offers JSON Response', objResponse); - - if (objResponse.code == 200) { - var objResponseBody = JSON.parse(objResponse.body); - log.debug('OFFER MODAL SUITELET: Offers JSON Response', objResponseBody); - - var objPlans = objResponseBody.plans; - log.debug('OFFER MODAL SUITELET: objPlans', objPlans); - - var arrPlans = objPlans.base; - log.debug('OFFER MODAL SUITELET: arrPlans', arrPlans); - - if (arrPlans.length == 0) { - var arrPlans = objPlans.adh; - } - log.debug('arrPlans', arrPlans); - - //Populate Sublist Values - for (var i = 0; i < arrPlans.length; i++) { - objPlanList.setSublistValue({ - id: 'custpage_item_id', - line: i, - value: arrPlans[i].id - }); - objPlanList.setSublistValue({ - id: 'custpage_plan_title', - line: i, - value: arrPlans[i].title - }); - objPlanList.setSublistValue({ - id: 'custpage_plan_term', - line: i, - value: parseInt(arrPlans[i].contract.termLength) - }); - objPlanList.setSublistValue({ - id: 'custpage_plan_price', - line: i, - value: parseFloat(arrPlans[i].price) / 100 - }); - } - } - - } catch (e) { - - } - - } - //Set Client handler - objForm.clientScriptModulePath = '../client/customscript_ext_offer_modal_controller.js'; - //Write Page - context.response.writePage(objForm); - } catch (e) { - - } - }; - return exports; - - }); \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/userevent/customscript_ext_offer_modal_ue.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/userevent/customscript_ext_offer_modal_ue.js deleted file mode 100644 index fe33b04..0000000 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/userevent/customscript_ext_offer_modal_ue.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - *@name: EXTEND SUITESCRIPT SDK - Offer Modal Controller - *@description: - * User Event script that shows a button on Sales Order to call a popup suitelet - * for the user to select the appropriate protection plan. - * - *@copyright Extend, Inc. - *@author Michael Draper - * - *@NApiVersion 2.x - *@NScriptType UserEventScript - */ - define(['N/runtime'], function(runtime) { - // Add button for Suitelet - var exports = {}; - exports.beforeLoad = function(context){ - - - var objEventRouter = { - 'create': _addButton, - 'edit': _addButton - } - - if (typeof objEventRouter[context.type] !== 'function') { - return true; - } - - objEventRouter[context.type](context); - return true; - - } - function _addButton(context){ - try - { - const recCurrent = context.newRecord; - const objForm = context.form; - objForm.clientScriptModulePath = '../client/customscript_ext_so_offer_controller_cs.js'; - objForm.addButton({ - id : 'custpage_open_suitelet', - label: 'Add Protection Plan', - functionName: 'openSuitelet()' - }); - } catch (error) - { - log.error('beforeLoad_addButton', error.message); - } - } - - return exports; - - -}); \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_modal_ue.xml b/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_modal_ue.xml deleted file mode 100644 index c204f3b..0000000 --- a/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_modal_ue.xml +++ /dev/null @@ -1,26 +0,0 @@ - - Displays button on Sales Order to trigger suitelet that displays warranty offers - F - Extend | UE | Offer Modal - F - - T - F - [/SuiteApps/com.extend.extendproductprotection/userevent/customscript_ext_offer_modal_ue.js] - - - F - T - F - F - - - ACTION|ADVANCEDREVREC|BANKCONNECTIVITY|BANKSTATEMENTPARSER|BUNDLEINSTALLATION|CLIENT|CONSOLRATEADJUSTOR|CSVIMPORT|CUSTOMGLLINES|CUSTOMMASSUPDATE|DATASETBUILDER|DEBUGGER|EMAILCAPTURE|FICONNECTIVITY|FIPARSER|MAPREDUCE|OTHER|PAYMENTGATEWAY|PAYMENTPOSTBACK|PLATFORMEXTENSION|PORTLET|PROMOTIONS|RECORDACTION|RESTLET|RESTWEBSERVICES|SCHEDULED|SDFINSTALLATION|SHIPPINGPARTNERS|SUITELET|TAXCALCULATION|USEREVENT|USERINTERFACE|WEBSERVICES|WORKBOOKBUILDER|WORKFLOW - T - DEBUG - SALESORDER - - TESTING - - - \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_presentation_sl.xml b/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_presentation_sl.xml deleted file mode 100644 index 3838222..0000000 --- a/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_offer_presentation_sl.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - F - Extend | SLET | Offer Modal - F - - T - F - [/SuiteApps/com.extend.extendproductprotection/suitelet/customscript_ext_offer_modal_sl.js] - - - 2 - F - F - F - - - - - NORMAL - - - SELECT - - F - F - - - - - - NO_ACTION - 2 - [scriptid=customlist_ext_environment] - COMPANY - T - - - 2 - F - F - F - - - - - NORMAL - - - SELECT - - F - F - - - - - - SET_NULL - 2 - -10 - COMPANY - T - - - - - F - F - T - - - - - T - F - DEBUG - - RELEASED - Extend | SLET | Offer Modal - - - \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_so_offer_controller_cs.xml b/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_so_offer_controller_cs.xml deleted file mode 100644 index a086d87..0000000 --- a/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_so_offer_controller_cs.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - F - Extend | CS | Offer Modal - F - - T - F - [/SuiteApps/com.extend.extendproductprotection/client/customscript_ext_so_offer_controller_cs.js] - - - F - T - F - F - - - ACTION|ADVANCEDREVREC|BANKCONNECTIVITY|BANKSTATEMENTPARSER|BUNDLEINSTALLATION|CLIENT|CONSOLRATEADJUSTOR|CSVIMPORT|CUSTOMGLLINES|CUSTOMMASSUPDATE|DATASETBUILDER|DEBUGGER|EMAILCAPTURE|FICONNECTIVITY|FIPARSER|MAPREDUCE|OTHER|PAYMENTGATEWAY|PAYMENTPOSTBACK|PLATFORMEXTENSION|PORTLET|PROMOTIONS|RECORDACTION|RESTLET|RESTWEBSERVICES|SCHEDULED|SDFINSTALLATION|SHIPPINGPARTNERS|SUITELET|TAXCALCULATION|USEREVENT|USERINTERFACE|WEBSERVICES|WORKBOOKBUILDER|WORKFLOW - T - DEBUG - SALESORDER - RELEASED - - - \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/custbody_ext_order_id.xml b/com.extend.extendproductprotection/src/Objects/custbody_ext_order_id.xml new file mode 100644 index 0000000..90ed8c0 --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/custbody_ext_order_id.xml @@ -0,0 +1,61 @@ + + 2 + F + F + F + F + F + F + F + F + T + F + T + F + F + F + F + F + F + F + F + F + T + F + F + F + F + + + + + NORMAL + + + F + TEXT + + F + + F + F + F + + + + + + + + + + 2 + + F + F + + + + T + + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/Fields/custbody_ext_process_error.xml b/com.extend.extendproductprotection/src/Objects/custbody_ext_process_error.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/Fields/custbody_ext_process_error.xml rename to com.extend.extendproductprotection/src/Objects/custbody_ext_process_error.xml diff --git a/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_associated_item.xml b/com.extend.extendproductprotection/src/Objects/custcol_ext_associated_item.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_associated_item.xml rename to com.extend.extendproductprotection/src/Objects/custcol_ext_associated_item.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_canceled_contract_ids.xml b/com.extend.extendproductprotection/src/Objects/custcol_ext_canceled_contract_ids.xml new file mode 100644 index 0000000..a1d8db7 --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/custcol_ext_canceled_contract_ids.xml @@ -0,0 +1,53 @@ + + 2 + F + F + F + F + F + F + F + F + F + F + F + F + F + F + F + F + F + F + T + F + F + F + F + F + F + + + + + NORMAL + + + F + TEXTAREA + Array of cancelled contract ids. + F + F + + + + + + + 2 + + F + + + + T + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_contract_id.xml b/com.extend.extendproductprotection/src/Objects/custcol_ext_contract_id.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_contract_id.xml rename to com.extend.extendproductprotection/src/Objects/custcol_ext_contract_id.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_contract_qty.xml b/com.extend.extendproductprotection/src/Objects/custcol_ext_line_id.xml similarity index 90% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_contract_qty.xml rename to com.extend.extendproductprotection/src/Objects/custcol_ext_line_id.xml index bba641a..6222c79 100644 --- a/com.extend.extendproductprotection/src/Objects/custcol_ext_contract_qty.xml +++ b/com.extend.extendproductprotection/src/Objects/custcol_ext_line_id.xml @@ -1,6 +1,6 @@ - + 2 - T + F F F F @@ -33,11 +33,11 @@ F - INTEGER + TEXT F F - + diff --git a/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_id.xml b/com.extend.extendproductprotection/src/Objects/custcol_ext_plan_id.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_id.xml rename to com.extend.extendproductprotection/src/Objects/custcol_ext_plan_id.xml diff --git a/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_term.xml b/com.extend.extendproductprotection/src/Objects/custcol_ext_plan_term.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_term.xml rename to com.extend.extendproductprotection/src/Objects/custcol_ext_plan_term.xml diff --git a/com.extend.extendproductprotection/src/Objects/Fields/customlist_ext_environment.xml b/com.extend.extendproductprotection/src/Objects/customlist_ext_environment.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/Fields/customlist_ext_environment.xml rename to com.extend.extendproductprotection/src/Objects/customlist_ext_environment.xml diff --git a/com.extend.extendproductprotection/src/Objects/Fields/customrecord_ext_configuration.xml b/com.extend.extendproductprotection/src/Objects/customrecord_ext_configuration.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/Fields/customrecord_ext_configuration.xml rename to com.extend.extendproductprotection/src/Objects/customrecord_ext_configuration.xml diff --git a/com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_config_validate_ue.xml b/com.extend.extendproductprotection/src/Objects/customscript_ext_config_validate_ue.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/Fields/customscript_ext_config_validate_ue.xml rename to com.extend.extendproductprotection/src/Objects/customscript_ext_config_validate_ue.xml diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_create_order_mr.xml b/com.extend.extendproductprotection/src/Objects/customscript_ext_create_order_mr.xml index bb3916c..60f644b 100644 --- a/com.extend.extendproductprotection/src/Objects/customscript_ext_create_order_mr.xml +++ b/com.extend.extendproductprotection/src/Objects/customscript_ext_create_order_mr.xml @@ -34,11 +34,39 @@ T + + 2 + F + F + F + + + + + NORMAL + + + SELECT + + F + F + + + + + + NO_ACTION + 2 + [appid=com.extend.extendproductprotection, scriptid=customrecord_ext_configuration] + + T + 1 1 + [appid=com.extend.extendproductprotection, scriptid=customrecord_ext_configuration.val_399709_t2522354_208] [scriptid=customsearch_ext_order_create] T DEBUG @@ -55,5 +83,25 @@ + + 1 + 1 + [appid=com.extend.extendproductprotection, scriptid=customrecord_ext_configuration.val_399709_t2522354_208] + [scriptid=customsearch_ext_order_create_2] + T + DEBUG + T + ADMINISTRATOR + NOTSCHEDULED + Extend | MR | Order Create - On Demand + 60 + + + + 2023-02-07 + 02:00:00Z + + + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_fulfill_order_mr.xml b/com.extend.extendproductprotection/src/Objects/customscript_ext_fulfill_order_mr.xml index fbae4c7..d8c0fb2 100644 --- a/com.extend.extendproductprotection/src/Objects/customscript_ext_fulfill_order_mr.xml +++ b/com.extend.extendproductprotection/src/Objects/customscript_ext_fulfill_order_mr.xml @@ -39,7 +39,7 @@ 1 1 - + [scriptid=customsearch_ext_fulfillment] T DEBUG T diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_refund_create_mr.xml b/com.extend.extendproductprotection/src/Objects/customscript_ext_refund_create_mr.xml new file mode 100644 index 0000000..0650ca4 --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/customscript_ext_refund_create_mr.xml @@ -0,0 +1,59 @@ + + + F + Extend | MR | Refund Create + F + + T + [/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js] + + + 2 + F + F + F + + + + + NORMAL + + + SELECT + + F + F + + + + + + NO_ACTION + 2 + -119 + + T + + + + + 1 + 1 + [scriptid=customsearch_ext_order_refund] + T + DEBUG + T + ADMINISTRATOR + NOTSCHEDULED + Extend | MR | Refund Create + 60 + + + + 2022-11-08 + 02:00:00Z + + + + + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/customsearch_ext_fulfillment.xml b/com.extend.extendproductprotection/src/Objects/customsearch_ext_fulfillment.xml new file mode 100644 index 0000000..795e4be --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/customsearch_ext_fulfillment.xml @@ -0,0 +1,11 @@ + + + + [scriptid=custbody18] + [scriptid=custbody19] + [scriptid=custbody_cust_priority] + [scriptid=custbody_ext_order_create] + [scriptid=custbody_promisedate] + + 764fde57f5ddd6e99e7f335eebba02a661803ea757eeb0274aab931c18eff9b4@GZC@2023.1.11@H4sIAAAAAAAA/+1dW2/iuhZ+39L+Dyh9O9IuxKEXEGUrJKbNbi4ol85wXqIMuHuyD5cqpDPT0fnxx84FwrXFJHCYeDRSwdjL9rK/tT6vxHbrzx/jUeUbCmb+dHLH8Zc1roImg+nQn/x9xzl2949b7s/277+1JrPZdNC0UOB7I/8nGhpf/kGDUJpOQs+foKCCxUxmzSjXHfc1DF+a1er3798vJyicvfohuhxMx9XZ4Csae7NqlI2rvPrDO862bNl8AlcACFf1puV9Q0MLecHga3PwOgun41n0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HzpaPwfMLheQoSz5eOxfMJjecpeDxfOiLPJ0yep6DyfOm4PEi4PKDg8qB0XB4kXB5QcHlQOi4PEi4PKLg8KB2XBwmXBxRcHpSOy4OEywMKLg9Kx+VBwuUBBZcHpePyIOHygILLg9JxeZBweUDB5UHpuDxIuDyg4PKgdFweJFweUHB5UDouLyRcXqDg8kLpuLyQcHmBgssL58zlKR/777GTMVIr2ONR/9IWx8Of8m8Ue8qn+0LC7QUKbi+UjtsLCbcXKLi9cM7c/jBkru5JjFS4xws3JFSYG/aIsJMiLuHwAgWHF0rH4YWEwwsUHF44Zw5/IOJW9hRGKrzdA3GNPBHXODHiUgVQcHWhdFy9nnD1OgVXr58zVz+QfX5wT2CkWn4PBrqyWTA/Droi+JQIrSfx+DpFPL5eunh8PeHsdQrOXj8Lzr6aFG2kShItFPjeyP+JhsaXf9AglKaT0PMnKGj//tv/ADFWv1+BsQAA + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create.xml b/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create.xml index 740b9b7..463fc85 100644 --- a/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create.xml +++ b/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create.xml @@ -3,5 +3,5 @@ [scriptid=custbody_ext_order_create] - 757a6c116b72c899396d4d1a0380b7a865c6668f13fd0cebd7b2dd5b9ddf5c9d@GZC@2022.2.13@H4sIAAAAAAAA/+1c62+jxhb/Xqn/g0W+VWqcd1qLpMIwjml4WMOQxPcLYu1J162NI8DZzer+8ffMYBxswAmYyd62jlbKMgPnMef1m8MQ+bevs2nrmYbRZB5cSceHR1KLBqP5eBL8cSW5pPfzL9Jv1z/+IAdRNB91HBpO/OnkGx3bn/6ko1idB7E/CWjYAjJB1OF3XUmf4/ip025/+fLlMKBxtJjE9HA0n7Wj0Wc686M2v01qLSbjK4k4RMN3J+cnJ6fnZx3Hf6Zjh/rh6HNntIji+SziFx79GnvzcExDbxRSP6ad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L/BzI6OlWH/F+TnRljp6MiXlYMbClbxPhDY9wrpC/hbho8RQgzUmzKVa5z5DiuXj7asvfdqh97gXcz7szosfA9zbC4PXJf9rwuXPwiz7NIYxOHGleAix+Z7cYMtVnP5uBN6bP0U6uN6XtzL1eoVvP+c01uvcZQDboBDS2dSB7jhKsZcup2LQ9DTG5g4OPc3PZQe31Mr4Wk9a3yVmn092YtFrULTHpdH9MWgeLD0OWQqo6S1V1tr+qzj6bquqpqur7q6r+2VR1nqrqfH9VnX82VV2kqrrYX1UXn01Vl6mqLvdX1eVnU1VtXpbVnqnLdimrVqAw+8W1lZVbtQLaqv0K2lpvSrYBpBfezdr6/bf/A2HA3UznVQAA \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create_2.xml b/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create_2.xml new file mode 100644 index 0000000..2a7549c --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create_2.xml @@ -0,0 +1,7 @@ + + + + [scriptid=custbody_ext_order_create] + + 2e7f5223b3a01dd3454629fea32c1a24c0f5278a446ed3b05f20e647f9624a76@GZC@2023.1.11@H4sIAAAAAAAA/+1c7W/iOBP/ftL9D1H67aQlQLe0RZRTSEzJNS/IcdpyX6IsuLc8D4QqCd3t6vnjn3FCILy1JZjSvU2FRHHs8cx4Zn4zTpzGn9/HI+GJBuFw4l+JlVJZFKjfnwyG/j9XokPany7EP5u//9bww3DSr9s0GHqj4Q86sL78h/YjZeJH3tCngQBk/LAe97oSv0bRY12Svn37VvJpFE6HES31J2Mp7H+lYy+U4m6iMB0OrkRiExXfVs+q1dOzz3Xbe6IDm3pB/2u9Pw2jyTiMf7j0e+ROggEN3H5AvYi61Xqldl6r1aqXtYvaxam4EKJcqohCNBzTMPLGjyDUUr/mTJSx9/gIfC+NagKTjOMRHfxDA2A5oKVkfviaSR6UkpGlhEsj/tGQskTTKQb0YegPIyDfbCS91UzLgIb9YPgYTaB/QGGuA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uZntnkrzX/rMdiHZVyNiZjjyGLvAG8gWQGNio03quw6oYPYrbd3zhVIpNWk21/KUD4HbxotOzHPiGDfrJS2zK60LLa2qd6vC05O4G1/Llj2my65WxEVcekuUSU8D87iJltJiZ/jd5GY9wrxfEpCdAxld3eoh3i86WJqjK2NiHlYMbOmbRNjjHQRL5G8hRlo8BUjy03SKZe5T1Hgp9r7Z8jedypp5AfcDW4xoFfjeRBi8Pv5PG7x0kGvepzGA0bEjzcqB+e/0fkOq+vRnw/fG9CXa8fWGtJm5tyt04z2YmUZ3foidDWJvbdw4kL0IAKxlw7GOpD0JMZkn359m5rKF2nvJuHYPig37vIuU2RxpSdbk9hU3Od+Kw6v3Blins+04vFzILnD4bHccXgXFoyFoLlXVElXVdldV7VdT1cxNzndX1fmvpqqLRFUXu6vq4ldT1WWiqsvdVXX5q6mqMquvKi8UWNuUVclRYf3k2kprpUoObVV+OW1VZ9qq5tBW9WfQ1mpTvPshvfJe9ebvv/0fHMr/X6NdAAA= + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_refund.xml b/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_refund.xml new file mode 100644 index 0000000..7866d04 --- /dev/null +++ b/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_refund.xml @@ -0,0 +1,13 @@ + + + + [appid=com.extend.extendproductprotection, scriptid=custcol_ext_contract_id] + [scriptid=custbody18] + [scriptid=custbody19] + [scriptid=custbody_cust_priority] + [scriptid=custbody_promisedate] + [scriptid=custcol_ext_canceled_contract_ids] + [scriptid=custcol_ext_line_id] + + 53a9fce61f7454f31f05c3099529c7fac0ebaf26bef69ce188245f0fd6256ea3@GZC@2023.1.11@H4sIAAAAAAAA/+1dW3OjuBJ+36r9Dy7nbatOHHNxLuV4C4OccILBwyWTnBeKMcoOuw5OYTwzmdoffwSI+IaTWFwcD5qaKgcBLXVLX+vrRojunz8eJ41vMJh5U/+y2T4+aTagP566nv/XZdMyB/85a/7Z+/23rj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7PEXB5rnZcnsNcniPg8lztuDyHuTxHwOW52nF5DnN5joDLc7Xj8hzm8hwBl+dqx+V5zOV5Ai7P147L85jL8wRcnq8dl+cxl+cJuDxfOy7PYy7PE3B5/pC5PPmKuffuihmblXvfurjN7TJfTudZCrcpdp+r33jM7XkCbs/XjtvzmNvzBNyeP2Runw+Z69tbxiZ85wvC6b6XhWEvErZXxKUGIODwfO04PI85PE/A4flD5vA5Ebe2O2W8CcHJDog7LxJx5/tFXAdz9Q4BV+/Ujqt3MFfvEHD1ziFz9Zzs852bS8amZXdgoGu7ThbHQdcE7xWhOB/fIcjHd2qXj+9gzt4h4Oydg+Ds60Xxhny40ICB50y8n9DVvvwNx6E49UPH82HQ+/23/wPKvHcloe0AAA== + \ No newline at end of file From fae9cfccb1508dcd0a347fb71b286c05cc405350 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:56:29 -0800 Subject: [PATCH 29/33] removed shipping --- .../lib/customscript_ext_config_lib.js | 8 +------ .../lib/customscript_ext_util.js | 23 +++---------------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js index ebc9f55..ce992f9 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_config_lib.js @@ -22,7 +22,6 @@ define([ var EMAIL; var ENVIRONMENT = 'demo'; var PRODUCT_ITEM; - var SHIPPING_ITEM; var DOMAIN = 'https://api-demo.helloextend.com'; @@ -45,8 +44,6 @@ define([ search.createColumn({ name: "custrecord_ext_store_id", label: "Store ID" }), search.createColumn({ name: "custrecord_ext_ref_id", label: "Ref ID" }), search.createColumn({ name: "custrecord_ext_pp_item", label: "Product Protection Item" }), - search.createColumn({ name: "custrecord_ext_sp_item", label: "Shipping Protection Item" }), - search.createColumn({ name: "custrecord_ext_sp_enabled", label: "Shipping Enabled" }) ] }); @@ -74,8 +71,6 @@ define([ API_VERSION = result.getValue({ name: 'custrecord_ext_api_version' }); } PRODUCT_ITEM = result.getValue({ name: 'custrecord_ext_pp_item' }); - SHIPPING_ITEM = result.getValue({ name: 'custrecord_ext_sp_item' }); - SHIPPING_ENABLED = result.getValue({ name: 'custrecord_ext_sp_enabled' }); return true; }); @@ -89,8 +84,7 @@ define([ email: EMAIL, //IMPORTATN: SB and Testing environemnts requires manual assignment of a test email refId: REF_ID, product_plan_item: PRODUCT_ITEM, - shipping_plan_item: SHIPPING_ITEM, - shipping_enabled: SHIPPING_ENABLED + }; return objExtendConfig; diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index bf2ef12..74f106e 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -403,10 +403,7 @@ var objExtendItemData = {}; - //var stExtendProductItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); - //move extend item to config record instead of param - var stExtendProductItemId = objExtendConfig.product_plan_item; - var stExtendShippingItemId = objExtendConfig.shipping_plan_item; + var stExtendProductItemId = objExtendConfig.product_plan_item; for (var i = 0; i < stLineCount; i++) { var stItemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); stUniqueKey = i; @@ -414,15 +411,6 @@ objExtendItemData[stUniqueKey] = {}; } //Check if item is one of the configured extend items - if (stExtendShippingItemId === stItemId) { - //if line is shipping proection - objExtendItemData[stUniqueKey] = {}; - objExtendItemData[stUniqueKey].isShipping = true; - // Start building the Extend Order Plan Info Object - objExtendItemData[stUniqueKey].quoteId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_quote_id', line: i }); - //set Extend Line Item Transaction ID on Extend Line - objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; - } if (stExtendProductItemId === stItemId) { log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); //get value of leadtoken column on extend line @@ -442,17 +430,13 @@ objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); //set Extend Line Item Transaction ID on Extend Line objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; - } - // - else { + }else { //get related item from extend line var stExtendItemRefId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - for (var j = 0; j < stLineCount; j++) { var stRelatedItem = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); if (stRelatedItem === stExtendItemRefId) { log.debug('_getExtendData: stRelatedItem| stExtendItemRefId ', stRelatedItem + ' | ' + stExtendItemRefId); - stUniqueKey = j; // Start building the Extend Order Plan Info Object objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); @@ -466,7 +450,7 @@ objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: i, value: stRelatedItemID }); } } - } else { + } }else { // Start building the Extend Order Item Info Object objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); objExtendItemData[stUniqueKey].itemId = stItemId @@ -508,7 +492,6 @@ } lineItems.push(item); } - } log.debug('_buildExtendItemJSON: lineItems', lineItems); From 1984fc506742af0a30ca473c9e8fa58a75d20fa4 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Thu, 23 Feb 2023 12:13:10 -0800 Subject: [PATCH 30/33] suiteapp bundle --- .../custbody_ext_order_create.xml | 0 .../{ => Fields}/custbody_ext_order_id.xml | 0 .../custbody_ext_process_error.xml | 0 .../custcol_ext_associated_item.xml | 0 .../custcol_ext_canceled_contract_ids.xml | 0 .../{ => Fields}/custcol_ext_contract_id.xml | 0 .../{ => Fields}/custcol_ext_lead_token.xml | 0 .../{ => Fields}/custcol_ext_line_id.xml | 0 .../{ => Fields}/custcol_ext_plan_id.xml | 0 .../{ => Fields}/custcol_ext_plan_term.xml | 0 .../{ => Fields}/custcol_ext_so_line.xml | 0 .../{ => Fields}/custitem_ext_item_ref_id.xml | 0 .../customlist_ext_environment.xml | 0 .../customrecord_ext_configuration.xml | 39 +++++++++++++++++++ .../customscript_ext_config_validate_ue.xml | 0 .../customscript_ext_create_order_mr.xml | 4 +- .../customscript_ext_fulfill_order_mr.xml | 0 .../customscript_ext_refund_create_mr.xml | 0 .../customsearch_ext_fulfillment.xml | 4 -- .../customsearch_ext_order_create.xml | 0 .../customsearch_ext_order_create_2.xml | 0 .../customsearch_ext_order_refund.xml | 4 -- .../src/deploy.xml | 5 ++- 23 files changed, 44 insertions(+), 12 deletions(-) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custbody_ext_order_create.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custbody_ext_order_id.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custbody_ext_process_error.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_associated_item.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_canceled_contract_ids.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_contract_id.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_lead_token.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_line_id.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_plan_id.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_plan_term.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custcol_ext_so_line.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Fields}/custitem_ext_item_ref_id.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Records}/customlist_ext_environment.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Records}/customrecord_ext_configuration.xml (87%) rename com.extend.extendproductprotection/src/Objects/{ => Scripts}/customscript_ext_config_validate_ue.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Scripts}/customscript_ext_create_order_mr.xml (89%) rename com.extend.extendproductprotection/src/Objects/{ => Scripts}/customscript_ext_fulfill_order_mr.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Scripts}/customscript_ext_refund_create_mr.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Searches}/customsearch_ext_fulfillment.xml (95%) rename com.extend.extendproductprotection/src/Objects/{ => Searches}/customsearch_ext_order_create.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Searches}/customsearch_ext_order_create_2.xml (100%) rename com.extend.extendproductprotection/src/Objects/{ => Searches}/customsearch_ext_order_refund.xml (96%) diff --git a/com.extend.extendproductprotection/src/Objects/custbody_ext_order_create.xml b/com.extend.extendproductprotection/src/Objects/Fields/custbody_ext_order_create.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custbody_ext_order_create.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custbody_ext_order_create.xml diff --git a/com.extend.extendproductprotection/src/Objects/custbody_ext_order_id.xml b/com.extend.extendproductprotection/src/Objects/Fields/custbody_ext_order_id.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custbody_ext_order_id.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custbody_ext_order_id.xml diff --git a/com.extend.extendproductprotection/src/Objects/custbody_ext_process_error.xml b/com.extend.extendproductprotection/src/Objects/Fields/custbody_ext_process_error.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custbody_ext_process_error.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custbody_ext_process_error.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_associated_item.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_associated_item.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_associated_item.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_associated_item.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_canceled_contract_ids.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_canceled_contract_ids.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_canceled_contract_ids.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_canceled_contract_ids.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_contract_id.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_contract_id.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_contract_id.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_contract_id.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_lead_token.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_lead_token.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_lead_token.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_lead_token.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_line_id.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_line_id.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_line_id.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_line_id.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_plan_id.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_id.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_plan_id.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_id.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_plan_term.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_term.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_plan_term.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_plan_term.xml diff --git a/com.extend.extendproductprotection/src/Objects/custcol_ext_so_line.xml b/com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_so_line.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custcol_ext_so_line.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custcol_ext_so_line.xml diff --git a/com.extend.extendproductprotection/src/Objects/custitem_ext_item_ref_id.xml b/com.extend.extendproductprotection/src/Objects/Fields/custitem_ext_item_ref_id.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/custitem_ext_item_ref_id.xml rename to com.extend.extendproductprotection/src/Objects/Fields/custitem_ext_item_ref_id.xml diff --git a/com.extend.extendproductprotection/src/Objects/customlist_ext_environment.xml b/com.extend.extendproductprotection/src/Objects/Records/customlist_ext_environment.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customlist_ext_environment.xml rename to com.extend.extendproductprotection/src/Objects/Records/customlist_ext_environment.xml diff --git a/com.extend.extendproductprotection/src/Objects/customrecord_ext_configuration.xml b/com.extend.extendproductprotection/src/Objects/Records/customrecord_ext_configuration.xml similarity index 87% rename from com.extend.extendproductprotection/src/Objects/customrecord_ext_configuration.xml rename to com.extend.extendproductprotection/src/Objects/Records/customrecord_ext_configuration.xml index 2688533..83bf1e1 100644 --- a/com.extend.extendproductprotection/src/Objects/customrecord_ext_configuration.xml +++ b/com.extend.extendproductprotection/src/Objects/Records/customrecord_ext_configuration.xml @@ -274,5 +274,44 @@ T + + 2 + F + F + F + F + + + + + NORMAL + + + F + SELECT + F + + F + F + F + + + + + + SET_NULL + + F + + + 2 + -10 + F + + + + T + + \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_config_validate_ue.xml b/com.extend.extendproductprotection/src/Objects/Scripts/customscript_ext_config_validate_ue.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customscript_ext_config_validate_ue.xml rename to com.extend.extendproductprotection/src/Objects/Scripts/customscript_ext_config_validate_ue.xml diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_create_order_mr.xml b/com.extend.extendproductprotection/src/Objects/Scripts/customscript_ext_create_order_mr.xml similarity index 89% rename from com.extend.extendproductprotection/src/Objects/customscript_ext_create_order_mr.xml rename to com.extend.extendproductprotection/src/Objects/Scripts/customscript_ext_create_order_mr.xml index 60f644b..4be1161 100644 --- a/com.extend.extendproductprotection/src/Objects/customscript_ext_create_order_mr.xml +++ b/com.extend.extendproductprotection/src/Objects/Scripts/customscript_ext_create_order_mr.xml @@ -56,8 +56,8 @@ NO_ACTION + -119 2 - [appid=com.extend.extendproductprotection, scriptid=customrecord_ext_configuration] T @@ -66,7 +66,6 @@ 1 1 - [appid=com.extend.extendproductprotection, scriptid=customrecord_ext_configuration.val_399709_t2522354_208] [scriptid=customsearch_ext_order_create] T DEBUG @@ -86,7 +85,6 @@ 1 1 - [appid=com.extend.extendproductprotection, scriptid=customrecord_ext_configuration.val_399709_t2522354_208] [scriptid=customsearch_ext_order_create_2] T DEBUG diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_fulfill_order_mr.xml b/com.extend.extendproductprotection/src/Objects/Scripts/customscript_ext_fulfill_order_mr.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customscript_ext_fulfill_order_mr.xml rename to com.extend.extendproductprotection/src/Objects/Scripts/customscript_ext_fulfill_order_mr.xml diff --git a/com.extend.extendproductprotection/src/Objects/customscript_ext_refund_create_mr.xml b/com.extend.extendproductprotection/src/Objects/Scripts/customscript_ext_refund_create_mr.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customscript_ext_refund_create_mr.xml rename to com.extend.extendproductprotection/src/Objects/Scripts/customscript_ext_refund_create_mr.xml diff --git a/com.extend.extendproductprotection/src/Objects/customsearch_ext_fulfillment.xml b/com.extend.extendproductprotection/src/Objects/Searches/customsearch_ext_fulfillment.xml similarity index 95% rename from com.extend.extendproductprotection/src/Objects/customsearch_ext_fulfillment.xml rename to com.extend.extendproductprotection/src/Objects/Searches/customsearch_ext_fulfillment.xml index 795e4be..cbef55d 100644 --- a/com.extend.extendproductprotection/src/Objects/customsearch_ext_fulfillment.xml +++ b/com.extend.extendproductprotection/src/Objects/Searches/customsearch_ext_fulfillment.xml @@ -1,11 +1,7 @@ - [scriptid=custbody18] - [scriptid=custbody19] - [scriptid=custbody_cust_priority] [scriptid=custbody_ext_order_create] - [scriptid=custbody_promisedate] 764fde57f5ddd6e99e7f335eebba02a661803ea757eeb0274aab931c18eff9b4@GZC@2023.1.11@H4sIAAAAAAAA/+1dW2/iuhZ+39L+Dyh9O9IuxKEXEGUrJKbNbi4ol85wXqIMuHuyD5cqpDPT0fnxx84FwrXFJHCYeDRSwdjL9rK/tT6vxHbrzx/jUeUbCmb+dHLH8Zc1roImg+nQn/x9xzl2949b7s/277+1JrPZdNC0UOB7I/8nGhpf/kGDUJpOQs+foKCCxUxmzSjXHfc1DF+a1er3798vJyicvfohuhxMx9XZ4Csae7NqlI2rvPrDO862bNl8AlcACFf1puV9Q0MLecHga3PwOgun41n0xUU/Qvf5dfTsj0ZjNAmb/PXN9fU1aFw3+KtbbtGD2iXPVUJ/jGahN37BPVrK1076MfZeXnCjl0q1cQtJc0do+DcKcHsDdBlXjv8k3Q4u45KXcRO16EurmhWaVjFEz/7ED7H4divOLWdShmg2CPyXcIrzBwjXNbTfXlBlMPJmszsuzm/O07m2BUVTenChbpv9VnVRot365o1e0azdeiJ/K88+GkU/pEK6aQIX/3bHPcK+2xOlR/E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LC7QUKbi+UjtsLCbcXKLi9cM7c/jBkru5JjFS4xws3JFSYG/aIsJMiLuHwAgWHF0rH4YWEwwsUHF44Zw5/IOJW9hRGKrzdA3GNPBHXODHiUgVQcHWhdFy9nnD1OgVXr58zVz+QfX5wT2CkWn4PBrqyWTA/Droi+JQIrSfx+DpFPL5eunh8PeHsdQrOXj8Lzr6aFG2kShItFPjeyP+JhsaXf9AglKaT0PMnKGj//tv/ADFWv1+BsQAA \ No newline at end of file diff --git a/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create.xml b/com.extend.extendproductprotection/src/Objects/Searches/customsearch_ext_order_create.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create.xml rename to com.extend.extendproductprotection/src/Objects/Searches/customsearch_ext_order_create.xml diff --git a/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create_2.xml b/com.extend.extendproductprotection/src/Objects/Searches/customsearch_ext_order_create_2.xml similarity index 100% rename from com.extend.extendproductprotection/src/Objects/customsearch_ext_order_create_2.xml rename to com.extend.extendproductprotection/src/Objects/Searches/customsearch_ext_order_create_2.xml diff --git a/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_refund.xml b/com.extend.extendproductprotection/src/Objects/Searches/customsearch_ext_order_refund.xml similarity index 96% rename from com.extend.extendproductprotection/src/Objects/customsearch_ext_order_refund.xml rename to com.extend.extendproductprotection/src/Objects/Searches/customsearch_ext_order_refund.xml index 7866d04..7e1a64b 100644 --- a/com.extend.extendproductprotection/src/Objects/customsearch_ext_order_refund.xml +++ b/com.extend.extendproductprotection/src/Objects/Searches/customsearch_ext_order_refund.xml @@ -2,10 +2,6 @@ [appid=com.extend.extendproductprotection, scriptid=custcol_ext_contract_id] - [scriptid=custbody18] - [scriptid=custbody19] - [scriptid=custbody_cust_priority] - [scriptid=custbody_promisedate] [scriptid=custcol_ext_canceled_contract_ids] [scriptid=custcol_ext_line_id] diff --git a/com.extend.extendproductprotection/src/deploy.xml b/com.extend.extendproductprotection/src/deploy.xml index 01c5c23..4b728fa 100644 --- a/com.extend.extendproductprotection/src/deploy.xml +++ b/com.extend.extendproductprotection/src/deploy.xml @@ -3,7 +3,10 @@ ~/FileCabinet/SuiteApps/com.extend.extendproductprotection/* - ~/Objects/Fields/* + ~/Objects/Records/* + ~/Objects/Fields/* + ~/Objects/Searches/* + ~/Objects/Scripts/* ~/Translations/* From 8ce89e078cb57b13dc51f345d6842381dad334e1 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Wed, 1 Mar 2023 10:58:54 -0800 Subject: [PATCH 31/33] qa updates --- .../lib/customscript_ext_util.js | 8 ++++---- .../mapreduce/customscript_ext_create_order_mr.js | 3 ++- .../mapreduce/customscript_ext_fulfill_order_mr.js | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 74f106e..ee2c80e 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -74,7 +74,7 @@ //build order data obj var objExtendData = {}; //get fulfillment data - objExtendData = exports.getFulfillmentData(objSalesOrderRecord); + objExtendData = exports.getFulfillmentData(objSalesOrderRecord, objExtendConfig); log.audit('EXTEND UTIL _fulfillExtendOrder: getFulfillmentData objExtendData', objExtendData); for (key in objExtendData) { @@ -245,9 +245,9 @@ log.debug('_getExtendData: Get Extend Data', '**ENTER**'); var objExtendItemData = {}; - var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); + //var stExtendItemId = runtime.getCurrentScript().getParameter('custscript_ext_protection_plan'); //move extend item to config record instead of param - // var stExtendItemId = objExtendConfig.protection_plan_item; + var stExtendItemId = objExtendConfig.product_plan_item; var stLineCount = objNewRecord.getLineCount({ sublistId: 'item' }); @@ -407,7 +407,7 @@ for (var i = 0; i < stLineCount; i++) { var stItemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); stUniqueKey = i; - if (stExtendItemId !== stItemId) { + if (stExtendProductItemId !== stItemId) { objExtendItemData[stUniqueKey] = {}; } //Check if item is one of the configured extend items diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js index f8cff6a..75c4753 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_create_order_mr.js @@ -51,7 +51,8 @@ define([ id: stSalesOrderId }); // Get Extend Details from Sales Order - var objExtendConfig = EXTEND_CONFIG.getConfig(); + var stExtendConfigRecId = runtime.getCurrentScript().getParameter('custscript_ext_config_rec'); + var objExtendConfig = EXTEND_CONFIG.getConfig(stExtendConfigRecId); objExtendData = EXTEND_UTIL.createExtendOrder(objSalesOrderRecord, objExtendConfig); } catch (e) { diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js index 68846c5..f026c9c 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_fulfill_order_mr.js @@ -56,7 +56,8 @@ define([ id: stSalesOrderId }); // Get Extend Details from Fulfillment - var objExtendConfig = EXTEND_CONFIG.getConfig(); + var stExtendConfigRecId = runtime.getCurrentScript().getParameter('custscript_ext_config'); + var objExtendConfig = EXTEND_CONFIG.getConfig(stExtendConfigRecId); objExtendData = EXTEND_UTIL.fulfillExtendOrder(objSalesOrderRecord, stFulfillmentId, objExtendConfig); From 2e6b9217f9d3346febb8de20853128dc275f7c1c Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Mon, 13 Mar 2023 10:20:02 -0700 Subject: [PATCH 32/33] update to use amount over rate --- .../lib/customscript_ext_util.js | 121 +++++++++++------- 1 file changed, 76 insertions(+), 45 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index ee2c80e..83b9113 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -3,7 +3,7 @@ *@description: Structures the various JSON request bodies to the Extend API * @NApiVersion 2.x */ - define([ +define([ 'N/runtime', 'N/search', 'N/record', @@ -256,12 +256,12 @@ //Check if item is one of the configured extend items if (stExtendItemId === stItemId) { log.debug('_getExtendData: Item Found | Line ', stItemId + ' | ' + i); - var arrContractIDs = []; + var arrContractIDs = []; //get qty of contracts created & compare to extend item qty var stContractIDs = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i }); - var arrContractIDs = JSON.parse(stContractIDs); - log.debug('_getExtendData: stContractID', arrContractIDs + '|' + typeof arrContractIDs); - // var arrContracyQty = JSON.parse(objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i })); + var arrContractIDs = JSON.parse(stContractIDs); + log.debug('_getExtendData: stContractID', arrContractIDs + '|' + typeof arrContractIDs); + // var arrContracyQty = JSON.parse(objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_contract_id', line: i })); var stExtendItemQty = objNewRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); if (arrContractIDs.length < stExtendItemQty) { @@ -426,73 +426,104 @@ objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); // Start building the Extend Order Plan Info Object objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); - objExtendItemData[stUniqueKey].extend_line = ""+i; + objExtendItemData[stUniqueKey].extend_line = "" + i; objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); + if (exports.objectIsEmpty(objExtendItemData[stUniqueKey].plan_price)) { + objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'amount', line: i }) / objExtendItemData[stUniqueKey].quantity * 100); + + } //set Extend Line Item Transaction ID on Extend Line objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; - }else { + } else { //get related item from extend line var stExtendItemRefId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); for (var j = 0; j < stLineCount; j++) { var stRelatedItem = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: j }); if (stRelatedItem === stExtendItemRefId) { log.debug('_getExtendData: stRelatedItem| stExtendItemRefId ', stRelatedItem + ' | ' + stExtendItemRefId); - stUniqueKey = j; - // Start building the Extend Order Plan Info Object - objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); - objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); - objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; - objExtendItemData[stUniqueKey].extend_line = i; - objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); - //set Extend Line Item Transaction ID of related product on Extend Line - objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; - var stRelatedItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; - objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: i, value: stRelatedItemID }); + stUniqueKey = j; + // Start building the Extend Order Plan Info Object + objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i }); + objExtendItemData[stUniqueKey].extend_plan_id = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_plan_id', line: i }); + objExtendItemData[stUniqueKey].itemId = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_associated_item', line: i });; + objExtendItemData[stUniqueKey].extend_line = i; + objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); + if (exports.objectIsEmpty(objExtendItemData[stUniqueKey].plan_price)) { + objExtendItemData[stUniqueKey].plan_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'amount', line: i }) / objExtendItemData[stUniqueKey].quantity * 100); + + } + //set Extend Line Item Transaction ID of related product on Extend Line + objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; + var stRelatedItemID = "" + objSalesOrderRecord.id + "-" + j + "-" + i; + objSalesOrderRecord.setSublistValue({ sublistId: 'item', fieldId: 'custcol_ext_line_id', line: i, value: stRelatedItemID }); + } } } - } }else { + } else { // Start building the Extend Order Item Info Object objExtendItemData[stUniqueKey].quantity = objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'quantity', line: i }); objExtendItemData[stUniqueKey].itemId = stItemId objExtendItemData[stUniqueKey].line = i; objExtendItemData[stUniqueKey].purchase_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'rate', line: i }) * 100); + if (exports.objectIsEmpty(objExtendItemData[stUniqueKey].purchase_price)) { + objExtendItemData[stUniqueKey].purchase_price = parseInt(objSalesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'amount', line: i }) / objExtendItemData[stUniqueKey].quantity * 100); + + } objExtendItemData[stUniqueKey].lineItemID = "" + objSalesOrderRecord.id + "-" + i; if (objExtendItemData[stUniqueKey].extend_line) { objExtendItemData[stUniqueKey].lineItemID = objExtendItemData[stUniqueKey].lineItemID + "-" + objExtendItemData[stUniqueKey].extend_line; } } - + } return objExtendItemData; }; // Build the Extend API JSON for order lines exports.buildExtendItemJSON = function (objValues, objExtendConfig) { - log.debug('_buildExtendItemJSON: objExtendConfig ', objExtendConfig); - //item json var lineItems = []; for (key in objValues) { - //get product refId - objValues.refId = exports.getItemRefId(objValues[key].itemId, objExtendConfig); - var item = { - 'product': { - 'id': objValues.refId, - // 'serialNumber': objValues.serial_number, - 'purchasePrice': objValues[key].purchase_price - }, - 'status': 'unfulfilled', - 'quantity': objValues[key].quantity, - 'lineItemTransactionId': objValues[key].lineItemID + //if line is leadToken contract + if (objValues[key].isLead) { + //objValues.refId = exports.getItemRefId(objValues[key].itemId, objExtendConfig); + var item = { + 'leadToken': objValues[key].leadToken, + 'quantity': objValues[key].quantity, + 'lineItemTransactionId': objValues[key].lineItemID + } + if (objValues[key].extend_plan_id && objValues[key].plan_price) { + item.plan = { + 'id': objValues[key].extend_plan_id.toString(), + 'purchasePrice': objValues[key].plan_price + } + } } - if (objValues[key].extend_plan_id && objValues[key].plan_price) { - item.plan = { - 'id': objValues[key].extend_plan_id.toString(), - 'purchasePrice': objValues[key].plan_price + else { + //get product refId + log.debug('_buildExtendItemJSON: objValues', objValues); + objValues[key].refId = exports.getItemRefId(objValues[key].itemId, objExtendConfig); + var item = { + 'product': { + 'id': objValues.refId, + // 'serialNumber': objValues.serial_number, + 'purchasePrice': objValues[key].purchase_price + }, + 'status': 'unfulfilled', + 'quantity': objValues[key].quantity, + 'lineItemTransactionId': objValues[key].lineItemID + } + if (objValues[key].extend_plan_id && objValues[key].plan_price) { + item.plan = { + 'id': objValues[key].extend_plan_id.toString(), + 'purchasePrice': objValues[key].plan_price + } } } + lineItems.push(item); + + } - log.debug('_buildExtendItemJSON: lineItems', lineItems); return lineItems; @@ -540,7 +571,7 @@ 'transactionId': objValues.id, 'saleOrigin': { 'integratorId': 'netsuite' - } + } } return objJSON; @@ -592,14 +623,14 @@ id: stItemId, columns: refIdValue }); - log.debug('EXTEND UTIL _getItemRefId:', arrItemLookup); + log.debug('EXTEND UTIL _getItemRefId:', arrItemLookup); for (var prop in arrItemLookup) { - if(arrItemLookup[prop][0].text){ - var stItemRefId = arrItemLookup[prop][0].text; - }else{ - var stItemRefId = arrItemLookup[prop] - } + if (arrItemLookup[prop][0].text) { + var stItemRefId = arrItemLookup[prop][0].text; + } else { + var stItemRefId = arrItemLookup[prop] + } break; } } From 6d663caba507afaa02f7dd758904d101a0bc93d7 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Mon, 13 Mar 2023 13:56:25 -0700 Subject: [PATCH 33/33] added config param --- .../lib/customscript_ext_util.js | 10 +++------- .../mapreduce/customscript_ext_refund_contract_mr.js | 12 ++++++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js index 83b9113..98002d2 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/lib/customscript_ext_util.js @@ -145,7 +145,7 @@ define([ }; //refund item by line item transaction id - exports.refundExtendOrder = function (objRefundData) { + exports.refundExtendOrder = function (objRefundData, objExtendConfig) { log.audit('EXTEND UTIL _refundExtendOrder:', '**ENTER**'); log.audit('EXTEND UTIL _refundExtendOrder: objRefundData', JSON.stringify(objRefundData)); @@ -166,7 +166,6 @@ define([ if (intContractsStillActive > 0) { log.debug('refundExtendOrder', "There is/are still " + intContractsStillActive + " active contract(s)."); - var config = EXTEND_CONFIG.getConfig(); for (var index = 0; index < arrActiveIDs.length; index++) { var contractId = arrActiveIDs[index]; @@ -178,7 +177,7 @@ define([ } else { log.debug('refundExtendOrder', "Attempting to cancel " + contractId); var objContractToRefund = { 'contractId': contractId } - var objExtendResponse = EXTEND_API.refundContract(objContractToRefund, config); + var objExtendResponse = EXTEND_API.refundContract(objContractToRefund, objExtendConfig); if (objExtendResponse.code === 201) { arrCanceledIDs.push(contractId); @@ -219,9 +218,6 @@ define([ objRefundedRecord.setValue({ fieldId: 'custbody_ext_order_create', value: true }); // var stExtendOrderId = objExtendResponseBody.id; - // log.debug('EXTEND UTIL _refundExtendOrder: stExtendOrderId: ', stExtendOrderId); - // objRefundedRecord.setValue({ fieldId: 'custbody_ext_order_id', value: stExtendOrderId }); - } else { log.error('EXTEND UTIL _refundExtendOrder', objExtendResponse); objRefundedRecord.setValue({ fieldId: 'custbody_ext_process_error', value: true }); @@ -504,7 +500,7 @@ define([ objValues[key].refId = exports.getItemRefId(objValues[key].itemId, objExtendConfig); var item = { 'product': { - 'id': objValues.refId, + 'id': objValues[key].refId, // 'serialNumber': objValues.serial_number, 'purchasePrice': objValues[key].purchase_price }, diff --git a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js index 2aa33aa..d3ad3a1 100644 --- a/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js +++ b/com.extend.extendproductprotection/src/FileCabinet/SuiteApps/com.extend.extendproductprotection/mapreduce/customscript_ext_refund_contract_mr.js @@ -15,9 +15,11 @@ 'N/runtime', 'N/record', 'N/search', - '../lib/customscript_ext_util' + '../lib/customscript_ext_util', + '../lib/customscript_ext_config_lib' + ], - function (runtime, record, search, EXTEND_UTIL) { + function (runtime, record, search, EXTEND_UTIL, EXTEND_CONFIG) { var exports = {}; exports.getInputData = function () { @@ -79,7 +81,9 @@ } //call to refund by line item transaction id - objExtendData = EXTEND_UTIL.refundExtendOrder(objRefundData); + var stExtendConfigRecId = runtime.getCurrentScript().getParameter('custscript_ext_config_record'); + var objExtendConfig = EXTEND_CONFIG.getConfig(stExtendConfigRecId); + objExtendData = EXTEND_UTIL.refundExtendOrder(objRefundData, objExtendConfig); //Load associated Saled Order Record // var objRefundRecord = record.load({ @@ -112,7 +116,7 @@ }) objNoteRecord.setValue('transaction', stFulfillmentId); - objNoteRecord.setValue('title', 'Extend Error Order Create'); + objNoteRecord.setValue('title', 'Extend Error Contract Refund'); objNoteRecord.setValue('note', JSON.stringify(e.message)); var stNoteId = objNoteRecord.save(); log.debug('reduce', 'stNoteId: ' + stNoteId);