mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fix for discount rounding
This commit is contained in:
parent
f2ea4a1669
commit
032efd5c22
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -714,7 +714,7 @@ function calculateAmounts(invoice) {
|
|||||||
if (parseInt(invoice.is_amount_discount)) {
|
if (parseInt(invoice.is_amount_discount)) {
|
||||||
lineTotal -= roundToTwo((lineTotal/total) * invoice.discount);
|
lineTotal -= roundToTwo((lineTotal/total) * invoice.discount);
|
||||||
} else {
|
} 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)) {
|
if (parseInt(invoice.is_amount_discount)) {
|
||||||
discount = roundToTwo(invoice.discount);
|
discount = roundToTwo(invoice.discount);
|
||||||
} else {
|
} else {
|
||||||
discount = roundToTwo(total * (invoice.discount/100));
|
discount = roundToTwo(total * invoice.discount / 100);
|
||||||
}
|
}
|
||||||
total -= discount;
|
total -= discount;
|
||||||
}
|
}
|
||||||
|
@ -383,7 +383,7 @@ function InvoiceModel(data) {
|
|||||||
if (parseInt(self.is_amount_discount())) {
|
if (parseInt(self.is_amount_discount())) {
|
||||||
return roundToTwo(self.discount());
|
return roundToTwo(self.discount());
|
||||||
} else {
|
} 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())) {
|
if (parseInt(self.is_amount_discount())) {
|
||||||
lineTotal -= roundToTwo((lineTotal/total) * self.discount());
|
lineTotal -= roundToTwo((lineTotal/total) * self.discount());
|
||||||
} else {
|
} else {
|
||||||
lineTotal -= roundToTwo(lineTotal * (self.discount()/100));
|
lineTotal -= roundToTwo(lineTotal * self.discount() / 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -822,7 +822,7 @@ function ItemModel(data) {
|
|||||||
|
|
||||||
this.prettyQty = ko.computed({
|
this.prettyQty = ko.computed({
|
||||||
read: function () {
|
read: function () {
|
||||||
return NINJA.parseFloat(this.qty()) ? roundSignificant(NINJA.parseFloat(this.qty())) : '';
|
return NINJA.parseFloat(this.qty()) ? NINJA.parseFloat(this.qty()) : '';
|
||||||
},
|
},
|
||||||
write: function (value) {
|
write: function (value) {
|
||||||
this.qty(value);
|
this.qty(value);
|
||||||
@ -832,7 +832,7 @@ function ItemModel(data) {
|
|||||||
|
|
||||||
this.prettyCost = ko.computed({
|
this.prettyCost = ko.computed({
|
||||||
read: function () {
|
read: function () {
|
||||||
return this.cost() ? roundSignificant(this.cost()).toFixed(2) : '';
|
return this.cost() ? this.cost() : '';
|
||||||
},
|
},
|
||||||
write: function (value) {
|
write: function (value) {
|
||||||
this.cost(value);
|
this.cost(value);
|
||||||
@ -842,6 +842,12 @@ function ItemModel(data) {
|
|||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
ko.mapping.fromJS(data, {}, this);
|
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();
|
this.totals = ko.observable();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user