diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 939e5bb18..a77e7e73f 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -3872,6 +3872,27 @@ + + disablecontactvehiclecreation + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + dms_acctnumber false diff --git a/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx b/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx index 6c0eeaa60..98bb7ac50 100644 --- a/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx +++ b/client/src/components/bill-enter-modal/bill-enter-modal.container.jsx @@ -93,6 +93,7 @@ function BillEnterModalContainer({ deductedfromlbr, lbr_adjustment, location: lineLocation, + part_type, ...restI } = i; diff --git a/client/src/components/documents-upload/documents-upload.utility.js b/client/src/components/documents-upload/documents-upload.utility.js index 240e22e26..9e39c8cf9 100644 --- a/client/src/components/documents-upload/documents-upload.utility.js +++ b/client/src/components/documents-upload/documents-upload.utility.js @@ -6,6 +6,7 @@ import { INSERT_NEW_DOCUMENT } from "../../graphql/documents.queries"; import { axiosAuthInterceptorId } from "../../utils/CleanAxios"; import client from "../../utils/GraphQLClient"; import exifr from "exifr"; +import { store } from "../../redux/store"; //Context: currentUserEmail, bodyshop, jobid, invoiceid @@ -112,7 +113,19 @@ export const uploadToCloudinary = async ( ); if (cloudinaryUploadResponse.status !== 200) { - if (!!onError) onError(cloudinaryUploadResponse.statusText); + if (!!onError) { + onError(cloudinaryUploadResponse.statusText); + } + + try { + axios.post("/newlog", { + message: "client-cloudinary-upload-error", + type: "error", + user: store.getState().user.email, + object: cloudinaryUploadResponse, + }); + } catch (error) {} + notification["error"]({ message: i18n.t("documents.errors.insert", { message: cloudinaryUploadResponse.statusText, diff --git a/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx b/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx index 3b89799f4..3dad78a86 100644 --- a/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx +++ b/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx @@ -129,6 +129,15 @@ export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { > + {bodyshop.pbs_serialnumber && ( + + + + )} diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 65de30e1a..4377750a0 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -246,6 +246,7 @@ "dms": { "cashierid": "Cashier ID", "default_journal": "Default Journal", + "disablecontactvehiclecreation": "Disable Contact & Vehicle Updates/Creation", "dms_acctnumber": "DMS Account #", "dms_wip_acctnumber": "DMS W.I.P. Account #", "generic_customer_number": "Generic Customer Number", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 096511350..28bddd12a 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -246,6 +246,7 @@ "dms": { "cashierid": "", "default_journal": "", + "disablecontactvehiclecreation": "", "dms_acctnumber": "", "dms_wip_acctnumber": "", "generic_customer_number": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index c9bd6291b..6fc35a8a7 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -246,6 +246,7 @@ "dms": { "cashierid": "", "default_journal": "", + "disablecontactvehiclecreation": "", "dms_acctnumber": "", "dms_wip_acctnumber": "", "generic_customer_number": "", diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index 004cdf5a8..fbcd2db79 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -928,6 +928,7 @@ - md_referral_sources - md_responsibility_centers - md_ro_statuses + - pbs_configuration - phone - prodtargethrs - production_config diff --git a/server.js b/server.js index 0828eac3b..fdfc431d9 100644 --- a/server.js +++ b/server.js @@ -179,7 +179,10 @@ app.post("/data/arms", data.arms); var ioevent = require("./server/ioevent/ioevent"); app.post("/ioevent", ioevent.default); - +app.post("/newlog", (req, res) => { + const { message, type, user, record, object } = req.body; + logger.log(message, type, user, record, object); +}); var cdkGetMake = require("./server/cdk/cdk-get-makes"); app.post("/cdk/getvehicles", fb.validateFirebaseIdToken, cdkGetMake.default); diff --git a/server/accounting/pbs/pbs-job-export.js b/server/accounting/pbs/pbs-job-export.js index e7bdcdb80..f6f83dfb7 100644 --- a/server/accounting/pbs/pbs-job-export.js +++ b/server/accounting/pbs/pbs-job-export.js @@ -103,28 +103,38 @@ exports.PbsSelectedCustomer = async function PbsSelectedCustomer( selectedCustomerId ) { try { - CdkBase.createLogEvent( - socket, - "DEBUG", - `User selected customer ${selectedCustomerId || "NEW"}` - ); + if ( + socket.JobData.bodyshop.pbs_configuration.disablecontactvehicle === false + ) { + CdkBase.createLogEvent( + socket, + "DEBUG", + `User selected customer ${selectedCustomerId || "NEW"}` + ); - //Upsert the contact information as per Wafaa's Email. - CdkBase.createLogEvent( - socket, - "DEBUG", - `Upserting contact information to DMS for ${ - socket.JobData.ownr_fn || "" - } ${socket.JobData.ownr_ln || ""} ${socket.JobData.ownr_co_nm || ""}` - ); - const ownerRef = await UpsertContactData(socket, selectedCustomerId); + //Upsert the contact information as per Wafaa's Email. + CdkBase.createLogEvent( + socket, + "DEBUG", + `Upserting contact information to DMS for ${ + socket.JobData.ownr_fn || "" + } ${socket.JobData.ownr_ln || ""} ${socket.JobData.ownr_co_nm || ""}` + ); + const ownerRef = await UpsertContactData(socket, selectedCustomerId); - CdkBase.createLogEvent( - socket, - "DEBUG", - `Upserting vehicle information to DMS for ${socket.JobData.v_vin}` - ); - await UpsertVehicleData(socket, ownerRef.ReferenceId); + CdkBase.createLogEvent( + socket, + "DEBUG", + `Upserting vehicle information to DMS for ${socket.JobData.v_vin}` + ); + await UpsertVehicleData(socket, ownerRef.ReferenceId); + } else { + CdkBase.createLogEvent( + socket, + "DEBUG", + `Contact and Vehicle updates disabled. Skipping to accounting data insert.` + ); + } CdkBase.createLogEvent(socket, "DEBUG", `Inserting account data.`); CdkBase.createLogEvent( socket, diff --git a/server/data/autohouse.js b/server/data/autohouse.js index 2297ac21f..1cba662d6 100644 --- a/server/data/autohouse.js +++ b/server/data/autohouse.js @@ -93,6 +93,7 @@ exports.default = async (req, res) => { .end({ allowEmptyTags: true }); allxmlsToUpload.push({ + count: autoHouseObject.AutoHouseExport.RepairOrder.length, xml: ret, filename: `IM_${bodyshop.autohouseid}_${moment().format( "DDMMYYYY_HHMMSS" @@ -123,12 +124,12 @@ exports.default = async (req, res) => { } } - for (const xmlObj of allxmlsToUpload) { - fs.writeFileSync(`./logs/${xmlObj.filename}`, xmlObj.xml); - } + // for (const xmlObj of allxmlsToUpload) { + // fs.writeFileSync(`./logs/${xmlObj.filename}`, xmlObj.xml); + // } - res.json(allxmlsToUpload); - return; + // res.json(allxmlsToUpload); + // return; let sftp = new Client(); sftp.on("error", (errors) => @@ -227,7 +228,11 @@ const CreateRepairOrderTag = (job, errorCallback) => { InsuredorClaimantFlag: null, }, VehicleInformation: { - Year: parseInt(job.v_model_yr.match(/\d/g).join(""), 10) || "", + Year: job.v_model_yr + ? parseInt(job.v_model_yr.match(/\d/g)) + ? parseInt(job.v_model_yr.match(/\d/g).join(""), 10) + : "" + : "", Make: job.v_make_desc || "", Model: job.v_model_desc || "", VIN: job.v_vin || "", @@ -267,22 +272,14 @@ const CreateRepairOrderTag = (job, errorCallback) => { }, Dates: { DateofLoss: - (job.loss_date && - moment(job.loss_date) - .tz(job.bodyshop.timezone) - .format(AhDateFormat)) || - "", + (job.loss_date && moment(job.loss_date).format(AhDateFormat)) || "", InitialCustomerContactDate: null, FirstFollowUpDate: null, ReferralDate: null, EstimateAppointmentDate: null, SecondFollowUpDate: null, AssignedDate: - (job.asgn_date && - moment(job.asgn_date) - .tz(job.bodyshop.timezone) - .format(AhDateFormat)) || - "", + (job.asgn_date && moment(job.asgn_date).format(AhDateFormat)) || "", EstComplete: null, CustomerAuthorizationDate: null, InsuranceAuthorizationDate: null, @@ -808,9 +805,9 @@ const GenerateDetailLines = (job, line, statuses) => { MarkUp: null, OrderedOn: (line.parts_order_lines[0] && - moment(line.parts_order_lines[0].parts_order.order_date) - .tz(job.bodyshop.timezone) - .format(AhDateFormat)) || + moment(line.parts_order_lines[0].parts_order.order_date).format( + AhDateFormat + )) || "", OriginalCost: null, OriginalInvoiceNumber: null, @@ -830,9 +827,7 @@ const GenerateDetailLines = (job, line, statuses) => { ExpectedOn: null, ReceivedOn: line.billlines[0] && - moment(line.billlines[0].bill.date) - .tz(job.bodyshop.timezone) - .format(AhDateFormat), + moment(line.billlines[0].bill.date).format(AhDateFormat), OrderedBy: null, ShipVia: null, VendorContact: null, diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index 6284de616..74f4f3a15 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -581,7 +581,6 @@ exports.AUTOHOUSE_QUERY = `query AUTOHOUSE_EXPORT($start: timestamptz, $bodyshop ownr_st ownr_ph1 ownr_zip - referral_source loss_type v_model_yr v_model_desc diff --git a/server/scheduling/scheduling-job.js b/server/scheduling/scheduling-job.js index d461e1395..24b5577b0 100644 --- a/server/scheduling/scheduling-job.js +++ b/server/scheduling/scheduling-job.js @@ -148,14 +148,14 @@ exports.job = async (req, res) => { //Propagate the expected load to each day. const yesterday = moment().tz(timezone).subtract(1, "day"); - const today = moment().tz(timezone).startOf("day"); + const today = moment().tz(timezone); - const end = moment.tz(timezone).max([ + const end = moment.max([ ...filteredArrJobs.map((a) => moment(a.scheduled_in).tz(timezone)), ...filteredCompJobs .map((p) => moment(p.actual_completion || p.scheduled_completion).tz(timezone)) .filter((p) => p.isValid() && p.isAfter(yesterday)), - moment().tz(timezone).add(5, "days"), + moment().tz(timezone).add(15, "days"), ]); const range = Math.round(moment.duration(end.diff(today)).asDays()); for (var day = 0; day < range; day++) { @@ -199,7 +199,7 @@ exports.job = async (req, res) => { const possibleDates = []; delete load.productionTotal; const loadKeys = Object.keys(load).sort((a, b) => - moment(a).tz(timezone).isAfter(moment(b).tz(timezone)) ? 1 : -1 + moment(a).isAfter(moment(b)) ? 1 : -1 ); loadKeys.forEach((loadKey) => {