Add error handling when unable to caclulate job totals.
This commit is contained in:
@@ -139,80 +139,86 @@ export function JobsDetailPage({
|
||||
},
|
||||
},
|
||||
});
|
||||
try {
|
||||
const newTotals = await Axios.post("/job/totalsssu", {
|
||||
id: job.id,
|
||||
});
|
||||
|
||||
const newTotals = await Axios.post("/job/totalsssu", {
|
||||
id: job.id,
|
||||
});
|
||||
if (newTotals.status !== 200 || result.errors) {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.totalscalc"),
|
||||
});
|
||||
} else {
|
||||
notification["success"]({
|
||||
message: t("jobs.successes.savetitle"),
|
||||
});
|
||||
const changedAuditFields = form.getFieldsValue(
|
||||
[
|
||||
"scheduled_in",
|
||||
"actual_in",
|
||||
"scheduled_completion",
|
||||
"actual_completion",
|
||||
"scheduled_delivery",
|
||||
"actual_delivery",
|
||||
"date_invoiced",
|
||||
"ins_co_nm",
|
||||
"ded_amt",
|
||||
"ded_status",
|
||||
"date_exported",
|
||||
"special_coverage_policy",
|
||||
"ca_gst_registrant",
|
||||
"ca_bc_pvrt",
|
||||
"scheduled_in",
|
||||
"rate_la1",
|
||||
"rate_la2",
|
||||
"rate_la3",
|
||||
"rate_la4",
|
||||
"rate_laa",
|
||||
"rate_lab",
|
||||
"rate_lad",
|
||||
"rate_lae",
|
||||
"rate_laf",
|
||||
"rate_lag",
|
||||
"rate_lam",
|
||||
"rate_lar",
|
||||
"rate_las",
|
||||
"rate_lau",
|
||||
"rate_ma2s",
|
||||
"rate_ma2t",
|
||||
"rate_ma3s",
|
||||
"rate_mabl",
|
||||
"rate_macs",
|
||||
"rate_mapa",
|
||||
"rate_mahw",
|
||||
"rate_mash",
|
||||
"rate_matd",
|
||||
],
|
||||
(meta) => meta && meta.touched
|
||||
);
|
||||
|
||||
if (newTotals.status !== 200 || result.errors) {
|
||||
Object.keys(changedAuditFields).forEach((key) => {
|
||||
insertAuditTrail({
|
||||
jobid: job.id,
|
||||
operation: AuditTrailMapping.jobfieldchange(
|
||||
key,
|
||||
changedAuditFields[key] instanceof moment
|
||||
? moment(changedAuditFields[key]).format("MM/DD/YYYY hh:mm a")
|
||||
: changedAuditFields[key]
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
await refetch();
|
||||
form.setFieldsValue(transormJobToForm(job));
|
||||
form.resetFields();
|
||||
}
|
||||
} catch (error) {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.totalscalc"),
|
||||
});
|
||||
} else {
|
||||
notification["success"]({
|
||||
message: t("jobs.successes.savetitle"),
|
||||
});
|
||||
const changedAuditFields = form.getFieldsValue(
|
||||
[
|
||||
"scheduled_in",
|
||||
"actual_in",
|
||||
"scheduled_completion",
|
||||
"actual_completion",
|
||||
"scheduled_delivery",
|
||||
"actual_delivery",
|
||||
"date_invoiced",
|
||||
"ins_co_nm",
|
||||
"ded_amt",
|
||||
"ded_status",
|
||||
"date_exported",
|
||||
"special_coverage_policy",
|
||||
"ca_gst_registrant",
|
||||
"ca_bc_pvrt",
|
||||
"scheduled_in",
|
||||
"rate_la1",
|
||||
"rate_la2",
|
||||
"rate_la3",
|
||||
"rate_la4",
|
||||
"rate_laa",
|
||||
"rate_lab",
|
||||
"rate_lad",
|
||||
"rate_lae",
|
||||
"rate_laf",
|
||||
"rate_lag",
|
||||
"rate_lam",
|
||||
"rate_lar",
|
||||
"rate_las",
|
||||
"rate_lau",
|
||||
"rate_ma2s",
|
||||
"rate_ma2t",
|
||||
"rate_ma3s",
|
||||
"rate_mabl",
|
||||
"rate_macs",
|
||||
"rate_mapa",
|
||||
"rate_mahw",
|
||||
"rate_mash",
|
||||
"rate_matd",
|
||||
],
|
||||
(meta) => meta && meta.touched
|
||||
);
|
||||
|
||||
Object.keys(changedAuditFields).forEach((key) => {
|
||||
insertAuditTrail({
|
||||
jobid: job.id,
|
||||
operation: AuditTrailMapping.jobfieldchange(
|
||||
key,
|
||||
changedAuditFields[key] instanceof moment
|
||||
? moment(changedAuditFields[key]).format("MM/DD/YYYY hh:mm a")
|
||||
: changedAuditFields[key]
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
await refetch();
|
||||
form.setFieldsValue(transormJobToForm(job));
|
||||
form.resetFields();
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const menuExtra = (
|
||||
|
||||
Reference in New Issue
Block a user