From 9ce9afd42b5eebd21974ca5e17c7d30edd34d535 Mon Sep 17 00:00:00 2001 From: alopez-extend <87334339+alopez-extend@users.noreply.github.com> Date: Wed, 2 Nov 2022 15:23:57 -0700 Subject: [PATCH] Minor Updates Updates here are needed to support offers and contract creation. Also unlocks the bundle on install for future customization. --- .gitignore | 2 ++ .../lib/customscript_ext_util.js | 35 +++++++++---------- .../customscript_ext_offer_modal_sl.js | 16 +++------ .../src/InstallationPreferences/locking.xml | 4 +-- 4 files changed, 25 insertions(+), 32 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bea433 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store 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..d9dae55 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 @@ -53,7 +53,7 @@ }) objNoteRecord.setValue('transaction', objSalesOrderRecord.id); objNoteRecord.setValue('title', 'Extend Contract Create Error | Line ' + key); - objNoteRecord.setValue('note', JOSN.stringify(objExtendResponse)); + objNoteRecord.setValue('note', JSON.stringify(objExtendResponse)); var stNoteId = objNoteRecord.save(); } } @@ -184,12 +184,12 @@ var objJSON = { 'transactionId': objValues.id, 'transactionDate': objValues.tran_date, -// 'transactionTotal': objValues.total_amount * 100, + 'transactionTotal': objValues.total_amount * 100, - 'transactionTotal': { - 'currencyCode': objValues.currency, - 'amount': parseInt(objValues.total_amount * 100) - }, + // 'transactionTotal': { + // 'currencyCode': objValues.currency, + // 'amount': parseInt(objValues.total_amount * 100) + // }, 'currency': objValues.currency, 'poNumber': objValues.order_number, @@ -216,24 +216,23 @@ }, 'product': { 'referenceId': objValues.refId, - // 'purchasePrice': objValues.purchase_price * 100, + 'purchasePrice': objValues.purchase_price * 100, - 'purchasePrice': { - 'currencyCode': objValues.currency, - 'amount': parseInt(objValues.purchase_price * 100), - } + // '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), - }, + 'planId': objValues.extend_plan_id, + 'purchasePrice': objValues.plan_price * 100, - 'planId': objValues.extend_plan_id + // 'purchasePrice': { + // 'currencyCode': objValues.currency, + // 'amount': parseInt(objValues.plan_price * 100), + // }, } }; return objJSON; 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..4f57e2e 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 @@ -13,7 +13,7 @@ *@NScriptType Suitelet *@NModuleScope Public */ -define([ + define([ 'N/ui/serverWidget', 'N/runtime', 'N/http', @@ -62,6 +62,7 @@ define([ objExtendItem.stItemId = objRequest.parameters.custpage_item_select; objExtendItem.stItemName = objRequest.parameters.custpage_item_name.trim(); objExtendItem.stItemQty = objRequest.parameters.custpage_item_qty; + objExtendItem.stRefId = objRequest.parameters.custpage_item_ref_id; objExtendItem.stPlanId = ''; objExtendItem.stPrice = 0; objExtendItem.stDescription = ''; @@ -336,23 +337,14 @@ define([ try { var objResponse = api.getPlansByItem(stItemRefId); 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; + var arrPlans = objResponseBody.plans; 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({ diff --git a/com.extend.extendproductprotection/src/InstallationPreferences/locking.xml b/com.extend.extendproductprotection/src/InstallationPreferences/locking.xml index 19453b5..2981e5f 100644 --- a/com.extend.extendproductprotection/src/InstallationPreferences/locking.xml +++ b/com.extend.extendproductprotection/src/InstallationPreferences/locking.xml @@ -4,8 +4,8 @@ - + - +