From 7df6a003dc14f4e943dd12c32d138a3d35142aa8 Mon Sep 17 00:00:00 2001 From: Deploy Date: Wed, 26 Aug 2026 22:31:34 +0200 Subject: [PATCH] fix(pos): physical TPV (cashier) skips inventory check, selfpay still validates --- project/src/modules/pos/application/create-pos-sale.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/project/src/modules/pos/application/create-pos-sale.ts b/project/src/modules/pos/application/create-pos-sale.ts index 50ea321..7012d94 100644 --- a/project/src/modules/pos/application/create-pos-sale.ts +++ b/project/src/modules/pos/application/create-pos-sale.ts @@ -174,6 +174,8 @@ export class CreatePosSaleUseCase { throw new AppError(400, 'POS_EMPTY_CART', 'El carrito está vacío'); const lineDiscountsEnabled = session.terminal_settings?.lineDiscountsEnabled !== false; + // POS-FIX-12: physical TPV (cashier) trusts real stock — skip inventory check + const selfpayMode = session.terminal_settings?.selfpayMode === true; let subtotalCents = 0; let discountCents = 0; let taxCents = 0; @@ -246,7 +248,10 @@ export class CreatePosSaleUseCase { FOR UPDATE`, [catalog.variant_id, session.store_id], ); - if (Number(stock.rows[0]?.available ?? 0) < inputItem.quantity) { + const availableStock = Number(stock.rows[0]?.available ?? 0); + // POS-FIX-12: only selfpay terminals validate against inventory_stock. + // Physical (cashier) TPV trusts real stock — the count is allowed to drift. + if (selfpayMode && availableStock < inputItem.quantity) { throw new AppError( 409, 'POS_STOCK_UNAVAILABLE',