Commit 06790de1 by François C.

Merge branch '4704-envoi-montant-eligible-au-tpe' into 'dev_cooperatic'

a quick solution to compute meal voucher amount before sending it to tpe if…

See merge request !60
parents 2a9fa667 ca720dd5
......@@ -61,6 +61,21 @@ odoo.define('pos_payment_terminal.pos_payment_terminal', function (require) {
var order = this.pos.get_order();
var line = order.selected_paymentline;
var data = self.get_data_send(order, line, currency_iso);
//Special case of meal voucher payement line :
if(line.is_meal_voucher && line.is_meal_voucher()) { //Make sure function exists (module meal_voucher might not be active)
//TODO : factor (already 3 occurences of this code in pos_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();
data["amount"] = round_pr(Math.max(0,max_curent_amount), this.pos.currency.rounding);
}
if (this.wait_terminal_answer()) {
screen.$('.delete-button').css('display', 'none');
this.message('payment_terminal_transaction_start_with_return', {'payment_info' : JSON.stringify(data)}, { timeout: 240000 }).then(function (answer) {
......
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