This commit is contained in:
seb
2026-09-30 22:37:40 +02:00
parent 3d2f8e9296
commit 74ed74fc68
19 changed files with 122 additions and 56 deletions

View File

@@ -82,18 +82,18 @@ export default function adjust(provider) {
if (rawWhId == null) {
throw new Error(`Warehouse required${itemLabel} (${sku})`);
}
const warehouseId = Number(rawWhId);
if (!Number.isInteger(warehouseId) || warehouseId <= 0) {
if (typeof rawWhId !== 'number' || !Number.isInteger(rawWhId) || rawWhId <= 0) {
throw new Error(`Warehouse must be a positive integer${itemLabel} (${sku})`);
}
const warehouseId = rawWhId;
if (line.amount == null) {
throw new Error(`Amount required${itemLabel} (${sku})`);
}
const amount = Number(line.amount);
if (!Number.isFinite(amount) || amount === 0) {
if (typeof line.amount !== 'number' || !Number.isFinite(line.amount) || line.amount === 0) {
throw new Error(`Invalid amount${itemLabel} (${sku}): must be non-zero number`);
}
const amount = line.amount;
const text = (line.text ?? line.transactionText ?? line.transaction_text ?? defaultText)?.trim?.() ||
(amount > 0 ? `Manual stock addition (+${amount})` : `Manual stock removal (${amount})`);