IO-1342 Resolve negative parts discount crash on job totals.

This commit is contained in:
Patrick Fic
2021-09-02 15:48:54 -07:00
parent 00549d6a88
commit 6e0675f28b
3 changed files with 6 additions and 6 deletions

View File

@@ -257,7 +257,7 @@ const generateInvoiceQbxml = (
if (jobline.prt_dsmk_p && jobline.prt_dsmk_p !== 0) { if (jobline.prt_dsmk_p && jobline.prt_dsmk_p !== 0) {
// console.log("Have a part discount", jobline); // console.log("Have a part discount", jobline);
DineroAmount = DineroAmount.add( DineroAmount = DineroAmount.add(
DineroAmount.percentage(jobline.prt_dsmk_p || 0) DineroAmount.percentage(Math.abs(jobline.prt_dsmk_p || 0))
); );
} }
const account = responsibilityCenters.profits.find( const account = responsibilityCenters.profits.find(

View File

@@ -301,7 +301,7 @@ function GenerateCostingData(job) {
amount: Math.round((val.act_price || 0) * 100), amount: Math.round((val.act_price || 0) * 100),
}) })
.multiply(val.part_qty || 0) .multiply(val.part_qty || 0)
.percentage(val.prt_dsmk_p || 0) .percentage(Math.abs(val.prt_dsmk_p || 0))
); );
if (!acc.parts[partsProfitCenter]) if (!acc.parts[partsProfitCenter])
acc.parts[partsProfitCenter] = Dinero(); acc.parts[partsProfitCenter] = Dinero();
@@ -330,7 +330,7 @@ function GenerateCostingData(job) {
amount: Math.round((val.act_price || 0) * 100), amount: Math.round((val.act_price || 0) * 100),
}) })
.multiply(val.part_qty || 0) .multiply(val.part_qty || 0)
.percentage(val.prt_dsmk_p || 0) .percentage(Math.abs(val.prt_dsmk_p || 0))
); );
if (!acc.parts[partsProfitCenter]) if (!acc.parts[partsProfitCenter])

View File

@@ -258,7 +258,7 @@ function CalculatePartsTotals(jobLines) {
amount: Math.round((value.act_price || 0) * 100), amount: Math.round((value.act_price || 0) * 100),
}) })
.multiply(value.part_qty || 0) .multiply(value.part_qty || 0)
.percentage(value.prt_dsmk_p || 0) .percentage(Math.abs(value.prt_dsmk_p || 0))
), ),
list: { list: {
...acc.parts.list, ...acc.parts.list,
@@ -289,7 +289,7 @@ function CalculatePartsTotals(jobLines) {
amount: Math.round((value.act_price || 0) * 100), amount: Math.round((value.act_price || 0) * 100),
}) })
.multiply(value.part_qty || 0) .multiply(value.part_qty || 0)
.percentage(value.prt_dsmk_p || 0) .percentage(Math.abs(value.prt_dsmk_p || 0))
), ),
}, },
}; };
@@ -425,7 +425,7 @@ function CalculateTaxesTotals(job, otherTotals) {
amount: Math.round((val.act_price || 0) * 100), amount: Math.round((val.act_price || 0) * 100),
}) })
.multiply(val.part_qty || 0) .multiply(val.part_qty || 0)
.percentage(val.prt_dsmk_p || 0) .percentage(Math.abs(val.prt_dsmk_p || 0))
) )
.percentage( .percentage(
((job.parts_tax_rates && ((job.parts_tax_rates &&