|
@ -4,22 +4,24 @@ const Registries = require('point_of_sale.Registries'); |
|
|
const { Gui } = require('point_of_sale.Gui'); |
|
|
const { Gui } = require('point_of_sale.Gui'); |
|
|
|
|
|
|
|
|
export const PosZeroQuantityRestrictProductScreen = (ProductScreen) => |
|
|
export const PosZeroQuantityRestrictProductScreen = (ProductScreen) => |
|
|
class extends ProductScreen { |
|
|
class extends ProductScreen { |
|
|
//@override
|
|
|
//@override
|
|
|
async _onClickPay() { |
|
|
async _onClickPay() { |
|
|
for (var i = 0; i < this.env.pos.get_order().orderlines.length; i++) { |
|
|
const orderLines = this.env.pos.get_order().orderlines; |
|
|
// get orderline quantity
|
|
|
for (let i = 0; i < orderLines.length; i++) { |
|
|
var qty = this.env.pos.get_order().orderlines[this.env.pos.get_order().orderlines.length - 1].quantity |
|
|
const qty = orderLines[i].quantity; |
|
|
if (qty !== 0){ |
|
|
if (qty === 0) { |
|
|
await super._onClickPay(...arguments); |
|
|
// Do not confirm the order and show error popup
|
|
|
}else { |
|
|
Gui.showPopup('ErrorPopup', { |
|
|
// do not confirm the order and show error popup;
|
|
|
title: 'Zero quantity not allowed', |
|
|
Gui.showPopup('ErrorPopup', { |
|
|
body: 'Only a positive quantity is allowed for confirming the order', |
|
|
title: ('Zero quantity not allowed'), |
|
|
}); |
|
|
body: ('Only a positive quantity is allowed for confirming the order') |
|
|
return; // Exit the loop and do not proceed with confirming the order
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
}; |
|
|
} |
|
|
Registries.Component.extend(ProductScreen, PosZeroQuantityRestrictProductScreen); |
|
|
// If all order lines have a positive quantity, call the original _onClickPay method
|
|
|
|
|
|
await super._onClickPay(...arguments); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Registries.Component.extend(ProductScreen, PosZeroQuantityRestrictProductScreen); |
|
|