IO-223 WIP ARMS
This commit is contained in:
@@ -2,7 +2,7 @@ const path = require("path");
|
|||||||
const queries = require("../graphql-client/queries");
|
const queries = require("../graphql-client/queries");
|
||||||
const Dinero = require("dinero.js");
|
const Dinero = require("dinero.js");
|
||||||
const moment = require("moment");
|
const moment = require("moment");
|
||||||
var builder = require("xmlbuilder2");
|
|
||||||
const _ = require("lodash");
|
const _ = require("lodash");
|
||||||
const logger = require("../utils/logger");
|
const logger = require("../utils/logger");
|
||||||
require("dotenv").config({
|
require("dotenv").config({
|
||||||
@@ -11,6 +11,12 @@ require("dotenv").config({
|
|||||||
`.env.${process.env.NODE_ENV || "development"}`
|
`.env.${process.env.NODE_ENV || "development"}`
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
const soap = require("soap");
|
||||||
|
|
||||||
|
const entegralEndpoint =
|
||||||
|
process.env.NODE_ENV === "production"
|
||||||
|
? "https://ws.entegral.com/RepairOrderFolderService/RepairOrderFolderService.asmx?op=RepairOrderFolderAddRq"
|
||||||
|
: "https://ws.entegral.com/RepairOrderFolderService/RepairOrderFolderService.asmx?op=RepairOrderFolderAddRq";
|
||||||
|
|
||||||
const client = require("../graphql-client/graphql-client").client;
|
const client = require("../graphql-client/graphql-client").client;
|
||||||
const uuid = require("uuid").v4;
|
const uuid = require("uuid").v4;
|
||||||
@@ -43,7 +49,7 @@ exports.default = async (req, res) => {
|
|||||||
DocumentVerNum: GetSupplementNumber(job.joblines), //TODO Get Supplement Number
|
DocumentVerNum: GetSupplementNumber(job.joblines), //TODO Get Supplement Number
|
||||||
DocumentStatus: GetDocumentstatus(job, bodyshop),
|
DocumentStatus: GetDocumentstatus(job, bodyshop),
|
||||||
CreateDateTime: moment().format(),
|
CreateDateTime: moment().format(),
|
||||||
// TransmitDateTime: "2009-03-11T11:58:31.0404914-07:00", Omitted from ARMS docs
|
TransmitDateTime: moment().format(), // Omitted from ARMS docs
|
||||||
},
|
},
|
||||||
EventInfo: {
|
EventInfo: {
|
||||||
AssignmentEvent: {
|
AssignmentEvent: {
|
||||||
@@ -51,7 +57,7 @@ exports.default = async (req, res) => {
|
|||||||
job.asgn_date && moment(job.asgn_date).format(),
|
job.asgn_date && moment(job.asgn_date).format(),
|
||||||
},
|
},
|
||||||
EstimateEvent: {
|
EstimateEvent: {
|
||||||
UploadDateTime: "2009-03-02T17:00:00.0000000-08:00", //TODO Figure out what this actually is. 'Date Estimate was uploaded'
|
UploadDateTime: moment().format(),
|
||||||
},
|
},
|
||||||
RepairEvent: {
|
RepairEvent: {
|
||||||
ArrivalDateTime:
|
ArrivalDateTime:
|
||||||
@@ -266,10 +272,12 @@ exports.default = async (req, res) => {
|
|||||||
job.loss_date && moment(job.loss_date).format(),
|
job.loss_date && moment(job.loss_date).format(),
|
||||||
LossDescCode: "Collision",
|
LossDescCode: "Collision",
|
||||||
PrimaryPOI: {
|
PrimaryPOI: {
|
||||||
POICode: job.area_of_damage.impact1,
|
POICode:
|
||||||
|
job.area_of_damage && job.area_of_damage.impact1,
|
||||||
},
|
},
|
||||||
SecondaryPOI: {
|
SecondaryPOI: {
|
||||||
POICode: job.area_of_damage.impact2,
|
POICode:
|
||||||
|
job.area_of_damage && job.area_of_damage.impact2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TotalLossInd: job.tlos_ind,
|
TotalLossInd: job.tlos_ind,
|
||||||
@@ -443,7 +451,7 @@ exports.default = async (req, res) => {
|
|||||||
TotalTypeDesc: "Body Labor",
|
TotalTypeDesc: "Body Labor",
|
||||||
TotalHours: job.job_totals.rates.lab.hours,
|
TotalHours: job.job_totals.rates.lab.hours,
|
||||||
TotalAmt: Dinero(job.job_totals.rates.lab.total).toFormat(
|
TotalAmt: Dinero(job.job_totals.rates.lab.total).toFormat(
|
||||||
0.0
|
"0.0"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -451,7 +459,7 @@ exports.default = async (req, res) => {
|
|||||||
TotalTypeDesc: "Frame Labor",
|
TotalTypeDesc: "Frame Labor",
|
||||||
TotalHours: job.job_totals.rates.laf.hours,
|
TotalHours: job.job_totals.rates.laf.hours,
|
||||||
TotalAmt: Dinero(job.job_totals.rates.laf.total).toFormat(
|
TotalAmt: Dinero(job.job_totals.rates.laf.total).toFormat(
|
||||||
0.0
|
"0.0"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -459,7 +467,7 @@ exports.default = async (req, res) => {
|
|||||||
TotalTypeDesc: "Mechanical Labor",
|
TotalTypeDesc: "Mechanical Labor",
|
||||||
TotalHours: job.job_totals.rates.lam.hours,
|
TotalHours: job.job_totals.rates.lam.hours,
|
||||||
TotalAmt: Dinero(job.job_totals.rates.lam.total).toFormat(
|
TotalAmt: Dinero(job.job_totals.rates.lam.total).toFormat(
|
||||||
0.0
|
"0.0"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -467,7 +475,7 @@ exports.default = async (req, res) => {
|
|||||||
TotalTypeDesc: "Refinish Labor",
|
TotalTypeDesc: "Refinish Labor",
|
||||||
TotalHours: job.job_totals.rates.lar.hours,
|
TotalHours: job.job_totals.rates.lar.hours,
|
||||||
TotalAmt: Dinero(job.job_totals.rates.lar.total).toFormat(
|
TotalAmt: Dinero(job.job_totals.rates.lar.total).toFormat(
|
||||||
0.0
|
"0.0"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -541,14 +549,14 @@ exports.default = async (req, res) => {
|
|||||||
TotalType: "MAPA",
|
TotalType: "MAPA",
|
||||||
TotalTypeDesc: "Paint Materials",
|
TotalTypeDesc: "Paint Materials",
|
||||||
TotalAmt: Dinero(job.job_totals.rates.mapa.total).toFormat(
|
TotalAmt: Dinero(job.job_totals.rates.mapa.total).toFormat(
|
||||||
0.0
|
"0.0"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
TotalType: "MASH",
|
TotalType: "MASH",
|
||||||
TotalTypeDesc: "Shop Materials",
|
TotalTypeDesc: "Shop Materials",
|
||||||
TotalAmt: Dinero(job.job_totals.rates.mash.total).toFormat(
|
TotalAmt: Dinero(job.job_totals.rates.mash.total).toFormat(
|
||||||
0.0
|
"0.0"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
@@ -569,7 +577,7 @@ exports.default = async (req, res) => {
|
|||||||
TotalType: "OTTW",
|
TotalType: "OTTW",
|
||||||
TotalTypeDesc: "Towing",
|
TotalTypeDesc: "Towing",
|
||||||
TotalAmt: Dinero(job.job_totals.additional.towing).toFormat(
|
TotalAmt: Dinero(job.job_totals.additional.towing).toFormat(
|
||||||
0.0
|
"0.0"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -586,7 +594,7 @@ exports.default = async (req, res) => {
|
|||||||
TotalSubType: "T2",
|
TotalSubType: "T2",
|
||||||
TotalTypeDesc: "Net Total",
|
TotalTypeDesc: "Net Total",
|
||||||
TotalAmt: Dinero(job.job_totals.totals.subtotal).toFormat(
|
TotalAmt: Dinero(job.job_totals.totals.subtotal).toFormat(
|
||||||
0.0
|
"0.0"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -594,7 +602,7 @@ exports.default = async (req, res) => {
|
|||||||
TotalSubType: "F7",
|
TotalSubType: "F7",
|
||||||
TotalTypeDesc: "Sales Tax",
|
TotalTypeDesc: "Sales Tax",
|
||||||
TotalAmt: Dinero(job.job_totals.totals.state_tax).toFormat(
|
TotalAmt: Dinero(job.job_totals.totals.state_tax).toFormat(
|
||||||
0.0
|
"0.0"
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -722,15 +730,15 @@ exports.default = async (req, res) => {
|
|||||||
// },
|
// },
|
||||||
ProductionStatus: {
|
ProductionStatus: {
|
||||||
ProductionStage: {
|
ProductionStage: {
|
||||||
ProductionStageCode: 4,
|
ProductionStageCode: GetProductionStageCode(job),
|
||||||
ProductionStageDateTime: "2009-03-11T11:58:32.1898319-07:00",
|
ProductionStageDateTime: moment().format(),
|
||||||
ProductionStageStatusComment:
|
// ProductionStageStatusComment:
|
||||||
"Going to be painted this afternoon",
|
// "Going to be painted this afternoon",
|
||||||
},
|
},
|
||||||
RepairStatus: {
|
RepairStatus: {
|
||||||
RepairStatusCode: 2,
|
RepairStatusCode: GetRepairStatusCode(job),
|
||||||
RepairStatusDateTime: "2009-03-11T11:58:32.1898319-07:00",
|
RepairStatusDateTime: moment().format(),
|
||||||
RepairStatusMemo: "Waiting on back ordered parts",
|
// RepairStatusMemo: "Waiting on back ordered parts",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// RepairOrderNotes: {
|
// RepairOrderNotes: {
|
||||||
@@ -771,6 +779,37 @@ exports.default = async (req, res) => {
|
|||||||
logger.log("arms-end-shop-extract", "DEBUG", "api", bodyshop.id, {
|
logger.log("arms-end-shop-extract", "DEBUG", "api", bodyshop.id, {
|
||||||
shopname: bodyshop.shopname,
|
shopname: bodyshop.shopname,
|
||||||
});
|
});
|
||||||
|
console.log(new Buffer.from(
|
||||||
|
`${process.env.ENTEGRAL_USER}:${process.env.ENTEGRAL_PASSWORD}`
|
||||||
|
).toString("base64"))
|
||||||
|
|
||||||
|
try {
|
||||||
|
const entegralSoapClient = await soap.createClientAsync(
|
||||||
|
entegralEndpoint,
|
||||||
|
{
|
||||||
|
wsdl_headers: {
|
||||||
|
Authorization: `Basic ${new Buffer.from(
|
||||||
|
`${process.env.ENTEGRAL_USER}:${process.env.ENTEGRAL_PASSWORD}`
|
||||||
|
).toString("base64")}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// const soapResponseVehicleInsertUpdate =
|
||||||
|
// await entegralSoapClient.RepairOrderFolderAddRq ({
|
||||||
|
// arg0: CDK_CREDENTIALS,
|
||||||
|
// arg1: { id: JobData.bodyshop.cdk_dealerid },
|
||||||
|
// arg2: {
|
||||||
|
// fileType: "VEHICLES",
|
||||||
|
// vehiclesVehicleId: DMSVid.vehiclesVehId,
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const [result, rawResponse, , rawRequest] = soapResponseVehicleInsertUpdate;
|
||||||
|
|
||||||
res.json(ret);
|
res.json(ret);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
//Error at the shop level.
|
//Error at the shop level.
|
||||||
@@ -793,7 +832,7 @@ exports.default = async (req, res) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.sendStatus(200);
|
// res.sendStatus(200);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(200).json(error);
|
res.status(200).json(error);
|
||||||
}
|
}
|
||||||
@@ -815,3 +854,10 @@ function GetDocumentstatus(job, bodyshop) {
|
|||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GetRepairStatusCode(job) {
|
||||||
|
return "25";
|
||||||
|
}
|
||||||
|
function GetProductionStageCode(job) {
|
||||||
|
return "33";
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user