Merged in hotfix/2021-12-29 (pull request #328)

Cherrypick CDK Fixes.

Approved-by: Patrick Fic
This commit is contained in:
Patrick Fic
2021-12-30 04:06:46 +00:00

View File

@@ -96,6 +96,7 @@ exports.default = async function (socket, { txEnvelope, jobid }) {
async function CdkSelectedCustomer(socket, selectedCustomerId) {
try {
socket.selectedCustomerId = selectedCustomerId;
if (selectedCustomerId) {
CdkBase.createLogEvent(
socket,
@@ -282,7 +283,12 @@ async function CalculateDmsVid(socket, JobData) {
)}`
);
CheckCdkResponseForError(socket, soapResponseVehicleInsertUpdate);
return result && result.return && result.return[0];
//if (result && result.return && result.return.length > 1) {
return result.return.find((r) => r.vehiclesVehId);
//}
//return result && result.return && result.return[0];
} catch (error) {
CdkBase.createXmlEvent(
socket,
@@ -605,7 +611,7 @@ async function InsertDmsCustomer(socket, newCustomerNumber) {
contactInfo: {
mainTelephoneNumber: {
main: true,
value: socket.JobData.ownr_ph1,
value: socket.JobData.ownr_ph1.replace(replaceSpecialRegex, ""),
},
email: {
desc: socket.JobData.ownr_ea ? "Other" : "CustomerDeclined",
@@ -773,45 +779,56 @@ async function UpdateDmsVehicle(socket) {
let ids = [];
const existingOwnerinVeh =
socket.DMSVeh &&
socket.DMSVeh.owners &&
socket.DMSVeh.owners.find((o) => o.id.value === socket.DMSCust.id.value);
//if it's a generic customer, don't update the vehicle owners.
if (existingOwnerinVeh) {
ids = socket.DMSVeh.owners.map((o) => {
return {
id: {
assigningPartyId:
o.id.value === socket.DMSCust.id.value ? "CURRENT" : "PREVIOUS",
value: o.id.value,
},
};
});
if (
socket.selectedCustomerId ===
socket.JobData.bodyshop.cdk_configuration.generic_customer_number
) {
ids = socket.DMSVeh && socket.DMSVeh.owners && socket.DMSVeh.owners;
} else {
const oldOwner =
const existingOwnerinVeh =
socket.DMSVeh &&
socket.DMSVeh.owners &&
socket.DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
socket.DMSVeh.owners.find(
(o) => o.id.value === socket.DMSCust.id.value
);
ids = [
{
id: {
assigningPartyId: "CURRENT",
value: socket.DMSCust.id.value,
if (existingOwnerinVeh) {
ids = socket.DMSVeh.owners.map((o) => {
return {
id: {
assigningPartyId:
o.id.value === socket.DMSCust.id.value ? "CURRENT" : "PREVIOUS",
value: o.id.value,
},
};
});
} else {
const oldOwner =
socket.DMSVeh &&
socket.DMSVeh.owners &&
socket.DMSVeh.owners.find((o) => o.id.assigningPartyId === "CURRENT");
ids = [
{
id: {
assigningPartyId: "CURRENT",
value: socket.DMSCust.id.value,
},
},
},
...(oldOwner
? [
{
id: {
assigningPartyId: "PREVIOUS",
value: oldOwner.id.value,
...(oldOwner
? [
{
id: {
assigningPartyId: "PREVIOUS",
value: oldOwner.id.value,
},
},
},
]
: []),
];
]
: []),
];
}
}
const soapResponseVehicleInsertUpdate =