Web-est bug fixes.

This commit is contained in:
Patrick Fic
2024-03-26 15:28:12 -07:00
parent 248aa65195
commit 2ace0189bc
3 changed files with 249 additions and 257 deletions

View File

@@ -600,11 +600,12 @@ async function CheckTaxRates(estData, bodyshop) {
estData.joblines.data.forEach((line) => {
if (line.misc_amt && line.misc_amt !== 0) {
line.act_price = line.act_price + line.misc_amt;
line.tax_part = !!line.misc_tax;
line.tax_part = !!line.misc_tax;
line.notes += ` | Misc amount override.`;
}
//WEB EST SPECIFIC CLEAN UP
InstanceRenderManager({executeFunction: true, args:[], promanager: () => {
if (line.mod_lbr_ty === "LAET" || line.mod_lbr_ty === "LAUT") {
line.notes += ` | ET/UT Update (prev = ${line.mod_lbr_ty})`;
line.mod_lbr_ty = "LAR";
@@ -615,52 +616,65 @@ async function CheckTaxRates(estData, bodyshop) {
//Group by line no
// For everything but the first one, strip out the price number in
InstanceRenderManager({executeFunction:true, args:[], promanager: () => {
const groupedByLineRef = _.groupBy(estData.joblines.data, "line_ref");
Object.keys(groupedByLineRef).forEach((lineRef) => {
groupedByLineRef[lineRef].forEach((line, index) => {
//Let the first one keep it
if (index === 0) return;
//Web Est seems to have additional costs with UNQ_SEQ 0. Keep them all?
if (line.unq_seq === 0) return;
const indexInEstData = estData.joblines.data.findIndex(
(l) => l.unq_seq === line.unq_seq
);
estData.joblines.data[
indexInEstData
].notes += ` | Scrubbed due to the line_ref issue. (prev act price = ${estData.joblines.data[indexInEstData].act_price})`;
estData.joblines.data[indexInEstData].act_price = 0;
estData.joblines.data[indexInEstData].db_price = 0;
});
})
}})
// InstanceRenderManager({executeFunction:true, args:[], promanager: () => {
// const groupedByLineRef = _.groupBy(estData.joblines.data, "line_ref");
// Object.keys(groupedByLineRef).forEach((lineRef) => {
// let index0ActPrice;
// groupedByLineRef[lineRef].forEach((line, index) => {
// //Let the first one keep it
// if (index === 0){
// index0ActPrice = line.act_price;
// return;}
// //Web Est seems to have additional costs with UNQ_SEQ 0. Keep them all?
// if (line.unq_seq === 0) return;
// if(index0ActPrice !== line.act_price){
// line.notes += ` | Price override.`;
// return;
// }
// const indexInEstData = estData.joblines.data.findIndex(
// (l) => l.unq_seq === line.unq_seq
// );
// estData.joblines.data[
// indexInEstData
// ].notes += ` | Scrubbed due to the line_ref issue. (prev act price = ${estData.joblines.data[indexInEstData].act_price})`;
// estData.joblines.data[indexInEstData].act_price = 0;
// estData.joblines.data[indexInEstData].db_price = 0;
// });
// })
// }})
InstanceRenderManager({
executeFunction: true,
args: [],
promanager: null, //Require to prevent auto firing of Rome.
rome: () => {
//Generate the list of duplicated UNQ_SEQ that will feed into the next section to scrub the lines.
const unqSeqHash = _.groupBy(estData.joblines.data, "unq_seq");
const duplicatedUnqSeq = Object.keys(unqSeqHash).filter(
(key) => unqSeqHash[key].length > 1
);
const unqSeqHash = _.groupBy(estData.joblines.data, 'unq_seq');
const duplicatedUnqSeq = Object.keys(unqSeqHash).filter((key) => unqSeqHash[key].length > 1);
duplicatedUnqSeq.forEach((unq_seq) => {
//Keys are strings, convert to int.
const int_unq_seq = parseInt(unq_seq);
//Keys are strings, convert to int.
const int_unq_seq = parseInt(unq_seq);
//When line splitting, the first line is always the non-refinish line. We will keep it as is.
//We will cleanse the second line, which is always the next line.
const nonRefLineIndex = estData.joblines.data.findIndex(
(line) => line.unq_seq === int_unq_seq
);
estData.joblines.data[nonRefLineIndex + 1] = {
...estData.joblines.data[nonRefLineIndex + 1],
part_type: null,
act_price: 0,
db_price: 0,
prt_dsmk_p: 0,
prt_dsmk_m: 0,
};
//When line splitting, the first line is always the non-refinish line. We will keep it as is.
//We will cleanse the second line, which is always the next line.
const nonRefLineIndex = estData.joblines.data.findIndex(
(line) => line.unq_seq === int_unq_seq
);
estData.joblines.data[nonRefLineIndex + 1] = {
...estData.joblines.data[nonRefLineIndex + 1],
part_type: null,
act_price: 0,
db_price: 0,
prt_dsmk_p: 0,
prt_dsmk_m: 0,
};
});
},
});
}