Commit 87d5994b by François C.

Merge branch '2150-auto-complete-cb-meal-voucher-amount' into 'meal-vouchers'

develop

See merge request !22
parents a55cb992 0eee7d82
...@@ -191,6 +191,10 @@ odoo.define("pos_meal_voucher.models", function (require) { ...@@ -191,6 +191,10 @@ odoo.define("pos_meal_voucher.models", function (require) {
this.cashregister.journal.meal_voucher_type) !== -1 this.cashregister.journal.meal_voucher_type) !== -1
); );
}, },
is_dematerialized_meal_voucher: function() {
return (
this.cashregister.journal.meal_voucher_type == "dematerialized") ;
},
}); });
......
...@@ -89,7 +89,36 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -89,7 +89,36 @@ odoo.define("pos_meal_voucher.screens", function (require) {
}); });
return methods; return methods;
}, },
click_paymentmethods: function(id) {
var self = this;
var methods = this._super.apply(this, arguments);
var paymentScreen = this.pos.gui.current_screen;
var order = this.pos.get_order();
if(order.selected_paymentline.is_dematerialized_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);
}
// Check how much is still possible to pay with meal voucher
// The selected line is "by default" set to the rest to pay of the order
const max_curent_amount = current_max-total_received +order.selected_paymentline.get_amount();
order.selected_paymentline.set_amount(max_curent_amount);
paymentScreen.order_changes();
paymentScreen.render_paymentlines();
paymentScreen.$(".paymentline.selected .edit").text(paymentScreen.format_currency_no_symbol(max_curent_amount));
}
},
payment_input: function() { payment_input: function() {
var self = this; var self = this;
...@@ -103,7 +132,6 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -103,7 +132,6 @@ odoo.define("pos_meal_voucher.screens", function (require) {
if (max_amount) { if (max_amount) {
current_max = Math.min(total_eligible, max_amount); current_max = Math.min(total_eligible, max_amount);
} }
if (total_received > current_max){ if (total_received > current_max){
this.gui.show_popup("alert", { this.gui.show_popup("alert", {
'title': _t("Meal Voucher Amount incorrect"), 'title': _t("Meal Voucher Amount incorrect"),
...@@ -122,10 +150,9 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -122,10 +150,9 @@ odoo.define("pos_meal_voucher.screens", function (require) {
} }
}, },
render_paymentlines: function() { render_paymentlines: function() {
var self = this; var self = this;
this._super.apply(this, arguments); this._super.apply(this, arguments);
var order = this.pos.get_order(); var order = this.pos.get_order();
if (!order) { if (!order) {
......
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