From b842cee0765a603d0264e813cdd07c924cea9a06 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 16 Feb 2022 16:45:49 -0800 Subject: [PATCH] IO-1738 PVRT Update --- .../job-totals.table.other.component.jsx | 8 +++--- .../job-totals.table.totals.component.jsx | 25 ++++++++++++++++++- server/job/job-totals.js | 15 +++++------ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/client/src/components/job-totals-table/job-totals.table.other.component.jsx b/client/src/components/job-totals-table/job-totals.table.other.component.jsx index b7c302899..ac132f1a6 100644 --- a/client/src/components/job-totals-table/job-totals.table.other.component.jsx +++ b/client/src/components/job-totals-table/job-totals.table.other.component.jsx @@ -33,10 +33,10 @@ export default function JobTotalsTableOther({ job }) { key: t("jobs.fields.storage_payable"), total: job.job_totals.additional.storage, }, - { - key: t("jobs.fields.ca_bc_pvrt"), - total: job.job_totals.additional.pvrt, - }, + // { + // key: t("jobs.fields.ca_bc_pvrt"), + // total: job.job_totals.additional.pvrt, + // }, ]; }, [job.job_totals, t]); diff --git a/client/src/components/job-totals-table/job-totals.table.totals.component.jsx b/client/src/components/job-totals-table/job-totals.table.totals.component.jsx index faa2e95bd..60c7c8ce9 100644 --- a/client/src/components/job-totals-table/job-totals.table.totals.component.jsx +++ b/client/src/components/job-totals-table/job-totals.table.totals.component.jsx @@ -3,7 +3,22 @@ import Dinero from "dinero.js"; import React, { useMemo } from "react"; import { useTranslation } from "react-i18next"; -export default function JobTotalsTableTotals({ job }) { +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +const mapStateToProps = createStructuredSelector({ + //currentUser: selectCurrentUser + bodyshop: selectBodyshop, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); +export default connect( + mapStateToProps, + mapDispatchToProps +)(JobTotalsTableTotals); + +export function JobTotalsTableTotals({ bodyshop, job }) { const { t } = useTranslation(); const data = useMemo(() => { @@ -21,6 +36,14 @@ export default function JobTotalsTableTotals({ job }) { key: t("jobs.labels.state_tax_amt"), total: job.job_totals.totals.state_tax, }, + ...(bodyshop.region_config === "CA_BC" + ? [ + { + key: t("jobs.fields.ca_bc_pvrt"), + total: job.job_totals.additional.pvrt, + }, + ] + : []), { key: t("jobs.labels.federal_tax_amt"), total: job.job_totals.totals.federal_tax, diff --git a/server/job/job-totals.js b/server/job/job-totals.js index b0a9cfed1..31dc995a6 100644 --- a/server/job/job-totals.js +++ b/server/job/job-totals.js @@ -442,8 +442,8 @@ function CalculateAdditional(job) { ret.total = ret.additionalCosts .add(ret.adjustments) //IO-813 Adjustment takes care of GST & PST at labor rate. .add(ret.towing) - .add(ret.storage) - .add(ret.pvrt); + .add(ret.storage); + //.add(ret.pvrt); return ret; } @@ -452,8 +452,8 @@ function CalculateTaxesTotals(job, otherTotals) { const subtotal = otherTotals.parts.parts.subtotal .add(otherTotals.parts.sublets.subtotal) .add(otherTotals.rates.subtotal) //No longer using just rates subtotal to include mapa/mash. - .add(otherTotals.additional.total) - .subtract(otherTotals.additional.pvrt); + .add(otherTotals.additional.total); + // .add(Dinero({ amount: (job.towing_payable || 0) * 100 })) // .add(Dinero({ amount: (job.storage_payable || 0) * 100 })); @@ -546,14 +546,15 @@ function CalculateTaxesTotals(job, otherTotals) { .add( otherTotals.additional.storage.percentage((job.tax_str_rt || 0) * 100) ) - .add(additionalItemsTax) - .add(otherTotals.additional.pvrt), + .add(additionalItemsTax), + // .add(otherTotals.additional.pvrt), local_tax: subtotal.percentage((job.local_tax_rate || 0) * 100), }; ret.total_repairs = ret.subtotal .add(ret.federal_tax) .add(ret.state_tax) - .add(ret.local_tax); + .add(ret.local_tax) + .add(otherTotals.additional.pvrt); ret.custPayable = { deductible: Dinero({ amount: Math.round((job.ded_amt || 0) * 100) }) || 0,