Browse Source

[ADD] POS with tax addon

pull/33/head
Antonio Espinosa 10 years ago
parent
commit
76a6af8b23
  1. 38
      pos_with_tax/README.rst
  2. 24
      pos_with_tax/__init__.py
  3. 43
      pos_with_tax/__openerp__.py
  4. 38
      pos_with_tax/i18n/es.po
  5. 38
      pos_with_tax/i18n/pos_with_tax.pot
  6. BIN
      pos_with_tax/static/description/icon.png
  7. 148
      pos_with_tax/static/src/js/main.js
  8. 20
      pos_with_tax/static/src/xml/pos.xml
  9. 13
      pos_with_tax/views/pos_template.xml
  10. 12
      pos_with_tax/views/report_receipt_view.xml

38
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 <antonioea@antiun.com>
* Endika Iglesias <endikaig@antiun.com>
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.

24
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 <endikaig@antiun.com>
# Antonio Espinosa <antonioea@antiun.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################

43
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 <endikaig@antiun.com>
# Antonio Espinosa <antonioea@antiun.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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,
}

38
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"

38
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"

BIN
pos_with_tax/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 13 KiB

148
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 <antonioea@antiun.com>
* # Endika Iglesias <endikaig@antiun.com>
* #
* # 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 <http://www.gnu.org/licenses/>.
* #
* ##############################################################################
*/
// 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);

20
pos_with_tax/static/src/xml/pos.xml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="Product">
<t t-jquery=".product-img" t-operation="replace">
<div class="product-img">
<img t-att-src='image_url' />
<t t-if="!product.to_weight">
<span class="price-tag">
<t t-esc="widget.format_currency(widget.get_product_price_with_tax(product),'Product Price')"/>
</span>
</t>
<t t-if="product.to_weight">
<span class="price-tag">
<t t-esc="widget.format_currency(widget.get_product_price_with_tax(product),'Product Price')+'/Kg'"/>
</span>
</t>
</div>
</t>
</t>
</templates>

13
pos_with_tax/views/pos_template.xml

@ -0,0 +1,13 @@
<openerp>
<data>
<template id="pos_with_tax_backend"
name="pos_with_tax_backend"
inherit_id="point_of_sale.assets_backend">
<xpath expr="." position="inside">
<script src="/pos_with_tax/static/src/js/main.js"
type="text/javascript"></script>
</xpath>
</template>
</data>
</openerp>

12
pos_with_tax/views/report_receipt_view.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="pos_with_tax_report_receipt"
inherit_id="point_of_sale.report_receipt">
<xpath expr="//div/table[@class='table table-condensed']/tbody/tr/td[@class='text-right'][2]/t[1]/span"
position="attributes">
<attribute name="t-esc">formatLang(line.price_subtotal_incl, currency_obj=res_company.currency_id)</attribute>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save