Commit aa009959 by François C.

Merge branch '3343-display-popup-when-meal-voucher-max-amount-reached' into 'dev_cooperatic'

display popup when meal voucher max amount reached

See merge request !43
parents 618733d4 0beba25a
...@@ -13,7 +13,6 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -13,7 +13,6 @@ odoo.define("pos_meal_voucher.screens", function (require) {
screens.ScreenWidget.include({ screens.ScreenWidget.include({
barcode_meal_voucher_payment_action: function (code) { barcode_meal_voucher_payment_action: function (code) {
var order = this.pos.get_order(); var order = this.pos.get_order();
if(!order.paper_meal_vouche_number_already_used(code.code)){ if(!order.paper_meal_vouche_number_already_used(code.code)){
// Display the payment screen, if it is not the current one. // Display the payment screen, if it is not the current one.
...@@ -21,8 +20,29 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -21,8 +20,29 @@ odoo.define("pos_meal_voucher.screens", function (require) {
this.gui.show_screen("payment"); this.gui.show_screen("payment");
} }
var paymentScreen = this.pos.gui.current_screen; var paymentScreen = this.pos.gui.current_screen;
var order = this.pos.get_order();
var amount = code.value; var amount = code.value;
// Check if the total amount is OK regarding to max amounts
var total_eligible = order.get_total_meal_voucher_eligible();
var max_amount = this.pos.config.max_meal_voucher_amount;
var total_received = order.get_total_meal_voucher_received() + amount;
// Display info popup if amount is too high
if (total_received > total_eligible) {
this.gui.show_popup("alert", {
'title': _t("Impossible d'utiliser ce Titre Restaurant"),
'body': _t("Vous ne pouvez pas ajouter ce ticket restaurant car le montant total est supérieur au montant éligible en titres restaurant")
});
return;
}
if (total_received > max_amount && max_amount > 0) {
this.gui.show_popup("alert", {
'title': _t("Impossible d'utiliser ce Titre Restaurant"),
'body': _t("Vous ne pouvez pas ajouter ce ticket restaurant car le montant total est supérieur au montant maximum autorisé")
});
return;
}
var cashregister = null; var cashregister = null;
// find a meal voucher cash register, if exist // find a meal voucher cash register, if exist
for ( var i = 0; i < this.pos.cashregisters.length; i++ ) { for ( var i = 0; i < this.pos.cashregisters.length; i++ ) {
...@@ -46,14 +66,11 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -46,14 +66,11 @@ odoo.define("pos_meal_voucher.screens", function (require) {
}else{ }else{
this.gui.show_popup("alert", { this.gui.show_popup("alert", {
'title': _t("Meal Voucher Amount already used"), 'title': _t("Titre restaurant déjà scanné"),
'body': _t("The paper meal voucher ") + 'body': _t("Le ticket restaurant ") +
code.code + _t(" was already used"), code.code + _t(" a déjà été scanné")
}); });
} }
}, },
// Setup the callback action for the "meal_voucher_payment" barcodes. // Setup the callback action for the "meal_voucher_payment" barcodes.
...@@ -287,8 +304,8 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -287,8 +304,8 @@ odoo.define("pos_meal_voucher.screens", function (require) {
// Open a popup asking for the number of the meal voucher // Open a popup asking for the number of the meal voucher
if(order.selected_paymentline.is_meal_voucher() && order.selected_paymentline.is_paper_meal_voucher()){ if(order.selected_paymentline.is_meal_voucher() && order.selected_paymentline.is_paper_meal_voucher()){
this.gui.show_popup("textinput", { this.gui.show_popup("textinput", {
'title': _t("Meal Voucher ticket"), 'title': _t("Chèque Restaurant"),
'body': _t("To add a meal voucher ticket close this window and scan the ticket. If the ticket can't be read please enter the code"), 'body': _t("Pour ajouter un chèque restaurant, merci de scanner le code barre du chèque. Si le chèque est illisible, veuillez rentrer le code à la main."),
confirm: function(value) { confirm: function(value) {
this.pos.get_order().remove_paymentline(order.selected_paymentline); this.pos.get_order().remove_paymentline(order.selected_paymentline);
var paymentScreen = this.pos.gui.current_screen; var paymentScreen = this.pos.gui.current_screen;
......
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