Commit 5c23432c by Yvon

lacagette_mona : take into account mona to block excessive total_received on…

lacagette_mona : take into account mona to block excessive total_received on meal voucher payement lines
parent 61c405a9
......@@ -118,6 +118,44 @@ odoo.define("lacagette_mona.screens", function (require) {
this.inputbuffer = "";
}
}
//The following block is also in pos_meal_voucher with one difference :
//total_eligible takes into account mona (pos_meal_voucher is blind to mona so it can not catch all excess)
//At first, I was afraid there could be a double alert window popping in case
//the amount received is "above the blind range of the pos_meal_voucher", but
//fortunately the behavior is exactly the one we want with the popup of pos_meal_voucher
//being overwritten by the one of mona module
if(order.selected_paymentline && order.selected_paymentline.is_dematerialized_meal_voucher()){
var total_eligible = order.get_total_meal_vouchers_eligible_including_mona();
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 there is change -> the amount of last payment line was above the order remaining due amount
let order_change = order.get_change();
if (order_change > 0) {
let last_line_amount = order.selected_paymentline.get_amount();
let limit_amount = round_pr(last_line_amount - order_change, this.pos.currency.rounding)
current_max = Math.min(current_max, limit_amount);
}
if (total_received > current_max){
this.gui.show_popup("alert", {
'title': _t("Meal Voucher Amount incorrect"),
'body': _t("Le montant saisi est supérieur au maximum éligible/au montant restant dû de ") +
this.format_currency(current_max),
});
const max_current_amount = current_max-total_received+order.selected_paymentline.get_amount() ;
order.selected_paymentline.set_amount(max_current_amount);
this.order_changes();
this.render_paymentlines();
this.$('.paymentline.selected .edit').text(this.format_currency_no_symbol(max_current_amount));
this.inputbuffer = "";
}
}
},
});
});
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