Fixed integer error when adding a decimal in amount when line is present BOD-120
This commit is contained in:
@@ -172,15 +172,21 @@ export default function InvoiceFormComponent({
|
|||||||
|
|
||||||
<Form.Item shouldUpdate>
|
<Form.Item shouldUpdate>
|
||||||
{() => {
|
{() => {
|
||||||
const totals = CalculateInvoiceTotal(
|
const values = form.getFieldsValue([
|
||||||
form.getFieldsValue([
|
"invoicelines",
|
||||||
"invoicelines",
|
"total",
|
||||||
"total",
|
"federal_tax_rate",
|
||||||
"federal_tax_rate",
|
"state_tax_rate",
|
||||||
"state_tax_rate",
|
"local_tax_rate",
|
||||||
"local_tax_rate",
|
]);
|
||||||
])
|
let totals;
|
||||||
);
|
console.log("values", values);
|
||||||
|
if (
|
||||||
|
!!values.total &&
|
||||||
|
!!values.invoicelines &&
|
||||||
|
values.invoicelines.length > 0
|
||||||
|
)
|
||||||
|
totals = CalculateInvoiceTotal(values);
|
||||||
if (!!totals)
|
if (!!totals)
|
||||||
return (
|
return (
|
||||||
<div className="invoice-form-totals">
|
<div className="invoice-form-totals">
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ import Dinero from "dinero.js";
|
|||||||
export const CalculateInvoiceTotal = (invoice) => {
|
export const CalculateInvoiceTotal = (invoice) => {
|
||||||
const {
|
const {
|
||||||
total,
|
total,
|
||||||
|
|
||||||
invoicelines,
|
invoicelines,
|
||||||
federal_tax_rate,
|
federal_tax_rate,
|
||||||
local_tax_rate,
|
local_tax_rate,
|
||||||
state_tax_rate,
|
state_tax_rate,
|
||||||
} = invoice;
|
} = invoice;
|
||||||
//TODO Determine why this recalculates so many times.
|
//TODO Determine why this recalculates so many times.
|
||||||
console.log("Calculating invoice total...");
|
|
||||||
let subtotal = Dinero({ amount: 0 });
|
let subtotal = Dinero({ amount: 0 });
|
||||||
let federalTax = Dinero({ amount: 0 });
|
let federalTax = Dinero({ amount: 0 });
|
||||||
let stateTax = 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 enteredTotal = subtotal.add(federalTax).add(stateTax).add(localTax);
|
||||||
const discrepancy = enteredTotal.subtract(invoiceTotal);
|
const discrepancy = enteredTotal.subtract(invoiceTotal);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user