IO-3627 Courtesy Car Create RO
Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
@@ -885,6 +885,8 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
STOR: Dinero()
|
||||
};
|
||||
|
||||
const pfp = job.parts_tax_rates;
|
||||
|
||||
//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)
|
||||
@@ -916,7 +918,17 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
})
|
||||
.multiply(val.part_qty || 0)
|
||||
.add(discMarkupAmount);
|
||||
taxableAmounts[typeOfPart] = taxableAmounts[typeOfPart].add(partAmount);
|
||||
if (taxableAmounts[typeOfPart]) {
|
||||
taxableAmounts[typeOfPart] = taxableAmounts[typeOfPart].add(partAmount);
|
||||
} else {
|
||||
const isTaxableCustomType =
|
||||
IsTrueOrYes(pfp?.[typeOfPart]?.prt_tax_in) || pfp?.[typeOfPart]?.prt_tax_in === true;
|
||||
|
||||
if (isTaxableCustomType) {
|
||||
if (!taxableAmounts[typeOfPart]) taxableAmounts[typeOfPart] = Dinero();
|
||||
taxableAmounts[typeOfPart] = taxableAmounts[typeOfPart].add(partAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -969,13 +981,15 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
})
|
||||
);
|
||||
|
||||
const pfp = job.parts_tax_rates;
|
||||
|
||||
//For any profile level markups/discounts, add them in now as well.
|
||||
Object.keys(otherTotals.parts.adjustments).forEach((key) => {
|
||||
const adjustmentAmount = otherTotals.parts.adjustments[key];
|
||||
if (adjustmentAmount.getAmount() !== 0 && pfp[key]?.prt_tax_in) {
|
||||
taxableAmounts[key] = taxableAmounts[key].add(adjustmentAmount);
|
||||
if (taxableAmounts[key]) {
|
||||
taxableAmounts[key] = taxableAmounts[key].add(adjustmentAmount);
|
||||
} else {
|
||||
taxableAmounts[key] = Dinero().add(adjustmentAmount);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1072,6 +1086,21 @@ function CalculateTaxesTotals(job, otherTotals) {
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if (pfp[key]) {
|
||||
//Custom part types (e.g. CC*) should flow through taxableAmountsByTier too.
|
||||
let assignedToTier = false;
|
||||
for (let tyCounter = 1; tyCounter <= 5; tyCounter++) {
|
||||
if (IsTrueOrYes(pfp[key][`prt_tx_in${tyCounter}`])) {
|
||||
taxableAmountsByTier[`ty${tyCounter}Tax`] = taxableAmountsByTier[`ty${tyCounter}Tax`].add(
|
||||
taxableAmounts[key]
|
||||
);
|
||||
assignedToTier = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!assignedToTier && (IsTrueOrYes(pfp[key].prt_tax_in) || pfp[key].prt_tax_in === true)) {
|
||||
taxableAmountsByTier.ty1Tax = taxableAmountsByTier.ty1Tax.add(taxableAmounts[key]);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logger.log("job-totals-USA Key with issue", "warn", null, job.id, {
|
||||
|
||||
Reference in New Issue
Block a user