Add and remove logging.

This commit is contained in:
Patrick Fic
2025-09-18 14:05:14 -07:00
parent fd229d5d09
commit 9e35b0f123

View File

@@ -68,7 +68,7 @@ exports.default = async function (socket, { txEnvelope, jobid }) {
exports.PbsSelectedCustomer = async function PbsSelectedCustomer(socket, selectedCustomerId) { exports.PbsSelectedCustomer = async function PbsSelectedCustomer(socket, selectedCustomerId) {
try { try {
if (socket.JobData.bodyshop.pbs_configuration.disablecontactvehicle === false) { if (socket.JobData.bodyshop.pbs_configuration.disablecontactvehicle !== true) {
CdkBase.createLogEvent(socket, "INFO", `User selected customer ${selectedCustomerId || "NEW"}`); CdkBase.createLogEvent(socket, "INFO", `User selected customer ${selectedCustomerId || "NEW"}`);
//Upsert the contact information as per Wafaa's Email. //Upsert the contact information as per Wafaa's Email.
@@ -90,19 +90,15 @@ exports.PbsSelectedCustomer = async function PbsSelectedCustomer(socket, selecte
`Contact and Vehicle updates disabled. Skipping to accounting data insert.` `Contact and Vehicle updates disabled. Skipping to accounting data insert.`
); );
} }
CdkBase.createLogEvent(socket, "INFO", `Inserting account data.`);
CdkBase.createLogEvent(socket, "INFO", `Inserting accounting posting data..`); CdkBase.createLogEvent(socket, "INFO", `Inserting accounting posting data..`);
const insertResponse = await InsertAccountPostingData(socket); const insertResponse = await InsertAccountPostingData(socket);
if (insertResponse.WasSuccessful) { if (insertResponse.WasSuccessful) {
CdkBase.createLogEvent(socket, "INFO", `Marking job as exported.`); CdkBase.createLogEvent(socket, "INFO", `Marking job as exported.`);
await MarkJobExported(socket, socket.JobData.id); await MarkJobExported(socket, socket.JobData.id);
if (socket.jobData.bodyshop.pbs_configuration.ro_posting) {
//If export succesful, check to see if an RO exists. await CreateRepairOrderInPBS(socket, socket.ownerRef, socket.vehicleRef)
//If it does, update necessary elements, otherwise create it. }
// if (socket.jobData.bodyshop.pbs_configuration.ro_posting) { //TODO: Create `ro_posting` field on
await CreateRepairOrderInPBS(socket, socket.ownerRef, socket.vehicleRef)
// }
socket.emit("export-success", socket.JobData.id); socket.emit("export-success", socket.JobData.id);
} else { } else {
CdkBase.createLogEvent(socket, "ERROR", `Export was not successful.`); CdkBase.createLogEvent(socket, "ERROR", `Export was not successful.`);
@@ -630,11 +626,13 @@ async function CreateRepairOrderInPBS(socket) {
if (RepairOrders.length === 0) { if (RepairOrders.length === 0) {
const InsertedRepairOrder = await RepairOrderChange(socket) const InsertedRepairOrder = await RepairOrderChange(socket)
socket.InsertedRepairOrder = InsertedRepairOrder; socket.InsertedRepairOrder = InsertedRepairOrder;
CdkBase.createLogEvent(socket, "INFO", `No repair orders found for vehicle. Inserting record.`);
} else if (RepairOrders.length > 0) { } else if (RepairOrders.length > 0) {
//Find out if it's a matching RO. //Find out if it's a matching RO.
const matchingRo = RepairOrders.find(ro => ro.Memo?.toLowerCase()?.includes(socket.JobData.ro_number.toLowerCase())) const matchingRo = RepairOrders.find(ro => ro.Memo?.toLowerCase()?.includes(socket.JobData.ro_number.toLowerCase()))
if (!matchingRo) { if (!matchingRo) {
CdkBase.createLogEvent(socket, "INFO", `ROs found for customer, but none match. Inserting record.`); CdkBase.createLogEvent(socket, "INFO", `ROs found for vehicle, but none match. Inserting record.`);
const InsertedRepairOrder = await RepairOrderChange(socket) const InsertedRepairOrder = await RepairOrderChange(socket)
socket.InsertedRepairOrder = InsertedRepairOrder; socket.InsertedRepairOrder = InsertedRepairOrder;
} else { } else {