1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Improve line item tax/discount rounding

This commit is contained in:
Hillel Coren 2018-04-01 19:17:42 +03:00
parent ba04d97035
commit dba0d28a68
5 changed files with 11 additions and 11 deletions

View File

@ -549,7 +549,7 @@ class InvoiceRepository extends BaseRepository
if ($invoice->is_amount_discount) {
$lineTotal -= $discount;
} else {
$lineTotal -= round($lineTotal * $discount / 100, 2);
$lineTotal -= round($lineTotal * $discount / 100, 4);
}
}
@ -567,17 +567,17 @@ class InvoiceRepository extends BaseRepository
if ($invoice->is_amount_discount) {
$lineTotal -= $discount;
} else {
$lineTotal -= round($lineTotal * $discount / 100, 2);
$lineTotal -= round($lineTotal * $discount / 100, 4);
}
}
if ($invoice->discount > 0) {
if ($invoice->is_amount_discount) {
if ($total != 0) {
$lineTotal -= round(($lineTotal / $total) * $invoice->discount, 2);
$lineTotal -= round(($lineTotal / $total) * $invoice->discount, 4);
}
} else {
$lineTotal -= round($lineTotal * ($invoice->discount / 100), 2);
$lineTotal -= round($lineTotal * ($invoice->discount / 100), 4);
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -652,17 +652,17 @@ function calculateAmounts(invoice) {
if (parseInt(invoice.is_amount_discount)) {
lineTotal -= discount;
} else {
lineTotal -= roundToTwo(lineTotal * discount / 100);
lineTotal -= roundSignificant(lineTotal * discount / 100);
}
}
lineTotal = roundToTwo(lineTotal);
lineTotal = roundSignificant(lineTotal);
if (invoice.discount != 0) {
var discount = roundToTwo(NINJA.parseFloat(invoice.discount));
if (parseInt(invoice.is_amount_discount)) {
lineTotal -= roundToTwo((lineTotal/total) * discount);
lineTotal -= roundSignificant((lineTotal/total) * discount);
} else {
lineTotal -= roundToTwo(lineTotal * discount / 100);
lineTotal -= roundSignificant(lineTotal * discount / 100);
}
}

View File

@ -914,7 +914,7 @@ function ItemModel(data) {
value -= roundToTwo(value * discount / 100);
}
}
return value ? roundToTwo(value) : 0;
return value ? roundSignificant(value) : 0;
});
this.totals.total = ko.computed(function() {