Commit 460c0821 by Damien Moulard

Merge branch '2158-check-if-meal-voucher-card-amount-is-relevant' into 'meal-vouchers'

2158 check if meal voucher card amount is relevant

See merge request !23
parents 7cd0bdea f8e9aea7
...@@ -292,3 +292,9 @@ msgstr "En cliquant sur ce bouton, tous les produits de cette catégories auront ...@@ -292,3 +292,9 @@ msgstr "En cliquant sur ce bouton, tous les produits de cette catégories auront
msgid "kg" msgid "kg"
msgstr "kg" msgstr "kg"
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:110
#, python-format
msgid "Warning, the input amount of meal voucher is above the maximum amount of "
msgstr "Le montant saisi est supérieur au montant maximum/au maximum éligible de "
\ No newline at end of file
...@@ -89,6 +89,38 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -89,6 +89,38 @@ odoo.define("pos_meal_voucher.screens", function (require) {
return methods; return methods;
}, },
payment_input: function() {
var self = this;
this._super.apply(this, arguments);
var order = this.pos.get_order();
if(order.selected_paymentline.is_meal_voucher()){
var total_eligible = order.get_total_meal_voucher_eligible();
var total_received = order.get_total_meal_voucher_received();
var max_amount = this.pos.config.max_meal_voucher_amount;
var current_max = total_eligible;
if (max_amount) {
current_max = Math.min(total_eligible, max_amount);
}
if (total_received > current_max){
this.gui.show_popup("alert", {
'title': _t("Meal Voucher Amount incorrect"),
'body': _t("Warning, the input amount of meal voucher is above the maximum amount of ") +
this.format_currency(current_max),
});
const max_curent_amount = current_max-total_received+order.selected_paymentline.get_amount() ;
order.selected_paymentline.set_amount(max_curent_amount);
this.order_changes();
this.render_paymentlines();
this.$('.paymentline.selected .edit').text(this.format_currency_no_symbol(max_curent_amount));
this.inputbuffer = "";
}
}
},
render_paymentlines: function() { render_paymentlines: function() {
var self = this; var self = this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment