Updates to CDK job export for existing customers & incorrect phone.

This commit is contained in:
Patrick Fic
2021-12-28 15:05:25 -08:00
parent fb92aae8cd
commit 072650cf94

View File

@@ -96,6 +96,7 @@ exports.default = async function (socket, { txEnvelope, jobid }) {
async function CdkSelectedCustomer(socket, selectedCustomerId) { async function CdkSelectedCustomer(socket, selectedCustomerId) {
try { try {
socket.selectedCustomerId = selectedCustomerId;
if (selectedCustomerId) { if (selectedCustomerId) {
CdkBase.createLogEvent( CdkBase.createLogEvent(
socket, socket,
@@ -605,7 +606,7 @@ async function InsertDmsCustomer(socket, newCustomerNumber) {
contactInfo: { contactInfo: {
mainTelephoneNumber: { mainTelephoneNumber: {
main: true, main: true,
value: socket.JobData.ownr_ph1, value: socket.JobData.ownr_ph1.replace(replaceSpecialRegex, ""),
}, },
email: { email: {
desc: socket.JobData.ownr_ea ? "Other" : "CustomerDeclined", desc: socket.JobData.ownr_ea ? "Other" : "CustomerDeclined",
@@ -773,45 +774,56 @@ async function UpdateDmsVehicle(socket) {
let ids = []; let ids = [];
const existingOwnerinVeh = //if it's a generic customer, don't update the vehicle owners.
socket.DMSVeh &&
socket.DMSVeh.owners &&
socket.DMSVeh.owners.find((o) => o.id.value === socket.DMSCust.id.value);
if (existingOwnerinVeh) { if (
ids = socket.DMSVeh.owners.map((o) => { socket.selectedCustomerId ===
return { socket.JobData.bodyshop.cdk_configuration.generic_customer_number
id: { ) {
assigningPartyId: ids = socket.DMSVeh && socket.DMSVeh.owners && socket.DMSVeh.owners;
o.id.value === socket.DMSCust.id.value ? "CURRENT" : "PREVIOUS",
value: o.id.value,
},
};
});
} else { } else {
const oldOwner = const existingOwnerinVeh =
socket.DMSVeh && socket.DMSVeh &&
socket.DMSVeh.owners && 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 = [ if (existingOwnerinVeh) {
{ ids = socket.DMSVeh.owners.map((o) => {
id: { return {
assigningPartyId: "CURRENT", id: {
value: socket.DMSCust.id.value, 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
...(oldOwner ? [
? [ {
{ id: {
id: { assigningPartyId: "PREVIOUS",
assigningPartyId: "PREVIOUS", value: oldOwner.id.value,
value: oldOwner.id.value, },
}, },
}, ]
] : []),
: []), ];
]; }
} }
const soapResponseVehicleInsertUpdate = const soapResponseVehicleInsertUpdate =