Fixed integer error when adding a decimal in amount when line is present BOD-120
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user