From 724898714de3d3c7b46e4e3fca7b32ae2417c07a Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Wed, 1 Dec 2021 13:37:55 -0800 Subject: [PATCH] IO-223 ARMS WIP --- .../jobs-available-table.container.jsx | 2 +- server/data/arms.js | 44 ++++++++++++++----- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/client/src/components/jobs-available-table/jobs-available-table.container.jsx b/client/src/components/jobs-available-table/jobs-available-table.container.jsx index 7cb63f152..8d37c6041 100644 --- a/client/src/components/jobs-available-table/jobs-available-table.container.jsx +++ b/client/src/components/jobs-available-table/jobs-available-table.container.jsx @@ -100,7 +100,7 @@ export function JobsAvailableContainer({ } //IO-539 Check for Parts Rate on PAL for SGI use case. await CheckTaxRates(estData.est_data, bodyshop); - console.log(estData); + const newTotals = ( await Axios.post("/job/totals", { job: { diff --git a/server/data/arms.js b/server/data/arms.js index 86afe6390..81235f850 100644 --- a/server/data/arms.js +++ b/server/data/arms.js @@ -42,6 +42,7 @@ exports.default = async (req, res) => { }); const ret = jobs.map((job) => { const transId = uuid(); // Can this actually be the job id? + return { RqUID: transId, DocumentInfo: { @@ -781,16 +782,17 @@ exports.default = async (req, res) => { logger.log("arms-end-shop-extract", "DEBUG", "api", bodyshop.id, { shopname: bodyshop.shopname, }); - console.log( - new Buffer.from( - `${process.env.ENTEGRAL_USER}:${process.env.ENTEGRAL_PASSWORD}` - ).toString("base64") - ); + const abc = ret[1]; + deleteNullKeys(abc); try { const entegralSoapClient = await soap.createClientAsync( entegralEndpoint, { + ignoredNamespaces: true, + wsdl_options: { + useEmptyTag: true, + }, wsdl_headers: { Authorization: `Basic ${new Buffer.from( `${process.env.ENTEGRAL_USER}:${process.env.ENTEGRAL_PASSWORD}` @@ -807,15 +809,15 @@ exports.default = async (req, res) => { ); const entegralResponse = - await entegralSoapClient.RepairOrderFolderAddRqAsync(ret[0]); + await entegralSoapClient.RepairOrderFolderAddRqAsync(abc); const [result, rawResponse, , rawRequest] = entegralResponse; console.log("🚀 ~ file: arms.js ~ line 806 ~ result", result); + res.json(result); } catch (error) { console.log(error); + res.json(error); } - - res.json(ret); } catch (error) { //Error at the shop level. logger.log("arms-error-shop", "ERROR", "api", bodyshop.id, { @@ -844,6 +846,7 @@ exports.default = async (req, res) => { }; function GetSupplementNumber(joblines) { + return 0; return _.max(joblines.map((jl) => jl.line_ind)); } @@ -853,10 +856,10 @@ function GetDocumentstatus(job, bodyshop) { return "V"; case bodyshop.md_ro_statuses.default_invoiced: case bodyshop.md_ro_statuses.default_exported: - return "V"; + return "Z"; default: - return "0"; + return "O"; } } @@ -866,3 +869,24 @@ function GetRepairStatusCode(job) { function GetProductionStageCode(job) { return "33"; } + +function isEmpty(obj) { + for (var key in obj) return false; + + return true; +} + +function deleteNullKeys(app) { + for (var key in app) { + if (app[key] !== null && typeof app[key] === "object") { + deleteNullKeys(app[key]); + + if (isEmpty(app[key])) { + delete app[key]; + } + } + if (app[key] === null) { + delete app[key]; + } + } +}