IO-223 ARMS Backup.

This commit is contained in:
Patrick Fic
2021-11-30 15:20:26 -08:00
parent cdc0c8bb37
commit 4355a04ba4

View File

@@ -16,10 +16,13 @@ const soap = require("soap");
const entegralEndpoint = const entegralEndpoint =
process.env.NODE_ENV === "production" process.env.NODE_ENV === "production"
? "https://ws.entegral.com/RepairOrderFolderService/RepairOrderFolderService.asmx?op=RepairOrderFolderAddRq" ? "https://ws.entegral.com/RepairOrderFolderService/RepairOrderFolderService.asmx?op=RepairOrderFolderAddRq"
: "https://ws.entegral.com/RepairOrderFolderService/RepairOrderFolderService.asmx?op=RepairOrderFolderAddRq"; : "https://uat-ws.armsbusinesssolutions.net/RepairOrderFolderService/RepairOrderFolderService.asmx?WSDL";
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;
const momentFormat = "yyyy-MM-DDTHH:mm:ss.SSSSSSSZ";
exports.default = async (req, res) => { exports.default = async (req, res) => {
//Query for the List of Bodyshop Clients. //Query for the List of Bodyshop Clients.
logger.log("arms-start", "DEBUG", "api", null, null); logger.log("arms-start", "DEBUG", "api", null, null);
@@ -40,7 +43,6 @@ exports.default = async (req, res) => {
const ret = jobs.map((job) => { const ret = jobs.map((job) => {
const transId = uuid(); // Can this actually be the job id? const transId = uuid(); // Can this actually be the job id?
return { return {
RepairOrderFolderAddRq: {
RqUID: transId, RqUID: transId,
DocumentInfo: { DocumentInfo: {
BMSVer: "4.0.0", BMSVer: "4.0.0",
@@ -48,31 +50,33 @@ exports.default = async (req, res) => {
DocumentVerCode: "EM", DocumentVerCode: "EM",
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(momentFormat),
TransmitDateTime: moment().format(), // Omitted from ARMS docs TransmitDateTime: moment().format(momentFormat), // Omitted from ARMS docs
}, },
EventInfo: { EventInfo: {
AssignmentEvent: { AssignmentEvent: {
CreateDateTime: CreateDateTime:
job.asgn_date && moment(job.asgn_date).format(), job.asgn_date && moment(job.asgn_date).format(momentFormat),
}, },
EstimateEvent: { EstimateEvent: {
UploadDateTime: moment().format(), UploadDateTime: moment().format(momentFormat),
}, },
RepairEvent: { RepairEvent: {
ArrivalDateTime: ArrivalDateTime:
job.date_open && moment(job.date_open).format(), job.date_open && moment(job.date_open).format(momentFormat),
ArrivalOdometerReading: job.kmin, ArrivalOdometerReading: job.kmin,
TargetCompletionDateTime: TargetCompletionDateTime:
job.scheduled_completion && job.scheduled_completion &&
moment(job.scheduled_completion).format(), moment(job.scheduled_completion).format(momentFormat),
ActualCompletionDateTime: ActualCompletionDateTime:
job.actual_completion && job.actual_completion &&
moment(job.actual_completion).format(), moment(job.actual_completion).format(momentFormat),
ActualPickUpDateTime: ActualPickUpDateTime:
job.actual_delivery && moment(job.actual_delivery).format(), job.actual_delivery &&
moment(job.actual_delivery).format(momentFormat),
CloseDateTime: CloseDateTime:
job.date_exported && moment(job.date_exported).format(), job.date_exported &&
moment(job.date_exported).format(momentFormat),
}, },
}, },
RepairOrderHeader: { RepairOrderHeader: {
@@ -269,15 +273,14 @@ exports.default = async (req, res) => {
LossInfo: { LossInfo: {
Facts: { Facts: {
LossDateTime: LossDateTime:
job.loss_date && moment(job.loss_date).format(), job.loss_date &&
moment(job.loss_date).format(momentFormat),
LossDescCode: "Collision", LossDescCode: "Collision",
PrimaryPOI: { PrimaryPOI: {
POICode: POICode: job.area_of_damage && job.area_of_damage.impact1,
job.area_of_damage && job.area_of_damage.impact1,
}, },
SecondaryPOI: { SecondaryPOI: {
POICode: POICode: job.area_of_damage && job.area_of_damage.impact2,
job.area_of_damage && job.area_of_damage.impact2,
}, },
}, },
TotalLossInd: job.tlos_ind, TotalLossInd: job.tlos_ind,
@@ -541,9 +544,9 @@ exports.default = async (req, res) => {
{ {
TotalType: "OTSL", TotalType: "OTSL",
TotalTypeDesc: "Sublet", TotalTypeDesc: "Sublet",
TotalAmt: Dinero( TotalAmt: Dinero(job.job_totals.parts.sublets.total).toFormat(
job.job_totals.parts.sublets.total "0.0"
).toFormat("0.0"), ),
}, },
{ {
TotalType: "MAPA", TotalType: "MAPA",
@@ -569,9 +572,9 @@ exports.default = async (req, res) => {
{ {
TotalType: "OTST", TotalType: "OTST",
TotalTypeDesc: "Storage", TotalTypeDesc: "Storage",
TotalAmt: Dinero( TotalAmt: Dinero(job.job_totals.additional.storage).toFormat(
job.job_totals.additional.storage "0.0"
).toFormat("0.0"), ),
}, },
{ {
TotalType: "OTTW", TotalType: "OTTW",
@@ -609,9 +612,9 @@ exports.default = async (req, res) => {
TotalType: "TOT", TotalType: "TOT",
TotalSubType: "GST", TotalSubType: "GST",
TotalTypeDesc: "GST Tax", TotalTypeDesc: "GST Tax",
TotalAmt: Dinero( TotalAmt: Dinero(job.job_totals.totals.federal_tax).toFormat(
job.job_totals.totals.federal_tax "0.0"
).toFormat("0.0"), ),
}, },
{ {
TotalType: "TOT", TotalType: "TOT",
@@ -731,13 +734,13 @@ exports.default = async (req, res) => {
ProductionStatus: { ProductionStatus: {
ProductionStage: { ProductionStage: {
ProductionStageCode: GetProductionStageCode(job), ProductionStageCode: GetProductionStageCode(job),
ProductionStageDateTime: moment().format(), ProductionStageDateTime: moment().format(momentFormat),
// ProductionStageStatusComment: // ProductionStageStatusComment:
// "Going to be painted this afternoon", // "Going to be painted this afternoon",
}, },
RepairStatus: { RepairStatus: {
RepairStatusCode: GetRepairStatusCode(job), RepairStatusCode: GetRepairStatusCode(job),
RepairStatusDateTime: moment().format(), RepairStatusDateTime: moment().format(momentFormat),
// RepairStatusMemo: "Waiting on back ordered parts", // RepairStatusMemo: "Waiting on back ordered parts",
}, },
}, },
@@ -765,7 +768,6 @@ exports.default = async (req, res) => {
// }, // },
// }, // },
// }, // },
},
}; };
}); });
@@ -779,9 +781,11 @@ 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( console.log(
new Buffer.from(
`${process.env.ENTEGRAL_USER}:${process.env.ENTEGRAL_PASSWORD}` `${process.env.ENTEGRAL_USER}:${process.env.ENTEGRAL_PASSWORD}`
).toString("base64")) ).toString("base64")
);
try { try {
const entegralSoapClient = await soap.createClientAsync( const entegralSoapClient = await soap.createClientAsync(
@@ -794,22 +798,23 @@ exports.default = async (req, res) => {
}, },
} }
); );
entegralSoapClient.setSecurity(
new soap.BasicAuthSecurity(
process.env.ENTEGRAL_USER,
process.env.ENTEGRAL_PASSWORD
)
);
const entegralResponse =
await entegralSoapClient.RepairOrderFolderAddRqAsync(ret[0]);
const [result, rawResponse, , rawRequest] = entegralResponse;
console.log("🚀 ~ file: arms.js ~ line 806 ~ result", result);
} catch (error) { } catch (error) {
console.log(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.