Add massaging of data to CCC import.

This commit is contained in:
Patrick Fic
2023-01-16 15:54:23 -08:00
parent 76025b5db1
commit 392b405978
5 changed files with 68 additions and 22 deletions

View File

@@ -11,3 +11,4 @@ REACT_APP_STRIPE_PUBLIC_KEY=pk_test_51GqB4TJl3nQjrZ0wCQWAxAhlNF8jKe0tipIa6ExBaxw
REACT_APP_AXIOS_BASE_API_URL=https://api.imex.online/ REACT_APP_AXIOS_BASE_API_URL=https://api.imex.online/
REACT_APP_REPORTS_SERVER_URL=https://reports3.test.imex.online REACT_APP_REPORTS_SERVER_URL=https://reports3.test.imex.online
REACT_APP_SPLIT_API=ts615lqgnmk84thn72uk18uu5pgce6e0l4rc REACT_APP_SPLIT_API=ts615lqgnmk84thn72uk18uu5pgce6e0l4rc
REACT_APP_COUNTRY=USA

View File

@@ -27,7 +27,7 @@ module.exports = {
lessOptions: { lessOptions: {
modifyVars: { modifyVars: {
...(process.env.NODE_ENV === "development" ...(process.env.NODE_ENV === "development"
? { "@primary-color": "#a51d1d" } ? { "@primary-color": "#B22234" }
: { : {
//"@primary-color": "#1DA57A" //"@primary-color": "#1DA57A"
}), }),

View File

@@ -39,6 +39,7 @@ import OwnerFindModalContainer from "../owner-find-modal/owner-find-modal.contai
import { GetSupplementDelta } from "./jobs-available-supplement.estlines.util"; import { GetSupplementDelta } from "./jobs-available-supplement.estlines.util";
import HeaderFields from "./jobs-available-supplement.headerfields"; import HeaderFields from "./jobs-available-supplement.headerfields";
import JobsAvailableTableComponent from "./jobs-available-table.component"; import JobsAvailableTableComponent from "./jobs-available-table.component";
import _ from "lodash";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop, bodyshop: selectBodyshop,
@@ -99,9 +100,13 @@ export function JobsAvailableContainer({
}); });
return; 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. //IO-539 Check for Parts Rate on PAL for SGI use case.
await CheckTaxRates(estData.est_data, bodyshop); await CheckTaxRates(estData.est_data, bodyshop);
// }
const newTotals = ( const newTotals = (
await Axios.post("/job/totals", { await Axios.post("/job/totals", {
job: { 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;
}
});
}

View File

@@ -2305,18 +2305,6 @@
shallowequal "^1.1.0" shallowequal "^1.1.0"
unfetch "^4.2.0" unfetch "^4.2.0"
"@stripe/react-stripe-js@^1.9.0":
version "1.9.0"
resolved "https://registry.yarnpkg.com/@stripe/react-stripe-js/-/react-stripe-js-1.9.0.tgz#74809a274d7db110c3daf6f68ca4d62c6e6559c7"
integrity sha512-Fn49X+Gu5fOTxhPOita1cPMi0jw+0v4xfJ3FCXbbvmfuuDl3M7ZvpRkoijBjql11NXsaXO3TMm3rkN3mEolJzw==
dependencies:
prop-types "^15.7.2"
"@stripe/stripe-js@^1.32.0":
version "1.32.0"
resolved "https://registry.yarnpkg.com/@stripe/stripe-js/-/stripe-js-1.32.0.tgz#4ecdd298db61ad9b240622eafed58da974bd210e"
integrity sha512-7EvBnbBfS1aynfLRmBFcuumHNGjKxnNkO47rorFBktqDYHwo7Yw6pfDW2iqq0R8r7i7XiJEdWPvvEgQAiDrx3A==
"@surma/rollup-plugin-off-main-thread@^1.1.1": "@surma/rollup-plugin-off-main-thread@^1.1.1":
version "1.4.2" version "1.4.2"
resolved "https://registry.yarnpkg.com/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-1.4.2.tgz#e6786b6af5799f82f7ab3a82e53f6182d2b91a58" resolved "https://registry.yarnpkg.com/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-1.4.2.tgz#e6786b6af5799f82f7ab3a82e53f6182d2b91a58"

View File

@@ -508,11 +508,18 @@ function IsAdditionalCost(jobLine) {
const isPaintOrShopMat = const isPaintOrShopMat =
jobLine.db_ref === "936008" || jobLine.db_ref === "936007"; jobLine.db_ref === "936008" || jobLine.db_ref === "936007";
return ( if (process.env.COUNTRY === "USA") {
(jobLine.lbr_op === "OP13" || //Added to resolve manual job lines coming into other totals because they have no reference. return (
(jobLine.db_ref && jobLine.db_ref.startsWith("9360"))) && jobLine.lbr_op === "OP13" || //Added to resolve manual job lines coming into other totals because they have no reference.
!isPaintOrShopMat (jobLine.part_type === null && (jobLine.act_price || 0 > 0))
); );
} else {
return (
(jobLine.lbr_op === "OP13" || //Added to resolve manual job lines coming into other totals because they have no reference.
(jobLine.db_ref && jobLine.db_ref.startsWith("9360"))) && //This ref works in Canada, but DB_REFS in the US do not fill in.
!isPaintOrShopMat
);
}
} }
function CalculateAdditional(job) { function CalculateAdditional(job) {
@@ -666,7 +673,18 @@ function CalculateTaxesTotals(job, otherTotals) {
.add( .add(
otherTotals.additional.storage.percentage((job.tax_str_rt || 0) * 100) otherTotals.additional.storage.percentage((job.tax_str_rt || 0) * 100)
) )
.add(additionalItemsTax), .add(additionalItemsTax)
.add(
process.env.COUNTRY === "USA"
? otherTotals.rates.mapa.total
.percentage((job.tax_paint_mat_rt || 0) * 100)
.add(
otherTotals.rates.mash.total.percentage(
(job.tax_paint_mat_rt || 0) * 100
)
)
: Dinero()
),
// .add(otherTotals.additional.pvrt), // .add(otherTotals.additional.pvrt),
local_tax: subtotal.percentage((job.local_tax_rate || 0) * 100), local_tax: subtotal.percentage((job.local_tax_rate || 0) * 100),
}; };