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

@@ -1,11 +1,11 @@
import {Table} from "antd"; import { Table } from 'antd';
import Dinero from "dinero.js"; import Dinero from 'dinero.js';
import React, {useMemo} from "react"; import React, { useMemo } from 'react';
import {useTranslation} from "react-i18next"; import { useTranslation } from 'react-i18next';
import {connect} from "react-redux"; import { connect } from 'react-redux';
import {createStructuredSelector} from "reselect"; import { createStructuredSelector } from 'reselect';
import {selectBodyshop} from "../../redux/user/user.selectors"; import { selectBodyshop } from '../../redux/user/user.selectors';
import InstanceRenderManager from '../../utils/instanceRenderMgr'; import InstanceRenderManager from '../../utils/instanceRenderMgr';
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
@@ -15,10 +15,7 @@ const mapStateToProps = createStructuredSelector({
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
//setUserLanguage: language => dispatch(setUserLanguage(language)) //setUserLanguage: language => dispatch(setUserLanguage(language))
}); });
export default connect( export default connect(mapStateToProps, mapDispatchToProps)(JobTotalsTableTotals);
mapStateToProps,
mapDispatchToProps
)(JobTotalsTableTotals);
export function JobTotalsTableTotals({ bodyshop, job }) { export function JobTotalsTableTotals({ bodyshop, job }) {
const { t } = useTranslation(); const { t } = useTranslation();
@@ -26,38 +23,38 @@ export function JobTotalsTableTotals({bodyshop, job}) {
const data = useMemo(() => { const data = useMemo(() => {
return [ return [
{ {
key: t("jobs.labels.subtotal"), key: t('jobs.labels.subtotal'),
total: job.job_totals.totals.subtotal, total: job.job_totals.totals.subtotal,
bold: true, bold: true,
}, },
...InstanceRenderManager({imex: [ { ...InstanceRenderManager({
key: t("jobs.labels.local_tax_amt"), imex: [
{
key: t('jobs.labels.local_tax_amt'),
total: job.job_totals.totals.local_tax, total: job.job_totals.totals.local_tax,
}, },
{ {
key: t("jobs.labels.state_tax_amt"), key: t('jobs.labels.state_tax_amt'),
total: job.job_totals.totals.state_tax, total: job.job_totals.totals.state_tax,
}, },
...(bodyshop.region_config === "CA_BC" ...(bodyshop.region_config === 'CA_BC'
? [ ? [
{ {
key: t("jobs.fields.ca_bc_pvrt"), key: t('jobs.fields.ca_bc_pvrt'),
total: job.job_totals.additional.pvrt, total: job.job_totals.additional.pvrt,
}, },
] ]
: []), : []),
{ {
key: t("jobs.labels.federal_tax_amt"), key: t('jobs.labels.federal_tax_amt'),
total: job.job_totals.totals.federal_tax, total: job.job_totals.totals.federal_tax,
},], },
promanager: "USE_ROME", ],
rome: [(job.job_totals.totals.us_sales_tax_breakdown promanager: 'USE_ROME',
rome: job.job_totals.totals.us_sales_tax_breakdown
? [ ? [
{ {
key: `${ key: `${bodyshop.md_responsibility_centers.taxes.tax_ty1?.tax_type1 || 'T1'} - ${[
bodyshop.md_responsibility_centers.taxes.tax_ty1?.tax_type1 ||
"T1"
} - ${[
job.cieca_pft.ty1_rate1, job.cieca_pft.ty1_rate1,
job.cieca_pft.ty1_rate2, job.cieca_pft.ty1_rate2,
job.cieca_pft.ty1_rate3, job.cieca_pft.ty1_rate3,
@@ -65,14 +62,11 @@ rome: [(job.job_totals.totals.us_sales_tax_breakdown
job.cieca_pft.ty1_rate5, job.cieca_pft.ty1_rate5,
] ]
.filter((i) => i > 0) .filter((i) => i > 0)
.join(", ")}%`, .join(', ')}%`,
total: job.job_totals.totals.us_sales_tax_breakdown.ty1Tax, total: job.job_totals.totals.us_sales_tax_breakdown.ty1Tax,
}, },
{ {
key: `${ key: `${bodyshop.md_responsibility_centers.taxes.tax_ty2?.tax_type2 || 'T2'} - ${[
bodyshop.md_responsibility_centers.taxes.tax_ty2?.tax_type2 ||
"T2"
} - ${[
job.cieca_pft.ty2_rate1, job.cieca_pft.ty2_rate1,
job.cieca_pft.ty2_rate2, job.cieca_pft.ty2_rate2,
job.cieca_pft.ty2_rate3, job.cieca_pft.ty2_rate3,
@@ -80,14 +74,11 @@ rome: [(job.job_totals.totals.us_sales_tax_breakdown
job.cieca_pft.ty2_rate5, job.cieca_pft.ty2_rate5,
] ]
.filter((i) => i > 0) .filter((i) => i > 0)
.join(", ")}%`, .join(', ')}%`,
total: job.job_totals.totals.us_sales_tax_breakdown.ty2Tax, total: job.job_totals.totals.us_sales_tax_breakdown.ty2Tax,
}, },
{ {
key: `${ key: `${bodyshop.md_responsibility_centers.taxes.tax_ty3?.tax_type3 || 'T3'} - ${[
bodyshop.md_responsibility_centers.taxes.tax_ty3?.tax_type3 ||
"T3"
} - ${[
job.cieca_pft.ty3_rate1, job.cieca_pft.ty3_rate1,
job.cieca_pft.ty3_rate2, job.cieca_pft.ty3_rate2,
job.cieca_pft.ty3_rate3, job.cieca_pft.ty3_rate3,
@@ -95,14 +86,11 @@ rome: [(job.job_totals.totals.us_sales_tax_breakdown
job.cieca_pft.ty3_rate5, job.cieca_pft.ty3_rate5,
] ]
.filter((i) => i > 0) .filter((i) => i > 0)
.join(", ")}%`, .join(', ')}%`,
total: job.job_totals.totals.us_sales_tax_breakdown.ty3Tax, total: job.job_totals.totals.us_sales_tax_breakdown.ty3Tax,
}, },
{ {
key: `${ key: `${bodyshop.md_responsibility_centers.taxes.tax_ty4?.tax_type4 || 'T4'} - ${[
bodyshop.md_responsibility_centers.taxes.tax_ty4?.tax_type4 ||
"T4"
} - ${[
job.cieca_pft.ty4_rate1, job.cieca_pft.ty4_rate1,
job.cieca_pft.ty4_rate2, job.cieca_pft.ty4_rate2,
job.cieca_pft.ty4_rate3, job.cieca_pft.ty4_rate3,
@@ -110,14 +98,11 @@ rome: [(job.job_totals.totals.us_sales_tax_breakdown
job.cieca_pft.ty4_rate5, job.cieca_pft.ty4_rate5,
] ]
.filter((i) => i > 0) .filter((i) => i > 0)
.join(", ")}%`, .join(', ')}%`,
total: job.job_totals.totals.us_sales_tax_breakdown.ty4Tax, total: job.job_totals.totals.us_sales_tax_breakdown.ty4Tax,
}, },
{ {
key: `${ key: `${bodyshop.md_responsibility_centers.taxes.tax_ty5?.tax_type5 || 'TT'} - ${[
bodyshop.md_responsibility_centers.taxes.tax_ty5?.tax_type5 ||
"TT"
} - ${[
job.cieca_pft.ty5_rate1, job.cieca_pft.ty5_rate1,
job.cieca_pft.ty5_rate2, job.cieca_pft.ty5_rate2,
job.cieca_pft.ty5_rate3, job.cieca_pft.ty5_rate3,
@@ -125,43 +110,35 @@ rome: [(job.job_totals.totals.us_sales_tax_breakdown
job.cieca_pft.ty5_rate5, job.cieca_pft.ty5_rate5,
] ]
.filter((i) => i > 0) .filter((i) => i > 0)
.join(", ")}%`, .join(', ')}%`,
total: job.job_totals.totals.us_sales_tax_breakdown.ty5Tax, total: job.job_totals.totals.us_sales_tax_breakdown.ty5Tax,
}, },
{ {
key: t("jobs.labels.total_sales_tax"), key: t('jobs.labels.total_sales_tax'),
bold: true, bold: true,
total: Dinero(job.job_totals.totals.us_sales_tax_breakdown.ty1Tax) total: Dinero(job.job_totals.totals.us_sales_tax_breakdown.ty1Tax)
.add( .add(Dinero(job.job_totals.totals.us_sales_tax_breakdown.ty2Tax))
Dinero(job.job_totals.totals.us_sales_tax_breakdown.ty2Tax) .add(Dinero(job.job_totals.totals.us_sales_tax_breakdown.ty3Tax))
) .add(Dinero(job.job_totals.totals.us_sales_tax_breakdown.ty4Tax))
.add( .add(Dinero(job.job_totals.totals.us_sales_tax_breakdown.ty5Tax))
Dinero(job.job_totals.totals.us_sales_tax_breakdown.ty3Tax) .toJSON(),
)
.add(
Dinero(job.job_totals.totals.us_sales_tax_breakdown.ty4Tax)
)
.add(
Dinero(job.job_totals.totals.us_sales_tax_breakdown.ty5Tax)
).toJSON(),
}, },
].filter((item) => item.total.amount !== 0) ].filter((item) => item.total.amount !== 0)
: [ : [
{ {
key: t("jobs.labels.state_tax_amt"), key: t('jobs.labels.state_tax_amt'),
total: job.job_totals.totals.state_tax, total: job.job_totals.totals.state_tax,
}, },
])] ],
}), }),
{ {
key: t("jobs.labels.total_repairs"), key: t('jobs.labels.total_repairs'),
total: job.job_totals.totals.total_repairs, total: job.job_totals.totals.total_repairs,
bold: true, bold: true,
}, },
{ {
key: t("jobs.fields.ded_amt"), key: t('jobs.fields.ded_amt'),
total: job.job_totals.totals.custPayable.deductible, total: job.job_totals.totals.custPayable.deductible,
}, },
// { // {
@@ -169,21 +146,21 @@ rome: [(job.job_totals.totals.us_sales_tax_breakdown
// total: job.job_totals.totals.custPayable.federal_tax, // total: job.job_totals.totals.custPayable.federal_tax,
// }, // },
{ {
key: t("jobs.fields.other_amount_payable"), key: t('jobs.fields.other_amount_payable'),
total: job.job_totals.totals.custPayable.other_customer_amount, total: job.job_totals.totals.custPayable.other_customer_amount,
}, },
{ {
key: t("jobs.fields.depreciation_taxes"), key: t('jobs.fields.depreciation_taxes'),
total: job.job_totals.totals.custPayable.dep_taxes, total: job.job_totals.totals.custPayable.dep_taxes,
}, },
{ {
key: t("jobs.labels.total_cust_payable"), key: t('jobs.labels.total_cust_payable'),
total: job.job_totals.totals.custPayable.total, total: job.job_totals.totals.custPayable.total,
bold: true, bold: true,
}, },
{ {
key: t("jobs.labels.net_repairs"), key: t('jobs.labels.net_repairs'),
total: job.job_totals.totals.net_repairs, total: job.job_totals.totals.net_repairs,
bold: true, bold: true,
}, },
@@ -193,22 +170,22 @@ rome: [(job.job_totals.totals.us_sales_tax_breakdown
const columns = [ const columns = [
{ {
//title: t("joblines.fields.part_type"), //title: t("joblines.fields.part_type"),
dataIndex: "key", dataIndex: 'key',
key: "key", key: 'key',
width: "80%", width: '80%',
onCell: (record, rowIndex) => { onCell: (record, rowIndex) => {
return {style: {fontWeight: record.bold && "bold"}}; return { style: { fontWeight: record.bold && 'bold' } };
}, },
}, },
{ {
title: t("joblines.fields.total"), title: t('joblines.fields.total'),
dataIndex: "total", dataIndex: 'total',
key: "total", key: 'total',
align: "right", align: 'right',
render: (text, record) => Dinero(record.total).toFormat(), render: (text, record) => Dinero(record.total).toFormat(),
width: "20%", width: '20%',
onCell: (record, rowIndex) => { onCell: (record, rowIndex) => {
return {style: {fontWeight: record.bold && "bold"}}; return { style: { fontWeight: record.bold && 'bold' } };
}, },
}, },
]; ];

View File

@@ -601,10 +601,11 @@ async function CheckTaxRates(estData, bodyshop) {
if (line.misc_amt && line.misc_amt !== 0) { if (line.misc_amt && line.misc_amt !== 0) {
line.act_price = line.act_price + line.misc_amt; 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 //WEB EST SPECIFIC CLEAN UP
InstanceRenderManager({executeFunction: true, args:[], promanager: () => { InstanceRenderManager({executeFunction: true, args:[], promanager: () => {
if (line.mod_lbr_ty === "LAET" || line.mod_lbr_ty === "LAUT") { if (line.mod_lbr_ty === "LAET" || line.mod_lbr_ty === "LAUT") {
line.notes += ` | ET/UT Update (prev = ${line.mod_lbr_ty})`; line.notes += ` | ET/UT Update (prev = ${line.mod_lbr_ty})`;
line.mod_lbr_ty = "LAR"; line.mod_lbr_ty = "LAR";
@@ -615,35 +616,42 @@ async function CheckTaxRates(estData, bodyshop) {
//Group by line no //Group by line no
// For everything but the first one, strip out the price number in // For everything but the first one, strip out the price number in
InstanceRenderManager({executeFunction:true, args:[], promanager: () => { // InstanceRenderManager({executeFunction:true, args:[], promanager: () => {
// const groupedByLineRef = _.groupBy(estData.joblines.data, "line_ref");
// Object.keys(groupedByLineRef).forEach((lineRef) => {
// let index0ActPrice;
const groupedByLineRef = _.groupBy(estData.joblines.data, "line_ref"); // groupedByLineRef[lineRef].forEach((line, index) => {
Object.keys(groupedByLineRef).forEach((lineRef) => { // //Let the first one keep it
groupedByLineRef[lineRef].forEach((line, index) => { // if (index === 0){
//Let the first one keep it // index0ActPrice = line.act_price;
if (index === 0) return; // return;}
//Web Est seems to have additional costs with UNQ_SEQ 0. Keep them all? // //Web Est seems to have additional costs with UNQ_SEQ 0. Keep them all?
if (line.unq_seq === 0) return; // if (line.unq_seq === 0) return;
const indexInEstData = estData.joblines.data.findIndex( // if(index0ActPrice !== line.act_price){
(l) => l.unq_seq === line.unq_seq // line.notes += ` | Price override.`;
); // return;
estData.joblines.data[ // }
indexInEstData // const indexInEstData = estData.joblines.data.findIndex(
].notes += ` | Scrubbed due to the line_ref issue. (prev act price = ${estData.joblines.data[indexInEstData].act_price})`; // (l) => l.unq_seq === line.unq_seq
estData.joblines.data[indexInEstData].act_price = 0; // );
estData.joblines.data[indexInEstData].db_price = 0; // 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. //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 unqSeqHash = _.groupBy(estData.joblines.data, 'unq_seq');
const duplicatedUnqSeq = Object.keys(unqSeqHash).filter( const duplicatedUnqSeq = Object.keys(unqSeqHash).filter((key) => unqSeqHash[key].length > 1);
(key) => unqSeqHash[key].length > 1
);
duplicatedUnqSeq.forEach((unq_seq) => { duplicatedUnqSeq.forEach((unq_seq) => {
//Keys are strings, convert to int. //Keys are strings, convert to int.
@@ -663,4 +671,10 @@ async function CheckTaxRates(estData, bodyshop) {
prt_dsmk_m: 0, prt_dsmk_m: 0,
}; };
}); });
},
});
} }

View File

@@ -3,6 +3,7 @@ const queries = require("../graphql-client/queries");
const adminClient = require("../graphql-client/graphql-client").client; const adminClient = require("../graphql-client/graphql-client").client;
const _ = require("lodash"); const _ = require("lodash");
const logger = require("../utils/logger"); const logger = require("../utils/logger");
const InstanceMgr = require("../utils/instanceMgr").default;
//****************************************************** */ //****************************************************** */
//****************************************************** */ //****************************************************** */
@@ -992,7 +993,7 @@ function CalculateTaxesTotals(job, otherTotals) {
); );
let taxableAmountInThisThreshold; let taxableAmountInThisThreshold;
if (thresholdAmount === 9999.99) { if (thresholdAmount === 9999.99 || InstanceMgr({debug:true,imex:false, rome: false, promanager:thresholdAmount === 0 && parseInt(tyCounter) === 1 }) ) { //
// THis is the last threshold. Tax the entire remaining amount. // THis is the last threshold. Tax the entire remaining amount.
taxableAmountInThisThreshold = remainingTaxableAmounts[taxTierKey]; taxableAmountInThisThreshold = remainingTaxableAmounts[taxTierKey];
remainingTaxableAmounts[taxTierKey] = Dinero(); remainingTaxableAmounts[taxTierKey] = Dinero();