Correct rounding for line item discounts
This commit is contained in:
parent
471528f5b5
commit
84eb3eb4bc
|
|
@ -183,7 +183,7 @@ abstract class CalculateInvoiceTotal {
|
|||
InvoiceItemEntity item, double invoiceTotal, int precision) {
|
||||
final double qty = round(item.quantity, 5);
|
||||
final double cost = round(item.cost, 5);
|
||||
final double itemDiscount = round(item.discount, precision);
|
||||
final double itemDiscount = round(item.discount, 5);
|
||||
double lineTotal = qty * cost;
|
||||
|
||||
if (discount != 0) {
|
||||
|
|
@ -216,7 +216,7 @@ abstract class CalculateInvoiceTotal {
|
|||
lineItems.forEach((item) {
|
||||
final double qty = round(item.quantity, 5);
|
||||
final double cost = round(item.cost, 5);
|
||||
final double itemDiscount = round(item.discount, precision);
|
||||
final double itemDiscount = round(item.discount, 5);
|
||||
final double taxRate1 = round(item.taxRate1, 3);
|
||||
final double taxRate2 = round(item.taxRate2, 3);
|
||||
final double taxRate3 = round(item.taxRate3, 3);
|
||||
|
|
@ -226,14 +226,14 @@ abstract class CalculateInvoiceTotal {
|
|||
if (isAmountDiscount) {
|
||||
lineTotal -= itemDiscount;
|
||||
} else {
|
||||
lineTotal -= round(lineTotal * itemDiscount / 100, 4);
|
||||
lineTotal -= round(lineTotal * itemDiscount / 100, precision);
|
||||
}
|
||||
}
|
||||
|
||||
if (discount != 0) {
|
||||
if (isAmountDiscount) {
|
||||
if (total != 0) {
|
||||
lineTotal -= round(lineTotal / total * discount, 4);
|
||||
lineTotal -= round(lineTotal / total * discount, precision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ abstract class CalculateInvoiceTotal {
|
|||
lineItems.forEach((item) {
|
||||
final double qty = round(item.quantity, 5);
|
||||
final double cost = round(item.cost, 5);
|
||||
final double discount = round(item.discount, precision);
|
||||
final double discount = round(item.discount, 5);
|
||||
|
||||
double lineTotal = qty * cost;
|
||||
|
||||
|
|
@ -313,7 +313,7 @@ abstract class CalculateInvoiceTotal {
|
|||
if (isAmountDiscount) {
|
||||
lineTotal -= discount;
|
||||
} else {
|
||||
lineTotal -= round(lineTotal * discount / 100, 4);
|
||||
lineTotal -= round(lineTotal * discount / 100, precision);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue