Changed global Dinero rounding IO-469.

This commit is contained in:
Patrick Fic
2021-02-02 14:43:09 -08:00
parent d1280e8680
commit 49a9f71d19
5 changed files with 12 additions and 11 deletions

View File

@@ -140,8 +140,12 @@ export function BillEnterModalLinesComponent({
...item,
actual_cost: !!item.actual_cost
? item.actual_cost
: parseFloat(e.target.value) *
(1 - discount),
: Math.round(
(parseFloat(e.target.value) *
(1 - discount) +
Number.EPSILON) *
100
) / 100,
};
}
return item;

View File

@@ -22,9 +22,12 @@ export const CalculateBillTotal = (invoice) => {
billlines.forEach((i) => {
if (!!i) {
console.log("Amount:", (i.actual_cost || 0) * 100);
const itemTotal = Dinero({
amount: Math.round((i.actual_cost || 0) * 100) || 0,
amount:
Math.round(((i.actual_cost || 0) * 100 + Number.EPSILON) * 100) / 100,
}).multiply(i.quantity || 1);
subtotal = subtotal.add(itemTotal);
if (i.applicable_taxes.federal) {
federalTax = federalTax.add(