Add massaging of data to CCC import.
This commit is contained in:
@@ -39,6 +39,7 @@ import OwnerFindModalContainer from "../owner-find-modal/owner-find-modal.contai
|
||||
import { GetSupplementDelta } from "./jobs-available-supplement.estlines.util";
|
||||
import HeaderFields from "./jobs-available-supplement.headerfields";
|
||||
import JobsAvailableTableComponent from "./jobs-available-table.component";
|
||||
import _ from "lodash";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -99,9 +100,13 @@ export function JobsAvailableContainer({
|
||||
});
|
||||
return;
|
||||
}
|
||||
// if (process.env.REACT_APP_COUNTRY === "USA") {
|
||||
//Massage the CCC file set to remove duplicate UNQ_SEQ.
|
||||
await ResolveCCCLineIssues(estData.est_data, bodyshop);
|
||||
// } else {
|
||||
//IO-539 Check for Parts Rate on PAL for SGI use case.
|
||||
await CheckTaxRates(estData.est_data, bodyshop);
|
||||
|
||||
// }
|
||||
const newTotals = (
|
||||
await Axios.post("/job/totals", {
|
||||
job: {
|
||||
@@ -509,3 +514,37 @@ async function CheckTaxRates(estData, bodyshop) {
|
||||
});
|
||||
//}
|
||||
}
|
||||
|
||||
async function ResolveCCCLineIssues(estData, bodyshop) {
|
||||
//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
|
||||
);
|
||||
|
||||
duplicatedUnqSeq.forEach((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],
|
||||
act_price: null,
|
||||
db_price: null,
|
||||
};
|
||||
});
|
||||
|
||||
//Find all misc amounts, populate them to the act price.
|
||||
//TODO Ensure that this doesnt get violated
|
||||
estData.joblines.data.forEach((line) => {
|
||||
if (line.misc_amt && line.misc_amt > 0) {
|
||||
line.act_price = line.misc_amt;
|
||||
line.part_type = "PAS";
|
||||
line.tax_part = line.misc_tax;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user