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 =
process.env.NODE_ENV === "production"
? "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 uuid = require("uuid").v4;
const momentFormat = "yyyy-MM-DDTHH:mm:ss.SSSSSSSZ";
exports.default = async (req, res) => {
//Query for the List of Bodyshop Clients.
logger.log("arms-start", "DEBUG", "api", null, null);
@@ -40,7 +43,6 @@ exports.default = async (req, res) => {
const ret = jobs.map((job) => {
const transId = uuid(); // Can this actually be the job id?
return {
RepairOrderFolderAddRq: {
RqUID: transId,
DocumentInfo: {
BMSVer: "4.0.0",
@@ -48,31 +50,33 @@ exports.default = async (req, res) => {
DocumentVerCode: "EM",
DocumentVerNum: GetSupplementNumber(job.joblines), //TODO Get Supplement Number
DocumentStatus: GetDocumentstatus(job, bodyshop),
CreateDateTime: moment().format(),
TransmitDateTime: moment().format(), // Omitted from ARMS docs
CreateDateTime: moment().format(momentFormat),
TransmitDateTime: moment().format(momentFormat), // Omitted from ARMS docs
},
EventInfo: {
AssignmentEvent: {
CreateDateTime:
job.asgn_date && moment(job.asgn_date).format(),
job.asgn_date && moment(job.asgn_date).format(momentFormat),
},
EstimateEvent: {
UploadDateTime: moment().format(),
UploadDateTime: moment().format(momentFormat),
},
RepairEvent: {
ArrivalDateTime:
job.date_open && moment(job.date_open).format(),
job.date_open && moment(job.date_open).format(momentFormat),
ArrivalOdometerReading: job.kmin,
TargetCompletionDateTime:
job.scheduled_completion &&
moment(job.scheduled_completion).format(),
moment(job.scheduled_completion).format(momentFormat),
ActualCompletionDateTime:
job.actual_completion &&
moment(job.actual_completion).format(),
moment(job.actual_completion).format(momentFormat),
ActualPickUpDateTime:
job.actual_delivery && moment(job.actual_delivery).format(),
job.actual_delivery &&
moment(job.actual_delivery).format(momentFormat),
CloseDateTime:
job.date_exported && moment(job.date_exported).format(),
job.date_exported &&
moment(job.date_exported).format(momentFormat),
},
},
RepairOrderHeader: {
@@ -269,15 +273,14 @@ exports.default = async (req, res) => {
LossInfo: {
Facts: {
LossDateTime:
job.loss_date && moment(job.loss_date).format(),
job.loss_date &&
moment(job.loss_date).format(momentFormat),
LossDescCode: "Collision",
PrimaryPOI: {
POICode:
job.area_of_damage && job.area_of_damage.impact1,
POICode: job.area_of_damage && job.area_of_damage.impact1,
},
SecondaryPOI: {
POICode:
job.area_of_damage && job.area_of_damage.impact2,
POICode: job.area_of_damage && job.area_of_damage.impact2,
},
},
TotalLossInd: job.tlos_ind,
@@ -541,9 +544,9 @@ exports.default = async (req, res) => {
{
TotalType: "OTSL",
TotalTypeDesc: "Sublet",
TotalAmt: Dinero(
job.job_totals.parts.sublets.total
).toFormat("0.0"),
TotalAmt: Dinero(job.job_totals.parts.sublets.total).toFormat(
"0.0"
),
},
{
TotalType: "MAPA",
@@ -569,9 +572,9 @@ exports.default = async (req, res) => {
{
TotalType: "OTST",
TotalTypeDesc: "Storage",
TotalAmt: Dinero(
job.job_totals.additional.storage
).toFormat("0.0"),
TotalAmt: Dinero(job.job_totals.additional.storage).toFormat(
"0.0"
),
},
{
TotalType: "OTTW",
@@ -609,9 +612,9 @@ exports.default = async (req, res) => {
TotalType: "TOT",
TotalSubType: "GST",
TotalTypeDesc: "GST Tax",
TotalAmt: Dinero(
job.job_totals.totals.federal_tax
).toFormat("0.0"),
TotalAmt: Dinero(job.job_totals.totals.federal_tax).toFormat(
"0.0"
),
},
{
TotalType: "TOT",
@@ -731,13 +734,13 @@ exports.default = async (req, res) => {
ProductionStatus: {
ProductionStage: {
ProductionStageCode: GetProductionStageCode(job),
ProductionStageDateTime: moment().format(),
ProductionStageDateTime: moment().format(momentFormat),
// ProductionStageStatusComment:
// "Going to be painted this afternoon",
},
RepairStatus: {
RepairStatusCode: GetRepairStatusCode(job),
RepairStatusDateTime: moment().format(),
RepairStatusDateTime: moment().format(momentFormat),
// 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, {
shopname: bodyshop.shopname,
});
console.log(new Buffer.from(
console.log(
new Buffer.from(
`${process.env.ENTEGRAL_USER}:${process.env.ENTEGRAL_PASSWORD}`
).toString("base64"))
).toString("base64")
);
try {
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) {
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);
} catch (error) {
//Error at the shop level.