From 643bb8566c4c3d53ff58ebf8c4141f46765a8dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Mon, 6 Jan 2014 14:51:19 +0100 Subject: [PATCH] [IMP] point_of_sale: detailed tax report on receipt bzr revid: fva@openerp.com-20140106135119-cnhopx3nie7f0r8h --- addons/point_of_sale/static/src/css/pos.css | 4 +- addons/point_of_sale/static/src/js/models.js | 37 +++++++++++++++++- addons/point_of_sale/static/src/xml/pos.xml | 40 +++++++++++++------- 3 files changed, 66 insertions(+), 15 deletions(-) diff --git a/addons/point_of_sale/static/src/css/pos.css b/addons/point_of_sale/static/src/css/pos.css index 275187f8e67..922a72d8423 100644 --- a/addons/point_of_sale/static/src/css/pos.css +++ b/addons/point_of_sale/static/src/css/pos.css @@ -589,7 +589,6 @@ td { line-height: 24px; border-radius: 3px; - cursor: pointer; border: 1px solid #cacaca; @@ -882,6 +881,9 @@ td { border-radius: 3px; overflow: hidden; } +.pos .pos-sale-ticket pre{ + font-family: "Inconsolata"; +} .pos .pos-sale-ticket .emph{ font-size: 20px; margin:5px; diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index e9940535d42..bbb63255617 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -47,6 +47,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal this.units = []; this.units_by_id = {}; this.pricelist = null; + window.posmodel = this; // these dynamic attributes can be watched for change by other models or widgets this.set({ @@ -121,7 +122,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal }).then(function(partners){ self.partners = partners; - return self.fetch('account.tax', ['amount', 'price_include', 'type']); + return self.fetch('account.tax', ['name','amount', 'price_include', 'type']); }).then(function(taxes){ self.taxes = taxes; @@ -598,6 +599,9 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal get_tax: function(){ return this.get_all_prices().tax; }, + get_tax_details: function(){ + return this.get_all_prices().taxDetails; + }, get_all_prices: function(){ var self = this; var currency_rounding = this.pos.currency.rounding; @@ -609,6 +613,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal var taxes_ids = product.taxes_id; var taxes = self.pos.taxes; var taxtotal = 0; + var taxdetail = {}; _.each(taxes_ids, function(el) { var tax = _.detect(taxes, function(t) {return t.id === el;}); if (tax.price_include) { @@ -623,6 +628,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal tmp = round_pr(tmp,currency_rounding); taxtotal += tmp; totalNoTax -= tmp; + taxdetail[tax.id] = tmp; } else { var tmp; if (tax.type === "percent") { @@ -635,12 +641,14 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal tmp = round_pr(tmp,currency_rounding); taxtotal += tmp; totalTax += tmp; + taxdetail[tax.id] = tmp; } }); return { "priceWithTax": totalTax, "priceWithoutTax": totalNoTax, "tax": taxtotal, + "taxDetails": taxdetail, }; }, }); @@ -795,6 +803,32 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal return sum + orderLine.get_tax(); }), 0); }, + getTaxDetails: function(){ + var details = {}; + var fulldetails = []; + var taxes_by_id = {}; + + for(var i = 0; i < this.pos.taxes.length; i++){ + taxes_by_id[this.pos.taxes[i].id] = this.pos.taxes[i]; + } + + this.get('orderLines').each(function(line){ + var ldetails = line.get_tax_details(); + for(var id in ldetails){ + if(ldetails.hasOwnProperty(id)){ + details[id] = (details[id] || 0) + ldetails[id]; + } + } + }); + + for(var id in details){ + if(details.hasOwnProperty(id)){ + fulldetails.push({amount: details[id], tax: taxes_by_id[id]}); + } + } + + return fulldetails; + }, getPaidTotal: function() { return (this.get('paymentLines')).reduce((function(sum, paymentLine) { return sum + paymentLine.get_amount(); @@ -866,6 +900,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal total_tax: this.getTax(), total_paid: this.getPaidTotal(), total_discount: this.getDiscountTotal(), + tax_details: this.getTaxDetails(), change: this.getChange(), name : this.getName(), client: client ? client.name : null , diff --git a/addons/point_of_sale/static/src/xml/pos.xml b/addons/point_of_sale/static/src/xml/pos.xml index 70756a9fecd..e1694f8cf34 100644 --- a/addons/point_of_sale/static/src/xml/pos.xml +++ b/addons/point_of_sale/static/src/xml/pos.xml @@ -636,18 +636,32 @@
- - - - + + + + + + + + + + + + + + + + + +
Subtotal: - -
Tax: - -
Discount: - -
Total: - -
Subtotal: + +
+ +
Discount: + +
Total: + +

@@ -663,7 +677,7 @@
Change: - +