diff --git a/pos_round_payment/README.rst b/pos_round_payment/README.rst new file mode 100644 index 00000000..efd69948 --- /dev/null +++ b/pos_round_payment/README.rst @@ -0,0 +1,44 @@ +Point Of Sales Round Payment +============================ + +Allow to round payment method to 5 cents. +You can choose to round only the cash payment or all the payment method. You +need to enable the feature on the payment journal. +Rounding only occurs for B2C (i.e. if partner does not have a VAT number). + +The pos order will be marked as paid with a difference between the total and +paid amount. When reconciling the posted entries after the end of the pos +session, the difference must be written on a write-off account. + +Installation +============ + +To install this module, you just need to select the module and insure yourself dependencies are available. + +Configuration +============= + +No configuration to use this module. + +Credits +======= + +Contributors +------------ + +* Jacques-Etienne Baudoux (BCIM sprl) + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://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_round_payment/__init__.py b/pos_round_payment/__init__.py new file mode 100644 index 00000000..aee8895e --- /dev/null +++ b/pos_round_payment/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/pos_round_payment/__openerp__.py b/pos_round_payment/__openerp__.py new file mode 100644 index 00000000..2ecbcf6b --- /dev/null +++ b/pos_round_payment/__openerp__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Jacques-Etienne Baudoux (BCIM sprl) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': "pos_round_payment", + 'version': '1.0', + 'category': 'Point Of Sale', + 'author': "BCIM", + 'website': "https://www.bcim.be", + 'depends': [ + 'point_of_sale', + ], + 'data': [ + 'views/account_journal.xml', + 'reports/pos_receipt.xml', + ], + 'installable': True, + 'auto_install': False, + 'license': 'AGPL-3', +} diff --git a/pos_round_payment/i18n/fr.po b/pos_round_payment/i18n/fr.po new file mode 100644 index 00000000..9fd12878 --- /dev/null +++ b/pos_round_payment/i18n/fr.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_round_payment +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-11-30 23:35+0000\n" +"PO-Revision-Date: 2019-11-30 23:35+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_round_payment +#: field:account.journal,round_payment:0 +msgid "Round Payment to 5 cents" +msgstr "Arrondir le paiement à 5 centimes" + +#. module: pos_round_payment +#: view:website:point_of_sale.report_receipt +msgid "Rounded" +msgstr "Arrondi" + diff --git a/pos_round_payment/models/__init__.py b/pos_round_payment/models/__init__.py new file mode 100644 index 00000000..92d74edd --- /dev/null +++ b/pos_round_payment/models/__init__.py @@ -0,0 +1,2 @@ +from . import account_journal +from . import pos_order diff --git a/pos_round_payment/models/account_journal.py b/pos_round_payment/models/account_journal.py new file mode 100644 index 00000000..53a5692f --- /dev/null +++ b/pos_round_payment/models/account_journal.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Jacques-Etienne Baudoux (BCIM sprl) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import models, fields + + +class AccountJournal(models.Model): + _inherit = 'account.journal' + + round_payment = fields.Boolean('Round Payment to 5 cents') diff --git a/pos_round_payment/models/pos_order.py b/pos_round_payment/models/pos_order.py new file mode 100644 index 00000000..48ee264b --- /dev/null +++ b/pos_round_payment/models/pos_order.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Jacques-Etienne Baudoux (BCIM sprl) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import api, models, fields + + +class PosOrder(models.Model): + _inherit = "pos.order" + + @api.multi + def test_paid(self): + """A Point of Sale is paid when the sum + @return: True + """ + for order in self: + if order.lines and not order.amount_total: + return True + if not order.lines: + return False + if not order.statement_ids: + return False + amount = abs(order.amount_total-order.amount_paid) + if any(order.statement_ids.mapped('journal_id.round_payment')): + test = 0.021 + else: + test = 0.009 + if amount >= test: + return False + return True diff --git a/pos_round_payment/reports/pos_receipt.xml b/pos_round_payment/reports/pos_receipt.xml new file mode 100644 index 00000000..63af1ae4 --- /dev/null +++ b/pos_round_payment/reports/pos_receipt.xml @@ -0,0 +1,17 @@ + + + + + + diff --git a/pos_round_payment/views/account_journal.xml b/pos_round_payment/views/account_journal.xml new file mode 100644 index 00000000..9c856129 --- /dev/null +++ b/pos_round_payment/views/account_journal.xml @@ -0,0 +1,15 @@ + + + + + POS Round Payment + account.journal + + + + + + + + + diff --git a/pos_round_payment/wizards/__init__.py b/pos_round_payment/wizards/__init__.py new file mode 100644 index 00000000..9355191c --- /dev/null +++ b/pos_round_payment/wizards/__init__.py @@ -0,0 +1 @@ +from . import pos_payment diff --git a/pos_round_payment/wizards/pos_payment.py b/pos_round_payment/wizards/pos_payment.py new file mode 100644 index 00000000..ee56665a --- /dev/null +++ b/pos_round_payment/wizards/pos_payment.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Jacques-Etienne Baudoux (BCIM sprl) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import api, models + + +class PosMakePayment(models.TransientModel): + _inherit = 'pos.make.payment' + + @api.onchange('journal_id') + def onchange_journal(self): + active_id = self.env.context.get('active_id', False) + order = self.env['pos.order'].browse(active_id) + if (not order.partner_id.commercial_partner_id.vat + and self.journal_id.round_payment): + self.amount = round(self.amount * 20) / 20 + else: + self.amount = order.amount_total - order.amount_paid + + @api.multi + def check(self): + """Check the order: + if the order is not paid: continue payment, + if the order is paid print ticket. + """ + active_id = self.env.context.get('active_id', False) + order = self.env['pos.order'].browse(active_id) + + amount = order.amount_total - order.amount_paid + if self.journal_id.round_payment: + amount = round(amount * 20) / 20 + + if amount != 0.0: + data = self.read()[0] + data['journal'] = data['journal_id'][0] + self.pool['pos.order'].add_payment(self._cr, self._uid, active_id, data, self._context) + + if order.test_paid(): + order.signal_workflow('paid') + return self.print_report() + + return self.launch_payment()