[FIX] point_of_sale: fix 'Group of Taxes' calculation

There were still references in the POS to a child_ids field on
account.tax. This field was renamed in accounting v9 to
children_tax_ids. Because child_ids wasn't loaded anymore this meant
that child_ids on the taxes in the POS was always undefined. On top of
that the original code used Array.prototype.concat() assuming it
modified the array, when in fact it returns a new array.

All of this meant that group taxes in the POS were never calculated,
this resolves that.
This commit is contained in:
Darshan Kalola
2015-11-25 15:34:28 +01:00
committed by Joren Van Onder
parent b32355e9b7
commit 1b714bdc6c
+4 -5
View File
@@ -201,7 +201,7 @@ exports.PosModel = Backbone.Model.extend({
},
},{
model: 'account.tax',
fields: ['name','amount', 'price_include', 'include_base_amount', 'amount_type'],
fields: ['name','amount', 'price_include', 'include_base_amount', 'amount_type', 'children_tax_ids'],
domain: null,
loaded: function(self, taxes){
self.taxes = taxes;
@@ -210,9 +210,8 @@ exports.PosModel = Backbone.Model.extend({
self.taxes_by_id[tax.id] = tax;
});
_.each(self.taxes_by_id, function(tax) {
tax.child_taxes = {};
_.each(tax.child_ids, function(child_tax_id) {
tax.child_taxes[child_tax_id] = self.taxes_by_id[child_tax_id];
tax.children_tax_ids = _.map(tax.children_tax_ids, function (child_tax_id) {
return self.taxes_by_id[child_tax_id];
});
});
},
@@ -1351,7 +1350,7 @@ exports.Orderline = Backbone.Model.extend({
total_excluded = ret.total_excluded;
base = ret.total_excluded;
total_included = ret.total_included;
list_taxes.concat(ret.taxes);
list_taxes = list_taxes.concat(ret.taxes);
}
else {
var tax_amount = self._compute_all(tax, base, quantity);