Fix: Kots with product quantity = 0 were allowed. So blank kots could be added.
This commit is contained in:
parent
38ccaa167c
commit
8c5d941850
@ -103,7 +103,11 @@ def update_route(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="Happy hour products are not balanced.",
|
||||
)
|
||||
for k in (k for k in data.kots if k.id_ is None and len(k.inventories) > 0):
|
||||
for k in (
|
||||
k
|
||||
for k in data.kots
|
||||
if k.id_ is None and len([i for i in k.inventories if round(i.quantity, 2) != 0]) > 0
|
||||
):
|
||||
need_to_print_kot = True
|
||||
code = db.execute(select(func.coalesce(func.max(Kot.code), 0) + 1)).scalar_one()
|
||||
kot = Kot(item.id, code, item.food_table_id, now, item.user_id)
|
||||
|
@ -237,7 +237,7 @@ export class BillService {
|
||||
printKot(guestBookId: string | null): Observable<boolean> {
|
||||
const item = JSON.parse(JSON.stringify(this.bill));
|
||||
const newKot = this.bill.kots.find((k) => k.id === undefined) as Kot;
|
||||
if (newKot.inventories.length === 0) {
|
||||
if (newKot.inventories.filter((x) => x.quantity !== 0).length === 0) {
|
||||
return throwError('Cannot print a blank KOT\nPlease add some products!');
|
||||
}
|
||||
if (!this.happyHourItemsBalanced() || this.happyHourItemsMoreThanRegular()) {
|
||||
|
Loading…
Reference in New Issue
Block a user