Merge branch 'master-AIO' into feature/IO-3001-us-est-scrubbing
This commit is contained in:
@@ -19,7 +19,8 @@ async function JobCosting(req, res) {
|
||||
const BearerToken = req.BearerToken;
|
||||
const client = req.userGraphQLClient;
|
||||
|
||||
logger.log("job-costing-start", "DEBUG", req.user.email, jobid, null);
|
||||
//Uncomment for further testing
|
||||
// logger.log("job-costing-start", "DEBUG", req.user.email, jobid, null);
|
||||
|
||||
try {
|
||||
const resp = await client.setHeaders({ Authorization: BearerToken }).request(queries.QUERY_JOB_COSTING_DETAILS, {
|
||||
@@ -46,7 +47,10 @@ async function JobCostingMulti(req, res) {
|
||||
const BearerToken = req.BearerToken;
|
||||
const client = req.userGraphQLClient;
|
||||
|
||||
logger.log("job-costing-multi-start", "DEBUG", req.user.email, jobids, null);
|
||||
//Uncomment for further testing
|
||||
// logger.log("job-costing-multi-start", "DEBUG", req?.user?.email, null, {
|
||||
// jobids
|
||||
// });
|
||||
|
||||
try {
|
||||
const resp = await client
|
||||
@@ -244,7 +248,8 @@ async function JobCostingMulti(req, res) {
|
||||
data: ret
|
||||
});
|
||||
} catch (error) {
|
||||
logger.log("job-costing-multi-error", "ERROR", req.user.email, [jobids], {
|
||||
logger.log("job-costing-multi-error", "ERROR", req?.user?.email, null, {
|
||||
jobids,
|
||||
message: error.message,
|
||||
stack: error.stack
|
||||
});
|
||||
@@ -282,7 +287,13 @@ function GenerateCostingData(job) {
|
||||
if (val.mod_lbr_ty) {
|
||||
const laborProfitCenter = val.profitcenter_labor || defaultProfits[val.mod_lbr_ty] || "Unknown";
|
||||
|
||||
if (laborProfitCenter === "Unknown") console.log("Unknown type", val.line_desc, val.mod_lbr_ty);
|
||||
//Uncomment for further testing
|
||||
// if (laborProfitCenter === "Unknown") {
|
||||
// logger.log("job-costing unknown type", "debug", null, null, {
|
||||
// line_desc: val.line_desc,
|
||||
// mod_lbr_ty: val.mod_lbr_ty
|
||||
// });
|
||||
// }
|
||||
|
||||
const rateName = `rate_${(val.mod_lbr_ty || "").toLowerCase()}`;
|
||||
|
||||
@@ -349,10 +360,22 @@ function GenerateCostingData(job) {
|
||||
if (val.part_type && val.part_type !== "PAE" && val.part_type !== "PAS" && val.part_type !== "PASL") {
|
||||
const partsProfitCenter = val.profitcenter_part || defaultProfits[val.part_type] || "Unknown";
|
||||
|
||||
if (partsProfitCenter === "Unknown") console.log("Unknown type", val.line_desc, val.part_type);
|
||||
//Uncomment for further testing
|
||||
// if (partsProfitCenter === "Unknown" || !partsProfitCenter) {
|
||||
// logger.log(
|
||||
// partsProfitCenter === "Unknown"
|
||||
// ? "job-costing unknown type"
|
||||
// : "Unknown cost/profit center mapping for parts.",
|
||||
// "debug",
|
||||
// null,
|
||||
// null,
|
||||
// {
|
||||
// line_desc: val.line_desc,
|
||||
// part_type: val.part_type
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
|
||||
if (!partsProfitCenter)
|
||||
console.log("Unknown cost/profit center mapping for parts.", val.line_desc, val.part_type);
|
||||
let partsAmount = Dinero({
|
||||
amount: val.act_price_before_ppc
|
||||
? Math.round(val.act_price_before_ppc * 100)
|
||||
@@ -409,10 +432,22 @@ function GenerateCostingData(job) {
|
||||
if (val.part_type && val.part_type !== "PAE" && (val.part_type === "PAS" || val.part_type === "PASL")) {
|
||||
const partsProfitCenter = val.profitcenter_part || defaultProfits[val.part_type] || "Unknown";
|
||||
|
||||
if (partsProfitCenter === "Unknown") console.log("Unknown type", val.line_desc, val.part_type);
|
||||
//Uncomment for further testing
|
||||
// if (partsProfitCenter === "Unknown" || !partsProfitCenter) {
|
||||
// logger.log(
|
||||
// partsProfitCenter === "Unknown"
|
||||
// ? "job-costing unknown type"
|
||||
// : "job-costing Unknown cost/profit center mapping for sublet",
|
||||
// "debug",
|
||||
// null,
|
||||
// null,
|
||||
// {
|
||||
// line_desc: val.line_desc,
|
||||
// part_type: val.part_type
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
|
||||
if (!partsProfitCenter)
|
||||
console.log("Unknown cost/profit center mapping for sublet.", val.line_desc, val.part_type);
|
||||
const partsAmount = Dinero({
|
||||
amount: Math.round((val.act_price || 0) * 100)
|
||||
})
|
||||
@@ -443,9 +478,14 @@ function GenerateCostingData(job) {
|
||||
//If so, use it, otherwise try to use the same from the auto-allocate logic in IO app jobs-close-auto-allocate.
|
||||
const partsProfitCenter = val.profitcenter_part || getAdditionalCostCenter(val, defaultProfits) || "Unknown";
|
||||
|
||||
if (partsProfitCenter === "Unknown") {
|
||||
console.log("Unknown type", val.line_desc, val.part_type);
|
||||
}
|
||||
//Uncomment for further testing
|
||||
// if (partsProfitCenter === "Unknown") {
|
||||
// logger.log("job-costing unknown type", "debug", null, null, {
|
||||
// line_desc: val.line_desc,
|
||||
// part_type: val.part_type
|
||||
// });
|
||||
// }
|
||||
|
||||
const partsAmount = Dinero({
|
||||
amount: Math.round((val.act_price || 0) * 100)
|
||||
})
|
||||
|
||||
@@ -26,7 +26,7 @@ exports.totalsSsu = async function (req, res) {
|
||||
const BearerToken = req.BearerToken;
|
||||
const client = req.userGraphQLClient;
|
||||
|
||||
logger.log("job-totals-ssu-USA", "DEBUG", req.user.email, id, null);
|
||||
logger.log("job-totals-ssu-USA", "DEBUG", req?.user?.email, id);
|
||||
|
||||
try {
|
||||
const job = await client.setHeaders({ Authorization: BearerToken }).request(queries.GET_JOB_BY_PK, {
|
||||
@@ -47,7 +47,7 @@ exports.totalsSsu = async function (req, res) {
|
||||
|
||||
res.status(200).send();
|
||||
} catch (error) {
|
||||
logger.log("job-totals-ssu-USA-error", "ERROR", req.user.email, id, {
|
||||
logger.log("job-totals-ssu-USA-error", "ERROR", req?.user?.email, id, {
|
||||
jobid: id,
|
||||
error
|
||||
});
|
||||
@@ -123,12 +123,10 @@ async function Totals(req, res) {
|
||||
const logger = req.logger;
|
||||
const client = req.userGraphQLClient;
|
||||
|
||||
logger.log("job-totals-USA", "DEBUG", req.user.email, job.id, {
|
||||
logger.log("job-totals-ssu-USA", "DEBUG", req.user.email, job.id, {
|
||||
jobid: job.id
|
||||
});
|
||||
|
||||
logger.log("job-totals-ssu-USA", "DEBUG", req.user.email, id, null);
|
||||
|
||||
await AutoAddAtsIfRequired({ job, client });
|
||||
|
||||
try {
|
||||
@@ -1000,7 +998,9 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Key with issue", key);
|
||||
logger.log("job-totals-USA Key with issue", "error", null, null, {
|
||||
key
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1065,7 +1065,9 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
totalTaxByTier[taxTierKey] = totalTaxByTier[taxTierKey].add(taxAmountToAdd);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("PFP Calculation error", error);
|
||||
logger.log("job-totals-USA - PFP Calculation Error", "error", null, null, {
|
||||
error
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -2,8 +2,16 @@ const { isObject } = require("lodash");
|
||||
|
||||
const jobUpdated = async (req, res) => {
|
||||
const { ioRedis, logger, ioHelpers } = req;
|
||||
// Old Way
|
||||
if (req?.body?.event?.data?.new || isObject(req?.body?.event?.data?.new)) {
|
||||
const updatedJob = req.body.event.data.new;
|
||||
const bodyshopID = updatedJob.shopid;
|
||||
ioRedis.to(ioHelpers.getBodyshopRoom(bodyshopID)).emit("production-job-updated", updatedJob);
|
||||
return res.json({ message: "Job updated and event emitted" });
|
||||
}
|
||||
|
||||
if (!req?.body?.event?.data?.new || !isObject(req?.body?.event?.data?.new)) {
|
||||
// New way
|
||||
if (!req?.body?.data || !isObject(req.body.data)) {
|
||||
logger.log("job-update-error", "ERROR", req.user?.email, null, {
|
||||
message: `Malformed Job Update request sent from Hasura`,
|
||||
body: req?.body
|
||||
@@ -15,12 +23,14 @@ const jobUpdated = async (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
logger.log("job-update", "INFO", req.user?.email, null, {
|
||||
message: `Job updated event received from Hasura`,
|
||||
jobid: req?.body?.event?.data?.new?.id
|
||||
});
|
||||
// Uncomment for further testing
|
||||
// You can also test this using SocketIOAdmin
|
||||
// logger.log("job-update", "DEBUG", req.user?.email, null, {
|
||||
// message: `Job updated event received from Hasura`,
|
||||
// jobid: req?.body?.event?.data?.new?.id
|
||||
// });
|
||||
|
||||
const updatedJob = req.body.event.data.new;
|
||||
const updatedJob = req.body.data;
|
||||
const bodyshopID = updatedJob.shopid;
|
||||
|
||||
// Emit the job-updated event only to the room corresponding to the bodyshop
|
||||
|
||||
Reference in New Issue
Block a user