[FIX] point_of_sale: check payment amount

In the pos one cannot make a payment that is larger than the
required amount if there is no cash payment option.
In order to check this there is a condition in the `payment_screen`.
The problem is that this condition fails to spot certain cases.

Steps to reproduce:
- open a pos that has only one payment method and this method is `bank`;
- buy an item for 10 $;
- try to pay 11 $;
- notice error popup; ( this is the expected behaviour )
- now try to create another payment line for any amount ( ex 9999 $ )
- as this is a different payment line the error popup will not appear;
--> this is wrong

In this commit we change the condition such that it detects this type of
error too.

closes odoo/odoo#141778

Signed-off-by: Adrien Guilliams (adgu) <adgu@odoo.com>
This commit is contained in:
vlst
2023-11-13 16:17:54 +00:00
parent 631dea3998
commit b8e62185c4
@@ -156,7 +156,6 @@ export class PaymentScreen extends Component {
);
if (
!hasCashPaymentMethod &&
this.currentOrder.get_due() + this.selectedPaymentLine.amount > 0 &&
amount > this.currentOrder.get_due() + this.selectedPaymentLine.amount
) {
this.selectedPaymentLine.set_amount(0);
@@ -272,9 +271,9 @@ export class PaymentScreen extends Component {
this.currentOrder.finalized = true;
// 1. Save order to server.
this.env.services.ui.block()
this.env.services.ui.block();
const syncOrderResult = await this.pos.push_single_order(this.currentOrder);
this.env.services.ui.unblock()
this.env.services.ui.unblock();
if (syncOrderResult instanceof ConnectionLostError) {
this.pos.showScreen(this.nextScreen);