Commit 5db467b0 by Etienne Freiss

display a popup if the meal voucher was already scan on this order

parent 4183965e
...@@ -316,3 +316,24 @@ msgstr " ) est inférieur à la valeur du/des ticket(s)( " ...@@ -316,3 +316,24 @@ msgstr " ) est inférieur à la valeur du/des ticket(s)( "
#, python-format #, python-format
msgid "Warning, the input amount of meal voucher is above the maximum amount of " 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 " msgstr "Le montant saisi est supérieur au montant maximum/au maximum éligible de "
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid "Meal Voucher already used"
msgstr "Ticket restaurant déjà scanné"
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid "The paper meal voucher "
msgstr "Le ticket restaurant "
#. module: pos_meal_voucher
#. openerp-web
#: code:addons/pos_meal_voucher/static/src/js/screens.js:
#, python-format
msgid " was already used"
msgstr " a déjà été scanné"
\ No newline at end of file
...@@ -17,6 +17,14 @@ odoo.define("pos_meal_voucher.models", function (require) { ...@@ -17,6 +17,14 @@ odoo.define("pos_meal_voucher.models", function (require) {
var OrderSuper = models.Order.prototype; var OrderSuper = models.Order.prototype;
var Order = models.Order.extend({ var Order = models.Order.extend({
paper_meal_vouche_number_already_used: function(meal_voucher_number){
for(const paiementLine of this.get_paymentlines()){
if(paiementLine.statement_note == meal_voucher_number) return true
}
return false;
},
get_total_meal_voucher_eligible: function() { get_total_meal_voucher_eligible: function() {
return round_pr(this.orderlines.reduce((function(sum, orderLine) { return round_pr(this.orderlines.reduce((function(sum, orderLine) {
if (orderLine.product.meal_voucher_ok && orderLine.get_price_with_tax() > 0){ if (orderLine.product.meal_voucher_ok && orderLine.get_price_with_tax() > 0){
......
...@@ -13,6 +13,8 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -13,6 +13,8 @@ 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 oder = this.pos.get_order();
if(!oder.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.
if (this.pos.gui.current_screen.template !== "PaymentScreenWidget"){ if (this.pos.gui.current_screen.template !== "PaymentScreenWidget"){
this.gui.show_screen("payment"); this.gui.show_screen("payment");
...@@ -40,6 +42,17 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -40,6 +42,17 @@ odoo.define("pos_meal_voucher.screens", function (require) {
paymentScreen.order_changes(); paymentScreen.order_changes();
paymentScreen.render_paymentlines(); paymentScreen.render_paymentlines();
paymentScreen.$(".paymentline.selected .edit").text(paymentScreen.format_currency_no_symbol(amount)); paymentScreen.$(".paymentline.selected .edit").text(paymentScreen.format_currency_no_symbol(amount));
}else{
this.gui.show_popup("alert", {
'title': _t("Meal Voucher Amount already used"),
'body': _t("The paper meal voucher ") +
code.code + _t(" was already used"),
});
}
}, },
// Setup the callback action for the "meal_voucher_payment" barcodes. // Setup the callback action for the "meal_voucher_payment" barcodes.
...@@ -97,7 +110,6 @@ odoo.define("pos_meal_voucher.screens", function (require) { ...@@ -97,7 +110,6 @@ odoo.define("pos_meal_voucher.screens", function (require) {
var paymentScreen = this.pos.gui.current_screen; var paymentScreen = this.pos.gui.current_screen;
var order = this.pos.get_order(); var order = this.pos.get_order();
if(order.selected_paymentline.is_dematerialized_meal_voucher()){ if(order.selected_paymentline.is_dematerialized_meal_voucher()){
var total_eligible = order.get_total_meal_voucher_eligible(); var total_eligible = order.get_total_meal_voucher_eligible();
var total_received = order.get_total_meal_voucher_received(); var total_received = order.get_total_meal_voucher_received();
......
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