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:
parent
ba04d97035
commit
dba0d28a68
@ -549,7 +549,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
if ($invoice->is_amount_discount) {
|
if ($invoice->is_amount_discount) {
|
||||||
$lineTotal -= $discount;
|
$lineTotal -= $discount;
|
||||||
} else {
|
} 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) {
|
if ($invoice->is_amount_discount) {
|
||||||
$lineTotal -= $discount;
|
$lineTotal -= $discount;
|
||||||
} else {
|
} else {
|
||||||
$lineTotal -= round($lineTotal * $discount / 100, 2);
|
$lineTotal -= round($lineTotal * $discount / 100, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($invoice->discount > 0) {
|
if ($invoice->discount > 0) {
|
||||||
if ($invoice->is_amount_discount) {
|
if ($invoice->is_amount_discount) {
|
||||||
if ($total != 0) {
|
if ($total != 0) {
|
||||||
$lineTotal -= round(($lineTotal / $total) * $invoice->discount, 2);
|
$lineTotal -= round(($lineTotal / $total) * $invoice->discount, 4);
|
||||||
}
|
}
|
||||||
} else {
|
} 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
@ -652,17 +652,17 @@ function calculateAmounts(invoice) {
|
|||||||
if (parseInt(invoice.is_amount_discount)) {
|
if (parseInt(invoice.is_amount_discount)) {
|
||||||
lineTotal -= discount;
|
lineTotal -= discount;
|
||||||
} else {
|
} else {
|
||||||
lineTotal -= roundToTwo(lineTotal * discount / 100);
|
lineTotal -= roundSignificant(lineTotal * discount / 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lineTotal = roundToTwo(lineTotal);
|
lineTotal = roundSignificant(lineTotal);
|
||||||
|
|
||||||
if (invoice.discount != 0) {
|
if (invoice.discount != 0) {
|
||||||
var discount = roundToTwo(NINJA.parseFloat(invoice.discount));
|
var discount = roundToTwo(NINJA.parseFloat(invoice.discount));
|
||||||
if (parseInt(invoice.is_amount_discount)) {
|
if (parseInt(invoice.is_amount_discount)) {
|
||||||
lineTotal -= roundToTwo((lineTotal/total) * discount);
|
lineTotal -= roundSignificant((lineTotal/total) * discount);
|
||||||
} else {
|
} else {
|
||||||
lineTotal -= roundToTwo(lineTotal * discount / 100);
|
lineTotal -= roundSignificant(lineTotal * discount / 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -914,7 +914,7 @@ function ItemModel(data) {
|
|||||||
value -= roundToTwo(value * discount / 100);
|
value -= roundToTwo(value * discount / 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value ? roundToTwo(value) : 0;
|
return value ? roundSignificant(value) : 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.totals.total = ko.computed(function() {
|
this.totals.total = ko.computed(function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user