release/2024-11-01 - Misc fixes
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -46,7 +46,9 @@ 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);
|
||||
logger.log("job-costing-multi-start", "DEBUG", req?.user?.email, null, {
|
||||
jobids
|
||||
});
|
||||
|
||||
try {
|
||||
const resp = await client
|
||||
@@ -244,7 +246,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 +285,12 @@ 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);
|
||||
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 +357,21 @@ 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);
|
||||
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 +428,21 @@ 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);
|
||||
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)
|
||||
})
|
||||
@@ -444,7 +474,10 @@ function GenerateCostingData(job) {
|
||||
const partsProfitCenter = val.profitcenter_part || getAdditionalCostCenter(val, defaultProfits) || "Unknown";
|
||||
|
||||
if (partsProfitCenter === "Unknown") {
|
||||
console.log("Unknown type", val.line_desc, val.part_type);
|
||||
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)
|
||||
@@ -476,7 +509,7 @@ function GenerateCostingData(job) {
|
||||
if (!hasMapaLine) {
|
||||
if (!jobLineTotalsByProfitCenter.additional[defaultProfits["MAPA"]])
|
||||
jobLineTotalsByProfitCenter.additional[defaultProfits["MAPA"]] = Dinero();
|
||||
|
||||
|
||||
jobLineTotalsByProfitCenter.additional[defaultProfits["MAPA"]] = jobLineTotalsByProfitCenter.additional[
|
||||
defaultProfits["MAPA"]
|
||||
].add(
|
||||
|
||||
@@ -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
|
||||
});
|
||||
@@ -84,12 +84,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 {
|
||||
@@ -961,7 +959,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
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1026,7 +1026,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
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user