Commit 1bb05c97 by Etienne Freiss

Merge branch 'meal-vouchers' of…

Merge branch 'meal-vouchers' of https://gl.cooperatic.fr/cooperatic-foodcoops/odoo into 2144-check-if-meal-voucher-amount-is-relevant
parents 56ebb334 460c0821
......@@ -312,3 +312,7 @@ msgstr "Attention, le montant éligible au paiement par titre restaurant( "
#, python-format
msgid " ) is under the amount input ( "
msgstr " ) est inférieur à la valeur du/des ticket(s)( "
#: 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 "
......@@ -89,6 +89,38 @@ odoo.define("pos_meal_voucher.screens", function (require) {
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() {
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