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) {
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,10 +774,20 @@ async function UpdateDmsVehicle(socket) {
let ids = [];
//if it's a generic customer, don't update the vehicle owners.
if (
socket.selectedCustomerId ===
socket.JobData.bodyshop.cdk_configuration.generic_customer_number
) {
ids = socket.DMSVeh && socket.DMSVeh.owners && socket.DMSVeh.owners;
} else {
const existingOwnerinVeh =
socket.DMSVeh &&
socket.DMSVeh.owners &&
socket.DMSVeh.owners.find((o) => o.id.value === socket.DMSCust.id.value);
socket.DMSVeh.owners.find(
(o) => o.id.value === socket.DMSCust.id.value
);
if (existingOwnerinVeh) {
ids = socket.DMSVeh.owners.map((o) => {
@@ -813,6 +824,7 @@ async function UpdateDmsVehicle(socket) {
: []),
];
}
}
const soapResponseVehicleInsertUpdate =
await soapClientVehicleInsertUpdate.updateAsync({