Add regression check.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Collapse, Form, InputNumber, Switch } from "antd";
|
||||
import { Collapse, Form, Input, InputNumber, Switch } from "antd";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -563,6 +563,13 @@ export function JobsDetailRatesParts({
|
||||
>
|
||||
<Switch />
|
||||
</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 header={t("joblines.fields.part_types.PAO")}>
|
||||
<Form.Item
|
||||
|
||||
@@ -793,6 +793,10 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
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.
|
||||
job.joblines
|
||||
.filter((jl) => !jl.removed)
|
||||
@@ -883,11 +887,12 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
taxableAmountInThisThreshold = Dinero({
|
||||
amount: Math.round(thresholdAmount * 100),
|
||||
});
|
||||
remainingTaxableAmounts[typeOfPart] = remainingTaxableAmounts[
|
||||
typeOfPart
|
||||
].subtract(
|
||||
remainingTaxableAmounts[typeOfPart] =
|
||||
remainingTaxableAmounts[typeOfPart].subtract(
|
||||
Dinero({
|
||||
amount: Math.round(taxableAmountInThisThreshold * 100),
|
||||
amount: Math.round(
|
||||
taxableAmountInThisThreshold * 100
|
||||
),
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -915,6 +920,61 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
.add(tieredTaxAmounts.ty5Tax)
|
||||
.add(tieredTaxAmounts.ty6Tax);
|
||||
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();
|
||||
|
||||
if (Object.keys(job.cieca_pfl).length > 0) {
|
||||
@@ -975,7 +1035,7 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
.add(
|
||||
otherTotals.additional.storage.percentage((job.tax_str_rt || 0) * 100)
|
||||
)
|
||||
// .add(additionalItemsTax)
|
||||
.add(additionalItemsTax) // 0 if using PFP method.
|
||||
.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.total.percentage(
|
||||
|
||||
Reference in New Issue
Block a user