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

Fix for discount rounding

This commit is contained in:
Hillel Coren 2017-08-18 13:26:14 +03:00
parent f2ea4a1669
commit 032efd5c22
4 changed files with 34 additions and 28 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -714,7 +714,7 @@ function calculateAmounts(invoice) {
if (parseInt(invoice.is_amount_discount)) {
lineTotal -= roundToTwo((lineTotal/total) * invoice.discount);
} else {
lineTotal -= roundToTwo(lineTotal * (invoice.discount/100));
lineTotal -= roundToTwo(lineTotal * invoice.discount / 100);
}
}
@ -749,7 +749,7 @@ function calculateAmounts(invoice) {
if (parseInt(invoice.is_amount_discount)) {
discount = roundToTwo(invoice.discount);
} else {
discount = roundToTwo(total * (invoice.discount/100));
discount = roundToTwo(total * invoice.discount / 100);
}
total -= discount;
}

View File

@ -383,7 +383,7 @@ function InvoiceModel(data) {
if (parseInt(self.is_amount_discount())) {
return roundToTwo(self.discount());
} else {
return roundToTwo(self.totals.rawSubtotal() * (self.discount()/100));
return roundToTwo(self.totals.rawSubtotal() * self.discount() / 100);
}
});
@ -427,7 +427,7 @@ function InvoiceModel(data) {
if (parseInt(self.is_amount_discount())) {
lineTotal -= roundToTwo((lineTotal/total) * self.discount());
} else {
lineTotal -= roundToTwo(lineTotal * (self.discount()/100));
lineTotal -= roundToTwo(lineTotal * self.discount() / 100);
}
}
@ -822,7 +822,7 @@ function ItemModel(data) {
this.prettyQty = ko.computed({
read: function () {
return NINJA.parseFloat(this.qty()) ? roundSignificant(NINJA.parseFloat(this.qty())) : '';
return NINJA.parseFloat(this.qty()) ? NINJA.parseFloat(this.qty()) : '';
},
write: function (value) {
this.qty(value);
@ -832,7 +832,7 @@ function ItemModel(data) {
this.prettyCost = ko.computed({
read: function () {
return this.cost() ? roundSignificant(this.cost()).toFixed(2) : '';
return this.cost() ? this.cost() : '';
},
write: function (value) {
this.cost(value);
@ -842,6 +842,12 @@ function ItemModel(data) {
if (data) {
ko.mapping.fromJS(data, {}, this);
var precision = getPrecision(this.cost());
var cost = parseFloat(this.cost());
if (cost) {
this.cost(cost.toFixed(Math.max(2, precision)));
}
this.qty(roundSignificant(this.qty()));
}
this.totals = ko.observable();