fix(pos): physical TPV (cashier) skips inventory check, selfpay still validates

This commit is contained in:
Deploy
2026-08-26 22:31:34 +02:00
parent 169e3e0c10
commit 7df6a003dc

View File

@@ -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',