From 5cf2345dca158feffb50ea608b398d55fee911e2 Mon Sep 17 00:00:00 2001 From: Allan Carr Date: Wed, 31 Jul 2024 14:15:31 -0700 Subject: [PATCH] IO-2854 Profile Adjustments for LA and MA Signed-off-by: Allan Carr --- .../job-totals.table.labor.component.jsx | 121 ++++++- .../jobs-detail-rates.labor.component.jsx | 191 ++++++++++- .../jobs-detail-rates.materials.component.jsx | 44 ++- .../jobs-detail-rates.parts.component.jsx | 25 +- ....responsibilitycenters.taxes.component.jsx | 300 +++++++++++++++++- client/src/translations/en_us/common.json | 6 + client/src/translations/es/common.json | 6 + client/src/translations/fr/common.json | 6 + server/graphql-client/queries.js | 1 + server/job/job-costing.js | 67 +++- server/job/job-totals-USA.js | 116 +++++-- 11 files changed, 809 insertions(+), 74 deletions(-) diff --git a/client/src/components/job-totals-table/job-totals.table.labor.component.jsx b/client/src/components/job-totals-table/job-totals.table.labor.component.jsx index dedce3809..683b34deb 100644 --- a/client/src/components/job-totals-table/job-totals.table.labor.component.jsx +++ b/client/src/components/job-totals-table/job-totals.table.labor.component.jsx @@ -3,8 +3,8 @@ import Dinero from "dinero.js"; import React, { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import CurrencyFormatter from "../../utils/CurrencyFormatter"; -import { alphaSort } from "../../utils/sorters"; import InstanceRenderManager from "../../utils/instanceRenderMgr"; +import { alphaSort } from "../../utils/sorters"; export default function JobTotalsTableLabor({ job }) { const { t } = useTranslation(); @@ -56,16 +56,47 @@ export default function JobTotalsTableLabor({ job }) { sortOrder: state.sortedInfo.columnKey === "mod_lb_hrs" && state.sortedInfo.order, render: (text, record) => record.hours.toFixed(1) }, - { - title: t("joblines.fields.total"), - dataIndex: "total", - key: "total", - align: "right", - sorter: (a, b) => a.total.amount - b.total.amount, - sortOrder: state.sortedInfo.columnKey === "total" && state.sortedInfo.order, - - render: (text, record) => Dinero(record.total).toFormat() - } + ...InstanceRenderManager({ + imex: { + title: t("joblines.fields.total"), + dataIndex: "total", + key: "total", + align: "right", + sorter: (a, b) => a.total.amount - b.total.amount, + sortOrder: state.sortedInfo.columnKey === "total" && state.sortedInfo.order, + render: (text, record) => Dinero(record.total).toFormat() + }, + rome: [ + { + title: t("joblines.fields.amount"), + dataIndex: "base", + key: "base", + align: "right", + sorter: (a, b) => a.base.amount - b.base.amount, + sortOrder: state.sortedInfo.columnKey === "base" && state.sortedInfo.order, + render: (text, record) => Dinero(record.base).toFormat() + }, + { + title: t("joblines.fields.adjustment"), + dataIndex: "adjustment", + key: "adjustment", + align: "right", + sorter: (a, b) => a.adjustment.amount - b.adjustment.amount, + sortOrder: state.sortedInfo.columnKey === "adjustment" && state.sortedInfo.order, + render: (text, record) => Dinero(record.adjustment).toFormat() + }, + { + title: t("joblines.fields.total"), + dataIndex: "total", + key: "total", + align: "right", + sorter: (a, b) => a.total.amount - b.total.amount, + sortOrder: state.sortedInfo.columnKey === "total" && state.sortedInfo.order, + render: (text, record) => Dinero(record.total).toFormat() + } + ], + promanager: "USE_ROME" + }) ]; const handleTableChange = (pagination, filters, sorter) => { @@ -91,6 +122,16 @@ export default function JobTotalsTableLabor({ job }) { {(job.job_totals.rates.mapa.hours + job.job_totals.rates.mash.hours).toFixed(1)} + {InstanceRenderManager({ + imex: null, + rome: ( + <> + + + + ), + promanager: "USE_ROME" + })} {Dinero(job.job_totals.rates.rates_subtotal).toFormat()} @@ -122,7 +163,29 @@ export default function JobTotalsTableLabor({ job }) { {job.job_totals.rates.mapa.rate} {job.job_totals.rates.mapa.hours.toFixed(1)} - {Dinero(job.job_totals.rates.mapa.total).toFormat()} + {InstanceRenderManager({ + imex: ( + <> + + {Dinero(job.job_totals.rates.mapa.total).toFormat()} + + + ), + rome: ( + <> + + {Dinero(job.job_totals.rates.mapa.base).toFormat()} + + + {Dinero(job.job_totals.rates.mapa.adjustment).toFormat()} + + + {Dinero(job.job_totals.rates.mapa.total).toFormat()} + + + ), + promanager: "USE_ROME" + })} @@ -151,7 +214,29 @@ export default function JobTotalsTableLabor({ job }) { {job.job_totals.rates.mash.rate} {job.job_totals.rates.mash.hours.toFixed(1)} - {Dinero(job.job_totals.rates.mash.total).toFormat()} + {InstanceRenderManager({ + imex: ( + <> + + {Dinero(job.job_totals.rates.mash.total).toFormat()} + + + ), + rome: ( + <> + + {Dinero(job.job_totals.rates.mash.base).toFormat()} + + + {Dinero(job.job_totals.rates.mash.adjustment).toFormat()} + + + {Dinero(job.job_totals.rates.mash.total).toFormat()} + + + ), + promanager: "USE_ROME" + })} @@ -159,6 +244,16 @@ export default function JobTotalsTableLabor({ job }) { + {InstanceRenderManager({ + imex: null, + rome: ( + <> + + + + ), + promanager: "USE_ROME" + })} {Dinero(job.job_totals.rates.subtotal).toFormat()} diff --git a/client/src/components/jobs-detail-rates/jobs-detail-rates.labor.component.jsx b/client/src/components/jobs-detail-rates/jobs-detail-rates.labor.component.jsx index afbe883ef..b7a2dc861 100644 --- a/client/src/components/jobs-detail-rates/jobs-detail-rates.labor.component.jsx +++ b/client/src/components/jobs-detail-rates/jobs-detail-rates.labor.component.jsx @@ -1,4 +1,4 @@ -import { Collapse, Form, Switch } from "antd"; +import { Collapse, Form, InputNumber, Switch } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -17,6 +17,9 @@ export function JobsDetailRatesLabor({ jobRO, expanded, required = true, form }) + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + - + + + + + {() => { + return ( + + + + ); + }} + - + + + + + {() => { + return ( + + + + ); + }} + - - - - - - + {InstanceRenderManager({ imex: true, rome: false, promanager: "USE_ROME" }) ? ( + <> + + + + + + {" "} + + ) : null} - - - + {InstanceRenderManager({ imex: true, rome: false, promanager: "USE_ROME" }) ? ( + + + + ) : null} diff --git a/client/src/components/shop-info/shop-info.responsibilitycenters.taxes.component.jsx b/client/src/components/shop-info/shop-info.responsibilitycenters.taxes.component.jsx index e52a70b46..b587deb5a 100644 --- a/client/src/components/shop-info/shop-info.responsibilitycenters.taxes.component.jsx +++ b/client/src/components/shop-info/shop-info.responsibilitycenters.taxes.component.jsx @@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { selectBodyshop } from "../../redux/user/user.selectors"; +import InstanceRenderManager from "../../utils/instanceRenderMgr"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; const mapStateToProps = createStructuredSelector({ @@ -51,6 +52,12 @@ export function ShopInfoResponsibilityCenters({ bodyshop, form }) { + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + + + + + + {() => { + return ( + + + + ); + }} + - + + + + + {() => { + return ( + + + + ); + }} + - + + + + + {() => { + return ( + + + + ); + }} + - - - - - - + {InstanceRenderManager({ imex: true, rome: false, promanager: "USE_ROME" }) ? ( + <> + + + + + + + + ) : null} - - - + {InstanceRenderManager({ imex: true, rome: false, promanager: "USE_ROME" }) ? ( + + + + ) : null} diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 0478acca4..eded9654e 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -1392,7 +1392,9 @@ "fields": { "act_price": "Retail Price", "act_price_before_ppc": "Original Part Price", + "adjustment": "Adjustment", "ah_detail_line": "Mark as Detail Labor Line (Autohouse Only)", + "amount":"Amount", "assigned_team": "Team", "assigned_team_name": "Team {{name}}", "create_ppc": "Create PPC?", @@ -1601,7 +1603,9 @@ "ccm": "CC Mileage", "cieca_id": "CIECA ID", "cieca_pfl": { + "lbr_adjp": "Labor Adjustment", "lbr_tax_in": "Tax Labor Indicator", + "lbr_taxp": "Labor Tax Rate", "lbr_tx_in1": "Tax 1 Indicator", "lbr_tx_in2": "Tax 2 Indicator", "lbr_tx_in3": "Tax 3 Indicator", @@ -1741,6 +1745,8 @@ "MASH": "Shop Materials", "cal_maxdlr": "Threshhold", "cal_opcode": "OP Codes", + "mat_adjp": "Material Adjustment", + "mat_taxp": "Material Tax Rate", "mat_tx_in1": "Tax 1 Indicator", "mat_tx_in2": "Tax 2 Indicator", "mat_tx_in3": "Tax 3 Indicator", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 77da83843..5351650e7 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -1392,7 +1392,9 @@ "fields": { "act_price": "Precio actual", "act_price_before_ppc": "", + "adjustment": "", "ah_detail_line": "", + "amount":"", "assigned_team": "", "assigned_team_name": "", "create_ppc": "", @@ -1601,7 +1603,9 @@ "ccm": "", "cieca_id": "CIECA ID", "cieca_pfl": { + "lbr_adjp": "", "lbr_tax_in": "", + "lbr_taxp": "", "lbr_tx_in1": "", "lbr_tx_in2": "", "lbr_tx_in3": "", @@ -1741,6 +1745,8 @@ "MASH": "", "cal_maxdlr": "", "cal_opcode": "", + "mat_adjp": "", + "mat_taxp": "", "mat_tx_in1": "", "mat_tx_in2": "", "mat_tx_in3": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 8f26de61a..abb95c042 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -1392,7 +1392,9 @@ "fields": { "act_price": "Prix actuel", "act_price_before_ppc": "", + "adjustment": "", "ah_detail_line": "", + "amount":"", "assigned_team": "", "assigned_team_name": "", "create_ppc": "", @@ -1601,7 +1603,9 @@ "ccm": "", "cieca_id": "CIECA ID", "cieca_pfl": { + "lbr_adjp": "", "lbr_tax_in": "", + "lbr_taxp": "", "lbr_tx_in1": "", "lbr_tx_in2": "", "lbr_tx_in3": "", @@ -1741,6 +1745,8 @@ "MASH": "", "cal_maxdlr": "", "cal_opcode": "", + "mat_adjp": "", + "mat_taxp": "", "mat_tx_in1": "", "mat_tx_in2": "", "mat_tx_in3": "", diff --git a/server/graphql-client/queries.js b/server/graphql-client/queries.js index 9a2e139b4..814f8d490 100644 --- a/server/graphql-client/queries.js +++ b/server/graphql-client/queries.js @@ -1527,6 +1527,7 @@ exports.QUERY_JOB_COSTING_DETAILS = ` query QUERY_JOB_COSTING_DETAILS($id: uuid! ca_bc_pvrt ca_customer_gst dms_allocation + cieca_pfl joblines(where: { removed: { _eq: false } }) { id db_ref diff --git a/server/job/job-costing.js b/server/job/job-costing.js index f8cbd2515..ecdc9dde3 100644 --- a/server/job/job-costing.js +++ b/server/job/job-costing.js @@ -286,9 +286,45 @@ function GenerateCostingData(job) { const rateName = `rate_${(val.mod_lbr_ty || "").toLowerCase()}`; - const laborAmount = Dinero({ + let laborAmount = Dinero(); + laborAmount = Dinero({ amount: Math.round((job[rateName] || 0) * 100) }).multiply(val.mod_lb_hrs || 0); + + if ( + job.cieca_pfl && + job.cieca_pfl[val.mod_lbr_ty.toUpperCase()] && + job.cieca_pfl[val.mod_lbr_ty.toUpperCase()].lbr_adjp !== 0 + ) { + let adjp = 0; + if ( + val.mod_lbr_ty === "la1" || + val.mod_lbr_ty === "la2" || + val.mod_lbr_ty === "la3" || + val.mod_lbr_ty === "la4" + ) { + adjp = + Math.abs(job.cieca_pfl["LAU"].lbr_adjp) > 1 + ? job.cieca_pfl["LAU"].lbr_adjp + : job.cieca_pfl["LAU"].lbr_adjp * 100; //Adjust lbr_adjp to whole number + } else { + if (job.cieca_pfl[val.mod_lbr_ty.toUpperCase()]) { + adjp = + Math.abs(job.cieca_pfl[val.mod_lbr_ty.toUpperCase()].lbr_adjp) > 1 + ? job.cieca_pfl[val.mod_lbr_ty.toUpperCase()].lbr_adjp + : job.cieca_pfl[val.mod_lbr_ty.toUpperCase()].lbr_adjp * 100; //Adjust lbr_adjp to whole number + } else { + adjp = + Math.abs(job.cieca_pfl["LAB"].lbr_adjp) > 1 + ? job.cieca_pfl["LAB"].lbr_adjp + : job.cieca_pfl["LAB"].lbr_adjp * 100; //Adjust lbr_adjp to whole number + } + } + laborAmount = laborAmount.add( + laborAmount.percentage(adjp < 0 ? adjp * -1 : adjp).multiply(adjp < 0 ? -1 : 1) + ); + } + if (!acc.labor[laborProfitCenter]) acc.labor[laborProfitCenter] = Dinero(); acc.labor[laborProfitCenter] = acc.labor[laborProfitCenter].add(laborAmount); @@ -317,7 +353,7 @@ function GenerateCostingData(job) { if (!partsProfitCenter) console.log("Unknown cost/profit center mapping for parts.", val.line_desc, val.part_type); - const partsAmount = Dinero({ + let partsAmount = Dinero({ amount: val.act_price_before_ppc ? Math.round(val.act_price_before_ppc * 100) : Math.round(val.act_price * 100) @@ -338,6 +374,33 @@ function GenerateCostingData(job) { .multiply(val.prt_dsmk_p > 0 ? 1 : -1) : Dinero() ); + + // Profile Discount for Parts + if (job.parts_tax_rates && job.parts_tax_rates[val.part_type.toUpperCase()]) { + if ( + job.parts_tax_rates[val.part_type.toUpperCase()].prt_discp !== undefined && + job.parts_tax_rates[val.part_type.toUpperCase()].prt_discp >= 0 + ) { + const discountRate = + Math.abs(job.parts_tax_rates[val.part_type.toUpperCase()].prt_discp) > 1 + ? parts_tajob.parts_tax_rates_rates[val.part_type.toUpperCase()].prt_discp + : job.parts_tax_rates[val.part_type.toUpperCase()].prt_discp * 100; + const disc = partsAmount.percentage(discountRate).multiply(-1); + partsAmount = partsAmount.add(disc); + } + if ( + job.parts_tax_rates[val.part_type.toUpperCase()].prt_mkupp !== undefined && + job.parts_tax_rates[val.part_type.toUpperCase()].prt_mkupp >= 0 + ) { + const markupRate = + Math.abs(job.parts_tax_rates[val.part_type.toUpperCase()].prt_mkupp) > 1 + ? job.parts_tax_rates[val.part_type.toUpperCase()].prt_mkupp + : job.parts_tax_rates[val.part_type.toUpperCase()].prt_mkupp * 100; + const markup = partsAmount.percentage(markupRate); + partsAmount = partsAmount.add(markup); + } + } + if (!acc.parts[partsProfitCenter]) acc.parts[partsProfitCenter] = Dinero(); acc.parts[partsProfitCenter] = acc.parts[partsProfitCenter].add(partsAmount); } diff --git a/server/job/job-totals-USA.js b/server/job/job-totals-USA.js index 747c9e51a..ba84a2488 100644 --- a/server/job/job-totals-USA.js +++ b/server/job/job-totals-USA.js @@ -331,6 +331,8 @@ async function CalculateRatesTotals({ job, client }) { //Skip calculating mapa and mash if we got the amounts. if (!((property === "mapa" && hasMapaLine) || (property === "mash" && hasMashLine))) { if (!ret[property].total) { + ret[property].base = Dinero(); + ret[property].adjustment = Dinero(); ret[property].total = Dinero(); } let threshold; @@ -349,13 +351,44 @@ async function CalculateRatesTotals({ job, client }) { } } - const total = Dinero({ + const base = Dinero({ amount: Math.round((ret[property].rate || 0) * 100) }).multiply(ret[property].hours); + let adjp = 0; + if (property === "mapa" || property === "mash") { + adjp = + Math.abs(job.materials[property.toUpperCase()].mat_adjp) > 1 + ? job.materials[property.toUpperCase()].mat_adjp + : job.materials[property.toUpperCase()].mat_adjp * 100; //Adjust mat_adjp to whole number + } else { + if (property === "la1" || property === "la2" || property === "la3" || property === "la4") { + adjp = + Math.abs(job.cieca_pfl["LAU"].lbr_adjp) > 1 + ? job.cieca_pfl["LAU"].lbr_adjp + : job.cieca_pfl["LAU"].lbr_adjp * 100; //Adjust lbr_adjp to whole number + } else { + if (job.cieca_pfl[property.toUpperCase()]) { + adjp = + Math.abs(job.cieca_pfl[property.toUpperCase()].lbr_adjp) > 1 + ? job.cieca_pfl[property.toUpperCase()].lbr_adjp + : job.cieca_pfl[property.toUpperCase()].lbr_adjp * 100; //Adjust lbr_adjp to whole number + } else { + adjp = + Math.abs(job.cieca_pfl["LAB"].lbr_adjp) > 1 + ? job.cieca_pfl["LAB"].lbr_adjp + : job.cieca_pfl["LAB"].lbr_adjp * 100; //Adjust lbr_adjp to whole number + } + } + } + const adjustment = base.percentage(adjp < 0 ? adjp * -1 : adjp).multiply(adjp < 0 ? -1 : 1); + const total = base.add(adjustment); + if (threshold && total.greaterThanOrEqual(threshold)) { ret[property].total = ret[property].total.add(threshold); } else { + ret[property].base = ret[property].base.add(base); + ret[property].adjustment = ret[property].adjustment.add(adjustment); ret[property].total = ret[property].total.add(total); } } @@ -703,18 +736,19 @@ function CalculateTaxesTotals(job, otherTotals) { //Potential issue here with Sublet Calculation. Sublets are calculated under labor in Mitchell, but it's done in IO //Under the parts rates. - let statePartsTax = Dinero(); - let additionalItemsTax = Dinero(); + let stateTax = Dinero(); + // let additionalItemsTax = Dinero(); //This is not used. let us_sales_tax_breakdown; + // This is not referenced in the code base. //Audatex sends additional glass part types. IO-774 - const BackupGlassTax = - job.parts_tax_rates && - (job.parts_tax_rates.PAGD || - job.parts_tax_rates.PAGF || - job.parts_tax_rates.PAGP || - job.parts_tax_rates.PAGQ || - job.parts_tax_rates.PAGR); + // const BackupGlassTax = + // job.parts_tax_rates && + // (job.parts_tax_rates.PAGD || + // job.parts_tax_rates.PAGF || + // job.parts_tax_rates.PAGP || + // job.parts_tax_rates.PAGQ || + // job.parts_tax_rates.PAGR); const taxableAmounts = { PAA: Dinero(), @@ -878,11 +912,27 @@ function CalculateTaxesTotals(job, otherTotals) { } else if (key.startsWith("LA")) { //Labor. for (let tyCounter = 1; tyCounter <= 5; tyCounter++) { - if (IsTrueOrYes(pfl[key][`lbr_tx_in${tyCounter}`])) { - //This amount is taxable for this type. - taxableAmountsByTier[`ty${tyCounter}Tax`] = taxableAmountsByTier[`ty${tyCounter}Tax`].add( - taxableAmounts[key] - ); + if (key === "LA1" || key === "LA2" || key === "LA3" || key === "LA4") { + if (IsTrueOrYes(pfl["LAU"][`lbr_tx_in${tyCounter}`])) { + //This amount is taxable for this type. + taxableAmountsByTier[`ty${tyCounter}Tax`] = taxableAmountsByTier[`ty${tyCounter}Tax`].add( + taxableAmounts[key] + ); + } + } else if (key === "LAA" && !pfl[key]) { + if (IsTrueOrYes(pfl["LAB"][`lbr_tx_in${tyCounter}`])) { + //This amount is taxable for this type. + taxableAmountsByTier[`ty${tyCounter}Tax`] = taxableAmountsByTier[`ty${tyCounter}Tax`].add( + taxableAmounts[key] + ); + } + } else { + if (IsTrueOrYes(pfl[key][`lbr_tx_in${tyCounter}`])) { + //This amount is taxable for this type. + taxableAmountsByTier[`ty${tyCounter}Tax`] = taxableAmountsByTier[`ty${tyCounter}Tax`].add( + taxableAmounts[key] + ); + } } } } else if (key === "TOW") { @@ -919,7 +969,6 @@ function CalculateTaxesTotals(job, otherTotals) { Object.keys(taxableAmountsByTier).forEach((taxTierKey) => { taxable_adjustment = taxableAmountsByTier[taxTierKey].multiply(percent_of_adjustment); - console.log("🚀 ~ taxableAmountsByTier ~ taxable_adjustment:", taxable_adjustment); if (job.adjustment_bottom_line > 0) { taxableAmountsByTier[taxTierKey] = taxableAmountsByTier[taxTierKey].add(taxable_adjustment); } else { @@ -937,8 +986,8 @@ function CalculateTaxesTotals(job, otherTotals) { let tyCounter = taxTierKey[2]; //Get the number from the key. //i represents the tax number. If we got here, this type of tax is applicable. Now we need to add based on the thresholds. for (let threshCounter = 1; threshCounter <= 5; threshCounter++) { - const thresholdAmount = parseFloat(job.cieca_pft[`ty${tyCounter}_thres${threshCounter}`]); - const thresholdTaxRate = parseFloat(job.cieca_pft[`ty${tyCounter}_rate${threshCounter}`]); + const thresholdAmount = parseFloat(job.cieca_pft[`ty${tyCounter}_thres${threshCounter}`]) || 0; + const thresholdTaxRate = parseFloat(job.cieca_pft[`ty${tyCounter}_rate${threshCounter}`]) || 0; let taxableAmountInThisThreshold; if ( @@ -946,7 +995,7 @@ function CalculateTaxesTotals(job, otherTotals) { InstanceMgr({ imex: false, rome: thresholdAmount === 0 && parseInt(tyCounter) === 1, - promanager: thresholdAmount === 0 && parseInt(tyCounter) === 1 + promanager: "USE_ROME" }) ) { // @@ -980,10 +1029,10 @@ function CalculateTaxesTotals(job, otherTotals) { } }); - // console.log("*** Total Tax by Tier Amounts***"); - // console.table(JSON.parse(JSON.stringify(totalTaxByTier))); + console.log("*** Total Tax by Tier Amounts***"); + console.table(JSON.parse(JSON.stringify(totalTaxByTier))); - statePartsTax = statePartsTax + stateTax = stateTax .add(totalTaxByTier.ty1Tax) .add(totalTaxByTier.ty2Tax) .add(totalTaxByTier.ty3Tax) @@ -991,17 +1040,18 @@ function CalculateTaxesTotals(job, otherTotals) { .add(totalTaxByTier.ty5Tax) .add(totalTaxByTier.ty6Tax); us_sales_tax_breakdown = totalTaxByTier; - //console.log("Tiered Taxes Total for Parts/Labor", statePartsTax.toFormat()); + //console.log("Tiered Taxes Total for Parts/Labor", stateTax.toFormat()); - let laborTaxTotal = Dinero(); + // This is not in use as such commented out. + // let laborTaxTotal = Dinero(); - if (Object.keys(job.cieca_pfl).length > 0) { - //Ignore it now, we have calculated it above. - //This was previously used for JCS before parts were also calculated at a different rate. - } else { - //We don't have it, just add in how it was before. - laborTaxTotal = otherTotals.rates.subtotal.percentage((job.tax_lbr_rt || 0) * 100); // THis is currently using the lbr tax rate from PFH not PFL. - } + // if (Object.keys(job.cieca_pfl).length > 0) { + // //Ignore it now, we have calculated it above. + // //This was previously used for JCS before parts were also calculated at a different rate. + // } else { + // //We don't have it, just add in how it was before. + // laborTaxTotal = otherTotals.rates.subtotal.percentage((job.tax_lbr_rt || 0) * 100); // THis is currently using the lbr tax rate from PFH not PFL. + // } //console.log("Labor Tax Total", laborTaxTotal.toFormat()); @@ -1010,9 +1060,9 @@ function CalculateTaxesTotals(job, otherTotals) { federal_tax: subtotal .percentage((job.federal_tax_rate || 0) * 100) .add(otherTotals.additional.pvrt.percentage((job.federal_tax_rate || 0) * 100)), - statePartsTax, + stateTax, us_sales_tax_breakdown, - state_tax: statePartsTax, + state_tax: stateTax, local_tax: subtotal.percentage((job.local_tax_rate || 0) * 100) }; ret.total_repairs = ret.subtotal