Merged in release/2021-08-20 (pull request #183)
IO-1327 Resolve dinero error on bill posting Approved-by: Patrick Fic
This commit is contained in:
@@ -1,13 +1,8 @@
|
|||||||
import Dinero from "dinero.js";
|
import Dinero from "dinero.js";
|
||||||
|
|
||||||
export const CalculateBillTotal = (invoice) => {
|
export const CalculateBillTotal = (invoice) => {
|
||||||
const {
|
const { total, billlines, federal_tax_rate, local_tax_rate, state_tax_rate } =
|
||||||
total,
|
invoice;
|
||||||
billlines,
|
|
||||||
federal_tax_rate,
|
|
||||||
local_tax_rate,
|
|
||||||
state_tax_rate,
|
|
||||||
} = invoice;
|
|
||||||
|
|
||||||
//TODO Determine why this recalculates so many times.
|
//TODO Determine why this recalculates so many times.
|
||||||
let subtotal = Dinero({ amount: 0 });
|
let subtotal = Dinero({ amount: 0 });
|
||||||
@@ -20,8 +15,7 @@ export const CalculateBillTotal = (invoice) => {
|
|||||||
billlines.forEach((i) => {
|
billlines.forEach((i) => {
|
||||||
if (!!i) {
|
if (!!i) {
|
||||||
const itemTotal = Dinero({
|
const itemTotal = Dinero({
|
||||||
amount:
|
amount: Math.round((i.actual_cost || 0) * 100),
|
||||||
Math.round(((i.actual_cost || 0) * 100 + Number.EPSILON) * 100) / 100,
|
|
||||||
}).multiply(i.quantity || 1);
|
}).multiply(i.quantity || 1);
|
||||||
|
|
||||||
subtotal = subtotal.add(itemTotal);
|
subtotal = subtotal.add(itemTotal);
|
||||||
|
|||||||
Reference in New Issue
Block a user