diff --git a/pos_with_tax/README.rst b/pos_with_tax/README.rst new file mode 100644 index 00000000..6476aa3d --- /dev/null +++ b/pos_with_tax/README.rst @@ -0,0 +1,38 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: AGPLv3 License + +Point of sale with tax +====================== + +Include tax in price on POS. + +This addons takes care of tax configuration: price_include, showing prices +with tax included even price_include == True or price_include == False + +This helps to shop owner because he can set product prices with taxes +or without taxes, but prices are always shown in POS with taxes + + +Credits +======= + +Contributors +------------ + +* Antonio Espinosa +* Endika Iglesias + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/pos_with_tax/__init__.py b/pos_with_tax/__init__.py new file mode 100644 index 00000000..f3ebd3ec --- /dev/null +++ b/pos_with_tax/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Python source code encoding : https://www.python.org/dev/peps/pep-0263/ +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright : +# (c) 2014 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) +# Endika Iglesias +# Antonio Espinosa +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## diff --git a/pos_with_tax/__openerp__.py b/pos_with_tax/__openerp__.py new file mode 100644 index 00000000..423acdde --- /dev/null +++ b/pos_with_tax/__openerp__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Python source code encoding : https://www.python.org/dev/peps/pep-0263/ +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright : +# (c) 2014 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) +# Endika Iglesias +# Antonio Espinosa +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'Point of sale with tax', + 'category': 'Point Of Sale', + 'version': '1.0', + 'depends': [ + 'point_of_sale', + ], + 'data': [ + 'views/pos_template.xml', + 'views/report_receipt_view.xml', + ], + 'qweb': [ + 'static/src/xml/pos.xml', + ], + 'author': 'Antiun Ingenieria S.L.', + 'website': 'http://www.antiun.com', + 'license': 'AGPL-3', + 'installable': True, +} diff --git a/pos_with_tax/i18n/es.po b/pos_with_tax/i18n/es.po new file mode 100644 index 00000000..ba48c99e --- /dev/null +++ b/pos_with_tax/i18n/es.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_with_tax +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-06-08 11:11+0000\n" +"PO-Revision-Date: 2015-06-08 11:11+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_with_tax +#. openerp-web +#: code:addons/pos_with_tax/static/src/js/models.js:98 +#, python-format +msgid "Connecting to the PosBox" +msgstr "Conectando a PosBox" + +#. module: pos_with_tax +#. openerp-web +#: code:addons/pos_with_tax/static/src/js/models.js:240 +#, python-format +msgid "Error: The Point of Sale User must belong to the same company as the Point of Sale. You are probably trying to load the point of sale as an administrator in a multi-company setup, with the administrator account set to the wrong company." +msgstr "Error: El Usuario del terminal de punto de venta debe pertenecer a la misma empresa que el punto de venta. Usted probablemente está intentando cargar el punto de venta como administrador en una configuración multi-empresa, con la cuenta de administrador se establece en la compañía equivocada." + +#. module: pos_with_tax +#. openerp-web +#: code:addons/pos_with_tax/static/src/js/models.js:120 +#: code:addons/pos_with_tax/static/src/js/models.js:403 +#, python-format +msgid "Loading" +msgstr "Cargando" \ No newline at end of file diff --git a/pos_with_tax/i18n/pos_with_tax.pot b/pos_with_tax/i18n/pos_with_tax.pot new file mode 100644 index 00000000..5f8492e4 --- /dev/null +++ b/pos_with_tax/i18n/pos_with_tax.pot @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_with_tax +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-06-08 11:11+0000\n" +"PO-Revision-Date: 2015-06-08 11:11+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: pos_with_tax +#. openerp-web +#: code:addons/pos_with_tax/static/src/js/models.js:98 +#, python-format +msgid "Connecting to the PosBox" +msgstr "Connecting to the PosBox" + +#. module: pos_with_tax +#. openerp-web +#: code:addons/pos_with_tax/static/src/js/models.js:240 +#, python-format +msgid "Error: The Point of Sale User must belong to the same company as the Point of Sale. You are probably trying to load the point of sale as an administrator in a multi-company setup, with the administrator account set to the wrong company." +msgstr "Error: The Point of Sale User must belong to the same company as the Point of Sale. You are probably trying to load the point of sale as an administrator in a multi-company setup, with the administrator account set to the wrong company." + +#. module: pos_with_tax +#. openerp-web +#: code:addons/pos_with_tax/static/src/js/models.js:120 +#: code:addons/pos_with_tax/static/src/js/models.js:403 +#, python-format +msgid "Loading" +msgstr "Loading" \ No newline at end of file diff --git a/pos_with_tax/static/description/icon.png b/pos_with_tax/static/description/icon.png new file mode 100644 index 00000000..89cd1bfe Binary files /dev/null and b/pos_with_tax/static/description/icon.png differ diff --git a/pos_with_tax/static/src/js/main.js b/pos_with_tax/static/src/js/main.js new file mode 100644 index 00000000..594125c7 --- /dev/null +++ b/pos_with_tax/static/src/js/main.js @@ -0,0 +1,148 @@ +/** + * # -*- coding: utf-8 -*- + * ############################################################################## + * # + * # OpenERP, Open Source Management Solution + * # This module copyright : + * # (c) 2014 Antiun Ingenieria, SL (Madrid, Spain, http://www.antiun.com) + * # Antonio Espinosa + * # Endika Iglesias + * # + * # This program is free software: you can redistribute it and/or modify + * # it under the terms of the GNU Affero General Public License as + * # published by the Free Software Foundation, either version 3 of the + * # License, or (at your option) any later version. + * # + * # This program is distributed in the hope that it will be useful, + * # but WITHOUT ANY WARRANTY; without even the implied warranty of + * # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * # GNU Affero General Public License for more details. + * # + * # You should have received a copy of the GNU Affero General Public License + * # along with this program. If not, see . + * # + * ############################################################################## + */ + +// Check jQuery available +if (typeof jQuery === 'undefined') { throw new Error('POS with tax Addon requires jQuery') } + ++function ($) { + 'use strict'; + + openerp.pos_with_tax = function (instance) { + var _t = instance.web._t, + _lt = instance.web._lt; + var QWeb = instance.web.qweb; + + var round_pr = instance.web.round_precision; + + instance.point_of_sale.ProductListWidget.include({ + compute_all: function(taxes, price_unit) { + var self = this; + var res = []; + var tmp = 0; + var data = {}; + var currency_rounding = this.pos.currency.rounding; + if (this.pos.company.tax_calculation_rounding_method == "round_globally"){ + currency_rounding = currency_rounding * 0.00001; + } + var base = price_unit; + _(taxes).each(function(tax) { + if (tax.price_include) { + if (tax.type === "percent") { + tmp = round_pr(base - round_pr(base / (1 + tax.amount),currency_rounding),currency_rounding); + data = {amount:tmp, price_include:true, id: tax.id}; + res.push(data); + } else if (tax.type === "fixed") { + tmp = round_pr(tax.amount * self.get_quantity(),currency_rounding); + data = {amount:tmp, price_include:true, id: tax.id}; + res.push(data); + } else { + throw "This type of tax is not supported by the point of sale: " + tax.type; + } + } else { + if (tax.type === "percent") { + tmp = round_pr(tax.amount * base, currency_rounding); + data = {amount:tmp, price_include:false, id: tax.id}; + res.push(data); + } else if (tax.type === "fixed") { + tmp = round_pr(tax.amount * self.get_quantity(), currency_rounding); + data = {amount:tmp, price_include:false, id: tax.id}; + res.push(data); + } else { + throw "This type of tax is not supported by the point of sale: " + tax.type; + } + + var base_amount = data.amount; + var child_amount = 0.0; + if (tax.child_depend) { + res.pop(); // do not use parent tax + child_tax = self.compute_all(tax.child_taxes, base_amount); + res.push(child_tax); + _(child_tax).each(function(child) { + child_amount += child.amount; + }); + } + if (tax.include_base_amount) { + base += base_amount + child_amount; + } + } + }); + return res; + }, + get_product_price_without_tax: function(product){ + return this.get_product_all_prices(product).priceWithoutTax; + }, + get_product_price_with_tax: function(product){ + return this.get_product_all_prices(product).priceWithTax; + }, + get_product_all_prices: function(product){ + var base = round_pr(product.price, this.pos.currency.rounding); + var totalTax = base; + var totalNoTax = base; + var taxtotal = 0; + var taxdetail = {}; + + var taxes_ids = product.taxes_id; + var taxes = this.pos.taxes; + var product_taxes = []; + + _(taxes_ids).each(function(el){ + product_taxes.push(_.detect(taxes, function(t){ + return t.id === el; + })); + }); + + var all_taxes = _(this.compute_all(product_taxes, base)).flatten(); + + _(all_taxes).each(function(tax) { + if (tax.price_include) { + totalNoTax -= tax.amount; + } else { + totalTax += tax.amount; + } + taxtotal += tax.amount; + taxdetail[tax.id] = tax.amount; + }); + + return { + "priceWithTax": totalTax, + "priceWithoutTax": totalNoTax, + "tax": taxtotal, + "taxDetails": taxdetail, + }; + }, + }); + + instance.point_of_sale.Orderline = instance.point_of_sale.Orderline.extend({ + // Show order line prices with taxes included + get_display_price: function(){ + return this.get_price_with_tax(); + }, + }); + + }; + + +}(jQuery); diff --git a/pos_with_tax/static/src/xml/pos.xml b/pos_with_tax/static/src/xml/pos.xml new file mode 100644 index 00000000..54704ea6 --- /dev/null +++ b/pos_with_tax/static/src/xml/pos.xml @@ -0,0 +1,20 @@ + + + + +
+ + + + + + + + + + + +
+
+
+
diff --git a/pos_with_tax/views/pos_template.xml b/pos_with_tax/views/pos_template.xml new file mode 100644 index 00000000..4a7f8986 --- /dev/null +++ b/pos_with_tax/views/pos_template.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/pos_with_tax/views/report_receipt_view.xml b/pos_with_tax/views/report_receipt_view.xml new file mode 100644 index 00000000..f10775cf --- /dev/null +++ b/pos_with_tax/views/report_receipt_view.xml @@ -0,0 +1,12 @@ + + + + + +