BOD-63 Prevent render of invoice detail when not selected

This commit is contained in:
Patrick Fic
2020-05-05 18:03:07 -07:00
parent 2317d7d385
commit 783d2ef433
8 changed files with 48 additions and 20 deletions

View File

@@ -8,20 +8,20 @@ export const CalculateInvoiceTotal = (invoice) => {
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 });
let localTax = Dinero({ amount: 0 });
if (!!!invoicelines) return null;
invoicelines.map((i) => {
invoicelines.forEach((i) => {
if (!!i) {
const itemTotal = Dinero({ amount: i.actual_cost * 100 || 0 }).multiply(
i.quantity || 1
);
const itemTotal = Dinero({
amount: Math.round((i.actual_cost || 0) * 100) || 0,
}).multiply(i.quantity || 1);
subtotal = subtotal.add(itemTotal);
if (i.applicable_taxes.federal) {
console.log("Adding fed tax.");
federalTax = federalTax.add(
itemTotal.percentage(federal_tax_rate || 0)
);