Skip to content

Commit

Permalink
[IMP] point_of_sale: add support for taxes included in base amount.
Browse files Browse the repository at this point in the history
  • Loading branch information
fvdsn committed Dec 18, 2014
1 parent 34b5394 commit c8000df
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions addons/point_of_sale/static/src/js/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,19 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
get_tax: function(){
return this.get_all_prices().tax;
},
get_tax_objects: function(){
var taxes_ids = this.get_product().taxes_id;
get_applicable_taxes: function(){
// Shenaningans because we need
// to keep the taxes ordering.
var ptaxes_ids = this.get_product().taxes_id;
var ptaxes_set = {};
for (var i = 0; i < ptaxes_ids.length; i++) {
ptaxes_set[ptaxes_ids[i]] = true;
}
var taxes = [];
for (var i = 0; i < taxes_ids.length; i++) {
taxes.push(this.pos.taxes_by_id[taxes_ids[i]]);
for (var i = 0; i < this.pos.taxes.length; i++) {
if (ptaxes_set[this.pos.taxes[i].id]) {
taxes.push(this.pos.taxes[i]);
}
}
return taxes;
},
Expand All @@ -852,7 +860,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
var totalNoTax = base;

var product = this.get_product();
var taxes = this.get_tax_objects();
var taxes = this.get_applicable_taxes();
var taxtotal = 0;
var taxdetail = {};
_.each(taxes, function(tax) {
Expand All @@ -878,7 +886,13 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
} else {
throw "This type of tax is not supported by the point of sale: " + tax.type;
}

tmp = round_pr(tmp,currency_rounding);

if (tax.include_base_amount) {
base += tmp;
}

taxtotal += tmp;
totalTax += tmp;
taxdetail[tax.id] = tmp;
Expand Down

0 comments on commit c8000df

Please sign in to comment.