feat(POS-FIX-7): completed feature

This commit is contained in:
chattie
2026-08-24 07:23:55 +02:00
parent cd2a8ab54d
commit 2467a02dd4
14 changed files with 305 additions and 81 deletions

View File

@@ -1336,7 +1336,7 @@ export async function registerPosRoutes(app: FastifyInstance, deps: PosRouteDeps
cashSessionId: { type: 'string', format: 'uuid' },
terminalId: { type: 'string', format: 'uuid' },
items: { type: 'array', minItems: 1, items: { type: 'object' } },
payments: { type: 'array', minItems: 1, items: { type: 'object' } },
payments: { type: 'array', minItems: 0, items: { type: 'object' } },
customerId: { type: 'string', format: 'uuid' },
},
},
@@ -1387,7 +1387,7 @@ export async function registerPosRoutes(app: FastifyInstance, deps: PosRouteDeps
cashSessionId: z.string().uuid(),
terminalId: z.string().uuid(),
items: z.array(z.union([freeLine, stockLine])).min(1),
payments: z.array(payment).min(1),
payments: z.array(payment).min(0),
customerId: z.string().uuid().optional(),
}),
request.body ?? {},

View File

@@ -51,8 +51,9 @@ export function validatePaymentAllocations(
inputs: PosPaymentInput[],
methods: ConfiguredPaymentMethod[],
): ValidatedPayment[] {
// Zero payments are allowed — creates a parked/pending sale with full outstanding balance.
if (inputs.length === 0) {
throw new AppError(400, 'POS_PAYMENT_REQUIRED', 'Selecciona al menos una forma de pago');
return [];
}
const byCode = new Map(methods.map((method) => [method.code, method]));
const validated = inputs.map((input) => {