Commit 0b42a4c6 by Thibault Grandjean

hide meal voucher if it's not activated

parent 59273361
...@@ -67,9 +67,29 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -67,9 +67,29 @@ odoo.define("pos_meal_voucher.screens", function (require) {
screens.OrderWidget.include({ screens.OrderWidget.include({
meal_voucher_activated: function() {
var payment_methods = this.pos.cashregisters.map(
function(method) {
return method.journal_id[1]
}
);
var is_meal_voucher_method = payment_methods.map(
function(method_name) {
var regex = new RegExp('Déj')
return regex.test(method_name)
}
);
return is_meal_voucher_method.includes(true);
},
update_summary: function () { update_summary: function () {
this._super.apply(this, arguments); this._super.apply(this, arguments);
var order = this.pos.get_order(); var order = this.pos.get_order();
if (!this.meal_voucher_activated()) {
this.el.querySelector(".summary .meal-voucher").style.display = 'none';
return;
}
if (!order.get_orderlines().length) { if (!order.get_orderlines().length) {
return; return;
} }
...@@ -80,6 +100,20 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -80,6 +100,20 @@ odoo.define("pos_meal_voucher.screens", function (require) {
screens.PaymentScreenWidget.include({ screens.PaymentScreenWidget.include({
meal_voucher_activated: function() {
var payment_methods = this.pos.cashregisters.map(
function(method) {
return method.journal_id[1]
}
);
var is_meal_voucher_method = payment_methods.map(
function(method_name) {
var regex = new RegExp('Déj')
return regex.test(method_name)
}
);
return is_meal_voucher_method.includes(true);
},
// odoo/addons/point_of_sale/static/src/js/screens.js // odoo/addons/point_of_sale/static/src/js/screens.js
// We need to change the default behaviour of locking input with // We need to change the default behaviour of locking input with
...@@ -296,6 +330,9 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -296,6 +330,9 @@ odoo.define("pos_meal_voucher.screens", function (require) {
if (!order) { if (!order) {
return; return;
} }
var meal_voucher_available = this.meal_voucher_activated();
// Update meal voucher summary // Update meal voucher summary
var total_eligible = order.get_total_meal_voucher_eligible(); var total_eligible = order.get_total_meal_voucher_eligible();
this.el.querySelector("#meal-voucher-eligible-amount").textContent = this.format_currency(total_eligible); this.el.querySelector("#meal-voucher-eligible-amount").textContent = this.format_currency(total_eligible);
...@@ -319,6 +356,10 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -319,6 +356,10 @@ odoo.define("pos_meal_voucher.screens", function (require) {
this.$("#meal-voucher-max-warning").addClass("oe_hidden"); this.$("#meal-voucher-max-warning").addClass("oe_hidden");
} }
if (!this.meal_voucher_activated()) {
this.$(".meal-voucher-summary").addClass("oe_hidden");
}
}, },
order_is_valid: function(force_validation) { order_is_valid: function(force_validation) {
......
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