|
|
|
|
@@ -26,16 +26,17 @@ exports.default = async function (socket, { txEnvelope, jobid }) {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const JobData = await QueryJobData(socket, jobid);
|
|
|
|
|
socket.JobData = JobData;
|
|
|
|
|
const DealerId = JobData.bodyshop.cdk_dealerid;
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"TRACE",
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`Dealer ID detected: ${JSON.stringify(DealerId)}`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"TRACE",
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{1} Begin Calculate DMS Vehicle ID using VIN: ${JobData.v_vin}`
|
|
|
|
|
);
|
|
|
|
|
socket.DMSVid = await CalculateDmsVid(socket, JobData);
|
|
|
|
|
@@ -43,38 +44,38 @@ exports.default = async function (socket, { txEnvelope, jobid }) {
|
|
|
|
|
if (socket.DMSVid.newId === "N") {
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"TRACE",
|
|
|
|
|
`{2.1} Querying the Vehicle using the DMSVid: ${socket.DmsVid}`
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{2.1} Querying the Vehicle using the DMSVid: ${socket.DMSVid}`
|
|
|
|
|
);
|
|
|
|
|
socket.DMSVeh = await QueryDmsVehicleById(socket, JobData, socket.DMSVid);
|
|
|
|
|
|
|
|
|
|
const DmsVehCustomerId =
|
|
|
|
|
const DMSVehCustomer =
|
|
|
|
|
socket.DMSVeh &&
|
|
|
|
|
socket.DMSVeh.owners.find((o) => o.assigningPartyId === "CURRENT");
|
|
|
|
|
socket.DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
|
|
|
|
|
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"TRACE",
|
|
|
|
|
`{2.2} Querying the Customer using the ID from DMSVeh: ${DmsVehCustomerId}`
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{2.2} Querying the Customer using the ID from DMSVeh: ${DMSVehCustomer.id.value}`
|
|
|
|
|
);
|
|
|
|
|
socket.DmsVehCustomer = await QueryDmsCustomerById(
|
|
|
|
|
socket.DMSVehCustomer = await QueryDmsCustomerById(
|
|
|
|
|
socket,
|
|
|
|
|
JobData,
|
|
|
|
|
DmsVehCustomerId
|
|
|
|
|
DMSVehCustomer.id.value
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"TRACE",
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{2.3} Querying the Customer using the name.`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
socket.DmsCustList = await QueryDmsCustomerByName(socket, JobData);
|
|
|
|
|
socket.DMSCustList = await QueryDmsCustomerByName(socket, JobData);
|
|
|
|
|
|
|
|
|
|
socket.emit("cdk-select-customer", [
|
|
|
|
|
...(socket.DmsVehCustomer ? socket.DmsVehCustomer : []),
|
|
|
|
|
...socket.DmsCustList,
|
|
|
|
|
...(socket.DMSVehCustomer ? [socket.DMSVehCustomer] : []),
|
|
|
|
|
...socket.DMSCustList,
|
|
|
|
|
]);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
@@ -98,45 +99,55 @@ async function CdkSelectedCustomer(socket, selectedCustomerId) {
|
|
|
|
|
if (selectedCustomerId) {
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"TRACE",
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{3.1} Querying the Customer using Customer ID: ${selectedCustomerId}`
|
|
|
|
|
);
|
|
|
|
|
socket.DMSCust = await QueryDmsCustomerById(socket, selectedCustomerId);
|
|
|
|
|
} else {
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"TRACE",
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{3.2} Generating a new customer ID.`
|
|
|
|
|
);
|
|
|
|
|
const newCustomerId = await GenerateDmsCustomerNumber(
|
|
|
|
|
socket,
|
|
|
|
|
socket.JobData
|
|
|
|
|
);
|
|
|
|
|
const newCustomerId = await GenerateDmsCustomerNumber(socket);
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"TRACE",
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{3.3} Inserting new customer with ID: ${newCustomerId}`
|
|
|
|
|
);
|
|
|
|
|
socket.DMSCust = await InsertDmsCustomer(
|
|
|
|
|
socket,
|
|
|
|
|
socket.JobData,
|
|
|
|
|
newCustomerId
|
|
|
|
|
);
|
|
|
|
|
socket.DMSCust = await InsertDmsCustomer(socket, newCustomerId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (socket.DMSVid.newId === "Y") {
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"TRACE",
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{4.1} Inserting new vehicle with ID: ID ${socket.DMSVid.vehiclesVehId}`
|
|
|
|
|
);
|
|
|
|
|
socket.DMSVeh = await InsertDmsVehicle(socket);
|
|
|
|
|
} else {
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"TRACE",
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{4.2} Querying Existing Vehicle using ID ${socket.DMSVid.vehiclesVehId}`
|
|
|
|
|
);
|
|
|
|
|
socket.DMSVeh = await QueryDmsVehicleById(
|
|
|
|
|
socket,
|
|
|
|
|
socket.JobData,
|
|
|
|
|
socket.DMSVid
|
|
|
|
|
);
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{4.3} Updating Existing Vehicle to associate to owner.`
|
|
|
|
|
);
|
|
|
|
|
socket.DMSVeh = await UpdateDmsVehicle(socket);
|
|
|
|
|
}
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"DEBUG",
|
|
|
|
|
`{5} Updating Service Vehicle History.`
|
|
|
|
|
);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
@@ -181,7 +192,7 @@ async function CalculateDmsVid(socket, JobData) {
|
|
|
|
|
arg1: { id: JobData.bodyshop.cdk_dealerid },
|
|
|
|
|
arg2: { VIN: JobData.v_vin },
|
|
|
|
|
});
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
|
|
|
|
|
|
|
|
|
const [result, rawResponse, , rawRequest] = soapResponseVehicleInsertUpdate;
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
socket,
|
|
|
|
|
@@ -204,9 +215,8 @@ async function CalculateDmsVid(socket, JobData) {
|
|
|
|
|
2
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const DmsVid = result && result.return && result.return[0];
|
|
|
|
|
return DmsVid;
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
|
|
|
|
return result && result.return && result.return[0];
|
|
|
|
|
} catch (error) {
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
socket,
|
|
|
|
|
@@ -217,7 +227,7 @@ async function CalculateDmsVid(socket, JobData) {
|
|
|
|
|
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
socket,
|
|
|
|
|
error.response.data,
|
|
|
|
|
error.response && error.response.data,
|
|
|
|
|
`soapClientVehicleInsertUpdate.getVehIdsAsync response.`,
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
@@ -245,7 +255,7 @@ async function QueryDmsVehicleById(socket, JobData, DMSVid) {
|
|
|
|
|
vehiclesVehicleId: DMSVid.vehiclesVehId,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
|
|
|
|
|
|
|
|
|
const [result, rawResponse, , rawRequest] = soapResponseVehicleInsertUpdate;
|
|
|
|
|
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
@@ -268,6 +278,7 @@ async function QueryDmsVehicleById(socket, JobData, DMSVid) {
|
|
|
|
|
rawResponse,
|
|
|
|
|
`soapClientVehicleInsertUpdate.readAsync response.`
|
|
|
|
|
);
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
|
|
|
|
const VehicleFromDMS = result && result.return && result.return.vehicle;
|
|
|
|
|
return VehicleFromDMS;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
@@ -290,10 +301,11 @@ async function QueryDmsCustomerById(socket, JobData, CustomerId) {
|
|
|
|
|
arg0: CDK_CREDENTIALS,
|
|
|
|
|
arg1: { dealerId: JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
|
|
|
|
arg2: {
|
|
|
|
|
userId: CustomerId,
|
|
|
|
|
// userId: CustomerId,
|
|
|
|
|
},
|
|
|
|
|
arg3: CustomerId,
|
|
|
|
|
});
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
|
|
|
|
|
|
|
|
|
|
const [result, rawResponse, , rawRequest] =
|
|
|
|
|
soapResponseCustomerInsertUpdate;
|
|
|
|
|
|
|
|
|
|
@@ -317,7 +329,7 @@ async function QueryDmsCustomerById(socket, JobData, CustomerId) {
|
|
|
|
|
2
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
|
|
|
|
|
const CustomersFromDms =
|
|
|
|
|
result && result.return && result.return.customerParty;
|
|
|
|
|
return CustomersFromDms;
|
|
|
|
|
@@ -331,7 +343,7 @@ async function QueryDmsCustomerById(socket, JobData, CustomerId) {
|
|
|
|
|
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
socket,
|
|
|
|
|
error.response.data,
|
|
|
|
|
error.response && error.response.data,
|
|
|
|
|
`soapClientCustomerInsertUpdate.readAsync response.`,
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
@@ -366,7 +378,7 @@ async function QueryDmsCustomerByName(socket, JobData) {
|
|
|
|
|
key: ownerName,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseCustomerSearch);
|
|
|
|
|
|
|
|
|
|
const [result, rawResponse, , rawRequest] = soapResponseCustomerSearch;
|
|
|
|
|
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
@@ -390,6 +402,7 @@ async function QueryDmsCustomerByName(socket, JobData) {
|
|
|
|
|
2
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseCustomerSearch);
|
|
|
|
|
const CustomersFromDms = (result && result.return) || [];
|
|
|
|
|
return CustomersFromDms;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
@@ -402,7 +415,7 @@ async function QueryDmsCustomerByName(socket, JobData) {
|
|
|
|
|
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
socket,
|
|
|
|
|
error.response.data,
|
|
|
|
|
error.response && error.response.data,
|
|
|
|
|
`soapClientCustomerSearch.executeSearchBulkAsync response.`,
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
@@ -416,7 +429,7 @@ async function QueryDmsCustomerByName(socket, JobData) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function GenerateDmsCustomerNumber(socket, JobData) {
|
|
|
|
|
async function GenerateDmsCustomerNumber(socket) {
|
|
|
|
|
try {
|
|
|
|
|
const soapClientCustomerInsertUpdate = await soap.createClientAsync(
|
|
|
|
|
CdkWsdl.CustomerInsertUpdate
|
|
|
|
|
@@ -425,13 +438,13 @@ async function GenerateDmsCustomerNumber(socket, JobData) {
|
|
|
|
|
await soapClientCustomerInsertUpdate.getCustomerNumberAsync(
|
|
|
|
|
{
|
|
|
|
|
arg0: CDK_CREDENTIALS,
|
|
|
|
|
arg1: { dealerId: JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
|
|
|
|
arg1: { dealerId: socket.JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
|
|
|
|
arg2: { userId: null },
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
);
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
|
|
|
|
|
|
|
|
|
|
const [result, rawResponse, , rawRequest] =
|
|
|
|
|
soapResponseCustomerInsertUpdate;
|
|
|
|
|
|
|
|
|
|
@@ -456,6 +469,7 @@ async function GenerateDmsCustomerNumber(socket, JobData) {
|
|
|
|
|
2
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
|
|
|
|
|
const customerNumber =
|
|
|
|
|
result && result.return && result.return.customerNumber;
|
|
|
|
|
return customerNumber;
|
|
|
|
|
@@ -469,20 +483,20 @@ async function GenerateDmsCustomerNumber(socket, JobData) {
|
|
|
|
|
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
socket,
|
|
|
|
|
error.response.data,
|
|
|
|
|
error.response && error.response.data,
|
|
|
|
|
`soapClientCustomerInsertUpdate.getCustomerNumberAsync response.`,
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"ERROR",
|
|
|
|
|
`Error in GenerateDmsCustomerNumber - ${JSON.stringify(error, null, 2)}`
|
|
|
|
|
`Error in GenerateDmsCustomerNumber - ${error}`
|
|
|
|
|
);
|
|
|
|
|
throw new Error(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function InsertDmsCustomer(socket, JobData, newCustomerNumber) {
|
|
|
|
|
async function InsertDmsCustomer(socket, newCustomerNumber) {
|
|
|
|
|
try {
|
|
|
|
|
const soapClientCustomerInsertUpdate = await soap.createClientAsync(
|
|
|
|
|
CdkWsdl.CustomerInsertUpdate
|
|
|
|
|
@@ -491,27 +505,31 @@ async function InsertDmsCustomer(socket, JobData, newCustomerNumber) {
|
|
|
|
|
await soapClientCustomerInsertUpdate.insertAsync(
|
|
|
|
|
{
|
|
|
|
|
arg0: CDK_CREDENTIALS,
|
|
|
|
|
arg1: { dealerId: JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
|
|
|
|
arg1: { dealerId: socket.JobData.bodyshop.cdk_dealerid }, //TODO: Verify why this does not follow the other standards.
|
|
|
|
|
arg2: { userId: null },
|
|
|
|
|
arg3: {
|
|
|
|
|
//Copied the required fields from the other integration.
|
|
|
|
|
//TODO: Verify whether we need to bring more information in.
|
|
|
|
|
id: { value: newCustomerNumber },
|
|
|
|
|
address: {
|
|
|
|
|
city: JobData.ownr_city,
|
|
|
|
|
addressLine: socket.JobData.ownr_addr1,
|
|
|
|
|
city: socket.JobData.ownr_city,
|
|
|
|
|
country: null,
|
|
|
|
|
postalcode: JobData.ownr_zip,
|
|
|
|
|
stateOrProvince: JobData.ownr_st,
|
|
|
|
|
postalCode: socket.JobData.ownr_zip,
|
|
|
|
|
stateOrProvince: socket.JobData.ownr_st,
|
|
|
|
|
},
|
|
|
|
|
contactInfo: {
|
|
|
|
|
mainTelephoneNumber: { main: true, value: JobData.ownr_ph1 },
|
|
|
|
|
mainTelephoneNumber: {
|
|
|
|
|
main: true,
|
|
|
|
|
value: socket.JobData.ownr_ph1,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
demographics: null,
|
|
|
|
|
name1: {
|
|
|
|
|
companyname: JobData.ownr_co_nm,
|
|
|
|
|
firstName: JobData.ownr_fn,
|
|
|
|
|
companyname: socket.JobData.ownr_co_nm,
|
|
|
|
|
firstName: socket.JobData.ownr_fn,
|
|
|
|
|
fullname: null,
|
|
|
|
|
lastName: JobData.ownr_ln,
|
|
|
|
|
lastName: socket.JobData.ownr_ln,
|
|
|
|
|
middleName: null,
|
|
|
|
|
nameType: "Person",
|
|
|
|
|
suffix: null,
|
|
|
|
|
@@ -522,7 +540,7 @@ async function InsertDmsCustomer(socket, JobData, newCustomerNumber) {
|
|
|
|
|
|
|
|
|
|
{}
|
|
|
|
|
);
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
|
|
|
|
|
|
|
|
|
|
const [result, rawResponse, , rawRequest] =
|
|
|
|
|
soapResponseCustomerInsertUpdate;
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
@@ -545,7 +563,8 @@ async function InsertDmsCustomer(socket, JobData, newCustomerNumber) {
|
|
|
|
|
2
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
|
const customer = result && result.return;
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseCustomerInsertUpdate);
|
|
|
|
|
const customer = result && result.return && result.return.customerParty;
|
|
|
|
|
return customer;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
@@ -557,7 +576,7 @@ async function InsertDmsCustomer(socket, JobData, newCustomerNumber) {
|
|
|
|
|
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
socket,
|
|
|
|
|
error.response.data,
|
|
|
|
|
error.response && error.response.data,
|
|
|
|
|
`soapClientCustomerInsertUpdate.insertAsync response.`,
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
@@ -570,7 +589,7 @@ async function InsertDmsCustomer(socket, JobData, newCustomerNumber) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function InsertDmsVehicle(socket, JobData) {
|
|
|
|
|
async function InsertDmsVehicle(socket) {
|
|
|
|
|
try {
|
|
|
|
|
const soapClientVehicleInsertUpdate = await soap.createClientAsync(
|
|
|
|
|
CdkWsdl.VehicleInsertUpdate
|
|
|
|
|
@@ -579,31 +598,33 @@ async function InsertDmsVehicle(socket, JobData) {
|
|
|
|
|
const soapResponseVehicleInsertUpdate =
|
|
|
|
|
await soapClientVehicleInsertUpdate.insertAsync({
|
|
|
|
|
arg0: CDK_CREDENTIALS,
|
|
|
|
|
arg1: { id: JobData.bodyshop.cdk_dealerid },
|
|
|
|
|
arg1: { id: socket.JobData.bodyshop.cdk_dealerid },
|
|
|
|
|
arg2: {
|
|
|
|
|
dealer: {
|
|
|
|
|
dealerNumber: JobData.bodyshop.cdk_dealerid,
|
|
|
|
|
VehicleId: socket.DmsVehId.vehiclesVehId,
|
|
|
|
|
dealerNumber: socket.JobData.bodyshop.cdk_dealerid,
|
|
|
|
|
inServiceDate: moment().startOf("day").toISOString(),
|
|
|
|
|
vehicleId: socket.DMSVid.vehiclesVehId,
|
|
|
|
|
},
|
|
|
|
|
manufacturer: {},
|
|
|
|
|
vehicle: {
|
|
|
|
|
DeliveryDate: moment().format("YYYYMMDD"),
|
|
|
|
|
Make: socket.txEnvelope.dms_make,
|
|
|
|
|
Model: socket.txEnvelope.dms_model,
|
|
|
|
|
ModelYear: JobData.v_model_yr,
|
|
|
|
|
OdometerStatus: socket.txEnvelope.kmout,
|
|
|
|
|
SaleClassValue: "MISC",
|
|
|
|
|
VIN: JobData.v_vin,
|
|
|
|
|
deliveryDate: moment().format("YYYYMMDD"),
|
|
|
|
|
make: socket.txEnvelope.dms_make,
|
|
|
|
|
modelAbrev: socket.txEnvelope.dms_model,
|
|
|
|
|
modelYear: socket.JobData.v_model_yr,
|
|
|
|
|
odometerStatus: socket.txEnvelope.kmout,
|
|
|
|
|
saleClassValue: "MISC",
|
|
|
|
|
VIN: socket.JobData.v_vin,
|
|
|
|
|
},
|
|
|
|
|
owners: {
|
|
|
|
|
id: {
|
|
|
|
|
assigningPartyId: "CURRENT",
|
|
|
|
|
value: socket.DmsCust.id.value,
|
|
|
|
|
value: socket.DMSCust.id.value,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
arg3: "VEHICLES",
|
|
|
|
|
});
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
|
|
|
|
|
|
|
|
|
const [result, rawResponse, , rawRequest] = soapResponseVehicleInsertUpdate;
|
|
|
|
|
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
@@ -626,6 +647,75 @@ async function InsertDmsVehicle(socket, JobData) {
|
|
|
|
|
rawResponse,
|
|
|
|
|
`soapClientVehicleInsertUpdate.insertAsync response.`
|
|
|
|
|
);
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
|
|
|
|
const VehicleFromDMS = result && result.return && result.return.vehicle;
|
|
|
|
|
return VehicleFromDMS;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"ERROR",
|
|
|
|
|
`Error in QueryDmsVehicleById - ${error}`
|
|
|
|
|
);
|
|
|
|
|
throw new Error(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function UpdateDmsVehicle(socket) {
|
|
|
|
|
try {
|
|
|
|
|
const soapClientVehicleInsertUpdate = await soap.createClientAsync(
|
|
|
|
|
CdkWsdl.VehicleInsertUpdate
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const soapResponseVehicleInsertUpdate =
|
|
|
|
|
await soapClientVehicleInsertUpdate.updateAsync({
|
|
|
|
|
arg0: CDK_CREDENTIALS,
|
|
|
|
|
arg1: { id: socket.JobData.bodyshop.cdk_dealerid },
|
|
|
|
|
arg2: {
|
|
|
|
|
...socket.DMSVeh,
|
|
|
|
|
dealer: {
|
|
|
|
|
...socket.DMSVeh.dealer,
|
|
|
|
|
inServiceDate: moment(
|
|
|
|
|
socket.DMSVeh.dealer.inServiceDate
|
|
|
|
|
).toISOString(),
|
|
|
|
|
},
|
|
|
|
|
vehicle: {
|
|
|
|
|
...socket.DMSVeh.vehicle,
|
|
|
|
|
deliveryDate: moment(
|
|
|
|
|
socket.DMSVeh.vehicle.deliveryDate
|
|
|
|
|
).toISOString(),
|
|
|
|
|
},
|
|
|
|
|
owners: {
|
|
|
|
|
id: {
|
|
|
|
|
assigningPartyId: "CURRENT",
|
|
|
|
|
value: socket.DMSCust.id.value,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
arg3: "VEHICLES",
|
|
|
|
|
});
|
|
|
|
|
const [result, rawResponse, , rawRequest] = soapResponseVehicleInsertUpdate;
|
|
|
|
|
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
socket,
|
|
|
|
|
rawRequest,
|
|
|
|
|
`soapClientVehicleInsertUpdate.updateAsync reqest.`
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
CdkBase.createLogEvent(
|
|
|
|
|
socket,
|
|
|
|
|
"TRACE",
|
|
|
|
|
`soapClientVehicleInsertUpdate.updateAsync Result ${JSON.stringify(
|
|
|
|
|
result,
|
|
|
|
|
null,
|
|
|
|
|
2
|
|
|
|
|
)}`
|
|
|
|
|
);
|
|
|
|
|
CdkBase.createXmlEvent(
|
|
|
|
|
socket,
|
|
|
|
|
rawResponse,
|
|
|
|
|
`soapClientVehicleInsertUpdate.updateAsync response.`
|
|
|
|
|
);
|
|
|
|
|
CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
|
|
|
|
|
const VehicleFromDMS = result && result.return && result.return.vehicle;
|
|
|
|
|
return VehicleFromDMS;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|