Fixed integer error when adding a decimal in amount when line is present BOD-120

This commit is contained in:
Patrick Fic
2020-05-06 08:38:53 -07:00
parent 783d2ef433
commit 851527a907
2 changed files with 17 additions and 11 deletions

View File

@@ -3,13 +3,13 @@ import Dinero from "dinero.js";
export const CalculateInvoiceTotal = (invoice) => {
const {
total,
invoicelines,
federal_tax_rate,
local_tax_rate,
state_tax_rate,
} = invoice;
//TODO Determine why this recalculates so many times.
console.log("Calculating invoice total...");
let subtotal = Dinero({ amount: 0 });
let federalTax = Dinero({ amount: 0 });
let stateTax = Dinero({ amount: 0 });
@@ -33,7 +33,7 @@ export const CalculateInvoiceTotal = (invoice) => {
}
});
const invoiceTotal = Dinero({ amount: total * 100 || 0 });
const invoiceTotal = Dinero({ amount: (parseFloat(total) || 0) * 100 });
const enteredTotal = subtotal.add(federalTax).add(stateTax).add(localTax);
const discrepancy = enteredTotal.subtract(invoiceTotal);