IO-223 ARMS WIP
This commit is contained in:
@@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user