Merged in release/2021-12/31 (pull request #325)

release/2021-12/31

Approved-by: Patrick Fic
This commit is contained in:
Patrick Fic
2021-12-29 16:27:26 +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,
@@ -605,7 +606,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 +774,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 =