Skip to content

Commit

Permalink
[ADD] pos_cashback_warning
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Sep 23, 2022
1 parent 0b697c0 commit 659d43a
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 0 deletions.
Empty file added pos_cashback_warning/README.rst
Empty file.
Empty file.
25 changes: 25 additions & 0 deletions pos_cashback_warning/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2022 - Today Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Point of Sale - Cashback Warning",
"version": "12.0.1.0.1",
"category": "Point of Sale",
"author": "GRAP, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"maintainers": ["legalsylvain"],
"depends": [
"point_of_sale",
],
"data": [
"views/templates.xml",
],
"qweb": [
'static/src/xml/pos.xml',
],
"images": [
"static/description/pos_cashback_warning.png",
],
"installable": True,
}
24 changes: 24 additions & 0 deletions pos_cashback_warning/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_cashback_warning
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-09-23 09:41+0000\n"
"PO-Revision-Date: 2022-09-23 09:41+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_cashback_warning
#. openerp-web
#: code:addons/pos_cashback_warning/static/src/xml/pos.xml:11
#, python-format
msgid "This will generate a cashback of"
msgstr "Cela va générer un cashback de"

1 change: 1 addition & 0 deletions pos_cashback_warning/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>
17 changes: 17 additions & 0 deletions pos_cashback_warning/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
This modules extends the Point of sale functionnalies to add a warning
if confirming an order generate a cashback.

By default, if the payment lines of an Odoo PoS order generate Change,
the journal for the change will be the Cash journal.
That is ok if the original payment line is a Cash payment, but if it's
a payment by credit card, check, meal voucher, etc. confirming the
transaction will generate a cashback.

This module simply add a message in such case.

.. image:: ../static/description/pos_cashback_warning.png


**Note** : The cashback is an operation that consists,
for a merchant to collect more money in check, credit card, etc.
than the amount of the sale and give change in cash.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions pos_cashback_warning/static/src/js/screens.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/** ***************************************************************************
Copyright (C) 2022 - Today: GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
******************************************************************************/

odoo.define('pos_cashback_warning.screens', function (require) {
"use strict";

var screens = require("point_of_sale.screens");
var core = require("web.core");
var _t = core._t;

screens.PaymentScreenWidget.include({

render_paymentlines: function() {
var total_cash_received = 0.0
var extradue = 0.0;

var order = this.pos.get_order();
if (order && order.get_total_with_tax() > 0.0) {
// Note Copy from original function render_paymentlines
// to recompute extradue value
var lines = order.get_paymentlines();
var due = order.get_due();
if (due && lines.length && due !== order.get_due(lines[lines.length-1])) {
extradue = due;
}
_.each(lines, function (line) {
console.log("=> line.cashregister.journal.type", line.cashregister.journal.type);
console.log("=> line.amount", line.amount);
if (line.cashregister.journal.type === "cash") {
total_cash_received += line.amount;
}
});
}
if (extradue < 0.0 && (total_cash_received + extradue) < 0.0) {
this.extradue_cashback = - (total_cash_received + extradue);
}
else {
this.extradue_cashback = 0.0;
}
this._super();
},

});
});
17 changes: 17 additions & 0 deletions pos_cashback_warning/static/src/xml/pos.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2022 - Today Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<templates id="template" xml:space="preserve">

<t t-extend="PaymentScreen-Paymentlines">
<t t-jquery=".paymentline.extra" t-operation="append">
<td colspan="4" t-if="widget.extradue_cashback > 0">
<i class='fa fa-warning'></i>
This will generate a cashback of <t t-esc='widget.format_currency_no_symbol(widget.extradue_cashback)'/>
</td>
</t>
</t>

</templates>
13 changes: 13 additions & 0 deletions pos_cashback_warning/views/templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!--
Copyright 2022 - Today Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->

<odoo>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_cashback_warning/static/src/js/screens.js"></script>
</xpath>
</template>
</odoo>
6 changes: 6 additions & 0 deletions setup/pos_cashback_warning/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 659d43a

Please sign in to comment.