quantity: (this.get('quantity')) + 1
});
},
- getTotal: function() {
- return (this.get('quantity')) * (this.get('list_price')) * (1 - (this.get('discount')) / 100);
- },
getPriceWithoutTax: function() {
- return getAllPrices().priceWithoutTax;
+ return this.getAllPrices().priceWithoutTax;
},
getPriceWithTax: function() {
- return getAllPrices().priceWithTax;
+ return this.getAllPrices().priceWithTax;
},
getTax: function() {
- return getAllPrices().tax;
+ return this.getAllPrices().tax;
},
getAllPrices: function() {
var self = this;
- var totalTax = (this.get('quantity')) * (this.get('list_price')) * (1 - (this.get('discount')) / 100);
- var totalNoTax = totalTax;
+ var base = (this.get('quantity')) * (this.get('list_price')) * (1 - (this.get('discount')) / 100);
+ var totalTax = base;
+ var totalNoTax = base;
var products = pos.store.get('product.product');
var product = _.detect(products, function(el) {return el.id === self.get('id');});
if (tax.price_include) {
var tmp;
if (tax.type === "percent") {
- tmp = tax.amount / (1 + self.getTotalWithoutTax());
+ tmp = base - (base / (1 + tax.amount));
} else if (tax.type === "fixed") {
tmp = tax.amount * self.get('quantity');
} else {
} else {
var tmp;
if (tax.type === "percent") {
- tmp = tax.amount * self.getTotalWithoutTax();
+ tmp = tax.amount * base;
} else if (tax.type === "fixed") {
tmp = tax.amount * self.get('quantity');
} else {
};
Order.prototype.getTotal = function() {
return (this.get('orderLines')).reduce((function(sum, orderLine) {
- return sum + orderLine.getTotal();
+ return sum + orderLine.getPriceWithTax();
}), 0);
};
Order.prototype.getTotalTaxExcluded = function() {
- return this.getTotal() / 1.21;
+ return (this.get('orderLines')).reduce((function(sum, orderLine) {
+ return sum + orderLine.getPriceWithoutTax();
+ }), 0);
};
Order.prototype.getTax = function() {
- return this.getTotal() / 1.21 * 0.21;
+ return (this.get('orderLines')).reduce((function(sum, orderLine) {
+ return sum + orderLine.getTax();
+ }), 0);
};
Order.prototype.getPaidTotal = function() {
return (this.get('paymentLines')).reduce((function(sum, paymentLine) {