Add regression check.

This commit is contained in:
Patrick Fic
2023-09-13 14:55:20 -07:00
parent d1ba90408d
commit ff318599f5
2 changed files with 174 additions and 107 deletions

View File

@@ -1,4 +1,4 @@
import { Collapse, Form, InputNumber, Switch } from "antd"; import { Collapse, Form, Input, InputNumber, Switch } from "antd";
import React from "react"; import React from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
@@ -563,6 +563,13 @@ export function JobsDetailRatesParts({
> >
<Switch /> <Switch />
</Form.Item> </Form.Item>
<Form.Item
style={{ display: "none" }}
label={t("jobs.fields.parts_tax_rates.prt_tx_ty1")}
name={["parts_tax_rates", "PAN", "prt_tx_ty1"]}
>
<Input />
</Form.Item>
</LayoutFormRow> </LayoutFormRow>
<LayoutFormRow header={t("joblines.fields.part_types.PAO")}> <LayoutFormRow header={t("joblines.fields.part_types.PAO")}>
<Form.Item <Form.Item

View File

@@ -793,6 +793,10 @@ function CalculateTaxesTotals(job, otherTotals) {
PAM: Dinero(), PAM: Dinero(),
}; };
if (
job.parts_tax_rates.PAN.prt_tx_ty1 &&
job.parts_tax_rates.PAN.prt_tx_ty1 !== ""
) {
//For each line, determine if it's taxable, and if it is, add the line amount to the taxable amounts total. //For each line, determine if it's taxable, and if it is, add the line amount to the taxable amounts total.
job.joblines job.joblines
.filter((jl) => !jl.removed) .filter((jl) => !jl.removed)
@@ -883,11 +887,12 @@ function CalculateTaxesTotals(job, otherTotals) {
taxableAmountInThisThreshold = Dinero({ taxableAmountInThisThreshold = Dinero({
amount: Math.round(thresholdAmount * 100), amount: Math.round(thresholdAmount * 100),
}); });
remainingTaxableAmounts[typeOfPart] = remainingTaxableAmounts[ remainingTaxableAmounts[typeOfPart] =
typeOfPart remainingTaxableAmounts[typeOfPart].subtract(
].subtract(
Dinero({ Dinero({
amount: Math.round(taxableAmountInThisThreshold * 100), amount: Math.round(
taxableAmountInThisThreshold * 100
),
}) })
); );
} }
@@ -915,6 +920,61 @@ function CalculateTaxesTotals(job, otherTotals) {
.add(tieredTaxAmounts.ty5Tax) .add(tieredTaxAmounts.ty5Tax)
.add(tieredTaxAmounts.ty6Tax); .add(tieredTaxAmounts.ty6Tax);
console.log("Tiered Taxes Total for Parts", statePartsTax.toFormat()); console.log("Tiered Taxes Total for Parts", statePartsTax.toFormat());
} else {
//Use the old thing.
job.joblines
.filter((jl) => !jl.removed)
.forEach((val) => {
if (!val.tax_part) return;
if (!val.part_type && IsAdditionalCost(val)) {
additionalItemsTax = additionalItemsTax.add(
Dinero({ amount: Math.round((val.act_price || 0) * 100) })
.multiply(val.part_qty || 0)
.percentage(
((job.parts_tax_rates &&
job.parts_tax_rates["PAN"] &&
job.parts_tax_rates["PAN"].prt_tax_rt) ||
0) * 100
)
);
} else {
statePartsTax = statePartsTax.add(
Dinero({ amount: Math.round((val.act_price || 0) * 100) })
.multiply(val.part_qty || 0)
.add(
val.prt_dsmk_m &&
val.prt_dsmk_m !== 0 &&
DiscountNotAlreadyCounted(val, job.joblines)
? val.prt_dsmk_m
? Dinero({ amount: Math.round(val.prt_dsmk_m * 100) })
: Dinero({
amount: Math.round(val.act_price * 100),
})
.multiply(val.part_qty || 0)
.percentage(Math.abs(val.prt_dsmk_p || 0))
.multiply(val.prt_dsmk_p > 0 ? 1 : -1)
: Dinero()
)
.percentage(
((job.parts_tax_rates &&
job.parts_tax_rates[val.part_type] &&
job.parts_tax_rates[val.part_type].prt_tax_rt) ||
(val.part_type &&
val.part_type.startsWith("PAG") &&
BackupGlassTax &&
BackupGlassTax.prt_tax_rt) ||
(!val.part_type &&
val.db_ref === "900510" &&
job.parts_tax_rates["PAN"] &&
job.parts_tax_rates["PAN"].prt_tax_rt) ||
0) * 100
)
);
}
console.log(statePartsTax.toFormat(), val.line_desc);
});
}
let laborTaxTotal = Dinero(); let laborTaxTotal = Dinero();
if (Object.keys(job.cieca_pfl).length > 0) { if (Object.keys(job.cieca_pfl).length > 0) {
@@ -975,7 +1035,7 @@ 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) // 0 if using PFP method.
.add( .add(
otherTotals.rates.mapa.hasMapaLine === false //If parts and materials were not added as lines, we must calculate the taxes on them. otherTotals.rates.mapa.hasMapaLine === false //If parts and materials were not added as lines, we must calculate the taxes on them.
? otherTotals.rates.mapa.total.percentage( ? otherTotals.rates.mapa.total.percentage(