diff --git a/client/src/components/job-detail-lines/job-lines-expander.component.jsx b/client/src/components/job-detail-lines/job-lines-expander.component.jsx index ceec1b2df..2d932bba5 100644 --- a/client/src/components/job-detail-lines/job-lines-expander.component.jsx +++ b/client/src/components/job-detail-lines/job-lines-expander.component.jsx @@ -7,6 +7,7 @@ import { Link } from "react-router-dom"; import { createStructuredSelector } from "reselect"; import { GET_JOB_LINE_ORDERS } from "../../graphql/jobs.queries"; import { QUERY_JOBLINE_TASKS_PAGINATED } from "../../graphql/tasks.queries.js"; +import { selectTechnician } from "../../redux/tech/tech.selectors.js"; import { selectBodyshop } from "../../redux/user/user.selectors"; import CurrencyFormatter from "../../utils/CurrencyFormatter"; import { DateFormatter } from "../../utils/DateFormatter"; @@ -16,14 +17,15 @@ import FeatureWrapper from "../feature-wrapper/feature-wrapper.component.jsx"; import TaskListContainer from "../task-list/task-list.container.jsx"; const mapStateToProps = createStructuredSelector({ - bodyshop: selectBodyshop + bodyshop: selectBodyshop, + technician: selectTechnician }); const mapDispatchToProps = (dispatch) => ({}); export default connect(mapStateToProps, mapDispatchToProps)(JobLinesExpander); -export function JobLinesExpander({ jobline, jobid, bodyshop }) { +export function JobLinesExpander({ jobline, jobid, bodyshop, technician }) { const { t } = useTranslation(); const { loading, error, data } = useQuery(GET_JOB_LINE_ORDERS, { fetchPolicy: "network-only", @@ -48,9 +50,15 @@ export function JobLinesExpander({ jobline, jobid, bodyshop }) { children: ( - - {line.parts_order.order_number} - + {!technician ? ( + <> + + {line.parts_order.order_number} + + + ) : ( + `${line.parts_order.order_number}` + )} {line.parts_order.order_date} @@ -121,9 +129,15 @@ export function JobLinesExpander({ jobline, jobid, bodyshop }) { children: ( - - {line.bill.invoice_number} - + {!technician ? ( + <> + + {line.bill.invoice_number} + + + ) : ( + `${line.bill.invoice_number}` + )} diff --git a/client/src/components/job-detail-lines/job-lines-part-price-change.component.jsx b/client/src/components/job-detail-lines/job-lines-part-price-change.component.jsx index 9b394af71..a7548542c 100644 --- a/client/src/components/job-detail-lines/job-lines-part-price-change.component.jsx +++ b/client/src/components/job-detail-lines/job-lines-part-price-change.component.jsx @@ -3,13 +3,21 @@ import { Button, Form, notification, Popover, Tooltip } from "antd"; import axios from "axios"; import { t } from "i18next"; import React, { useState } from "react"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; import { UPDATE_LINE_PPC } from "../../graphql/jobs-lines.queries"; +import { selectTechnician } from "../../redux/tech/tech.selectors"; import CurrencyFormatter from "../../utils/CurrencyFormatter"; import InstanceRenderManager from "../../utils/instanceRenderMgr"; import CurrencyFormItemComponent from "../form-items-formatted/currency-form-item.component"; import JobLineConvertToLabor from "../job-line-convert-to-labor/job-line-convert-to-labor.component"; -export default function JobLinesPartPriceChange({ job, line, refetch }) { +const mapStateToProps = createStructuredSelector({ + technician: selectTechnician +}); +const mapDispatchToProps = (dispatch) => ({}); + +export function JobLinesPartPriceChange({ job, line, refetch, technician }) { const [loading, setLoading] = useState(false); const [updatePartPrice] = useMutation(UPDATE_LINE_PPC); @@ -52,7 +60,7 @@ export default function JobLinesPartPriceChange({ job, line, refetch }) { } }; - const popcontent = InstanceRenderManager({ + const popcontent = !technician && InstanceRenderManager({ imex: null, rome: (
@@ -95,3 +103,4 @@ export default function JobLinesPartPriceChange({ job, line, refetch }) { ); } +export default connect(mapStateToProps, mapDispatchToProps)(JobLinesPartPriceChange); diff --git a/client/src/components/job-detail-lines/job-lines.component.jsx b/client/src/components/job-detail-lines/job-lines.component.jsx index a639001f9..984455466 100644 --- a/client/src/components/job-detail-lines/job-lines.component.jsx +++ b/client/src/components/job-detail-lines/job-lines.component.jsx @@ -205,7 +205,6 @@ export function JobLinesComponent({ onFilter: (value, record) => value.includes(record.part_type), render: (text, record) => (record.part_type ? t(`joblines.fields.part_types.${record.part_type}`) : null) }, - { title: t("joblines.fields.act_price"), dataIndex: "act_price", @@ -220,7 +219,6 @@ export function JobLinesComponent({ dataIndex: "part_qty", key: "part_qty" }, - // { // title: t('joblines.fields.tax_part'), // dataIndex: 'tax_part', @@ -329,7 +327,7 @@ export function JobLinesComponent({ key: "actions", render: (text, record) => ( - {(record.manual_line || jobIsPrivate) && ( + {(record.manual_line || jobIsPrivate) && !technician && ( <> - {(record.manual_line || jobIsPrivate) && ( + {(record.manual_line || jobIsPrivate) && !technician && ( <> - {InstanceRenderManager({ rome: })} + {InstanceRenderManager({ rome: })} ({ insertAuditTrail: ({ jobid, operation, type }) => dispatch(insertAuditTrail({ jobid, operation, type })) }); export default connect(mapStateToProps, mapDispatchToProps)(JobLineConvertToLabor); -export function JobLineConvertToLabor({ children, jobline, job, insertAuditTrail, ...otherBtnProps }) { +export function JobLineConvertToLabor({ children, jobline, job, insertAuditTrail, technician, ...otherBtnProps }) { const { t } = useTranslation(); const [loading, setLoading] = useState(false); @@ -165,7 +166,7 @@ export function JobLineConvertToLabor({ children, jobline, job, insertAuditTrail return ( <> {children} - {jobline.act_price !== 0 && ( + {jobline.act_price !== 0 && !technician && ( ); 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/pages/production-list/production-list.component.jsx b/client/src/pages/production-list/production-list.component.jsx index 116d6cb20..01dd29d51 100644 --- a/client/src/pages/production-list/production-list.component.jsx +++ b/client/src/pages/production-list/production-list.component.jsx @@ -1,6 +1,12 @@ import React from "react"; +import NoteUpsertModal from "../../components/note-upsert-modal/note-upsert-modal.container"; import ProductionListTable from "../../components/production-list-table/production-list-table.container"; export default function ProductionListComponent() { - return ; + return ( + <> + + + + ); } diff --git a/client/src/pages/tech/tech.page.component.jsx b/client/src/pages/tech/tech.page.component.jsx index 9f6b11cf7..2733bae68 100644 --- a/client/src/pages/tech/tech.page.component.jsx +++ b/client/src/pages/tech/tech.page.component.jsx @@ -33,6 +33,8 @@ const TimeTicketModalTask = lazy( const TechAssignedProdJobs = lazy(() => import("../tech-assigned-prod-jobs/tech-assigned-prod-jobs.component")); const TechDispatchedParts = lazy(() => import("../tech-dispatched-parts/tech-dispatched-parts.page")); +const TaskUpsertModalContainer = lazy(() => import("../../components/task-upsert-modal/task-upsert-modal.container")); + const { Content } = Layout; const mapStateToProps = createStructuredSelector({ @@ -67,6 +69,7 @@ export function TechPage({ technician }) { + 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