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) {
|
InvoiceItemEntity item, double invoiceTotal, int precision) {
|
||||||
final double qty = round(item.quantity, 5);
|
final double qty = round(item.quantity, 5);
|
||||||
final double cost = round(item.cost, 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;
|
double lineTotal = qty * cost;
|
||||||
|
|
||||||
if (discount != 0) {
|
if (discount != 0) {
|
||||||
|
|
@ -216,7 +216,7 @@ abstract class CalculateInvoiceTotal {
|
||||||
lineItems.forEach((item) {
|
lineItems.forEach((item) {
|
||||||
final double qty = round(item.quantity, 5);
|
final double qty = round(item.quantity, 5);
|
||||||
final double cost = round(item.cost, 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 taxRate1 = round(item.taxRate1, 3);
|
||||||
final double taxRate2 = round(item.taxRate2, 3);
|
final double taxRate2 = round(item.taxRate2, 3);
|
||||||
final double taxRate3 = round(item.taxRate3, 3);
|
final double taxRate3 = round(item.taxRate3, 3);
|
||||||
|
|
@ -226,14 +226,14 @@ abstract class CalculateInvoiceTotal {
|
||||||
if (isAmountDiscount) {
|
if (isAmountDiscount) {
|
||||||
lineTotal -= itemDiscount;
|
lineTotal -= itemDiscount;
|
||||||
} else {
|
} else {
|
||||||
lineTotal -= round(lineTotal * itemDiscount / 100, 4);
|
lineTotal -= round(lineTotal * itemDiscount / 100, precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (discount != 0) {
|
if (discount != 0) {
|
||||||
if (isAmountDiscount) {
|
if (isAmountDiscount) {
|
||||||
if (total != 0) {
|
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) {
|
lineItems.forEach((item) {
|
||||||
final double qty = round(item.quantity, 5);
|
final double qty = round(item.quantity, 5);
|
||||||
final double cost = round(item.cost, 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;
|
double lineTotal = qty * cost;
|
||||||
|
|
||||||
|
|
@ -313,7 +313,7 @@ abstract class CalculateInvoiceTotal {
|
||||||
if (isAmountDiscount) {
|
if (isAmountDiscount) {
|
||||||
lineTotal -= discount;
|
lineTotal -= discount;
|
||||||
} else {
|
} else {
|
||||||
lineTotal -= round(lineTotal * discount / 100, 4);
|
lineTotal -= round(lineTotal * discount / 100, precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue