This commit is contained in:
seb
2026-10-18 20:29:48 +02:00
parent 5e4cb5a3f8
commit c06a5e3413
9 changed files with 39 additions and 25 deletions

View File

@@ -169,8 +169,10 @@ function deliveryErrorStatus(error) {
if (error.message === 'File not found') return 404;
if (error.message === 'Supplier not found') return 404;
if (error.message === 'Warehouse not found') return 404;
if (error.message === 'No supplier selected') return 400;
if (error.message === 'Invalid supplierId') return 400;
if (error.message === 'Article not found') return 404;
if (error.message === 'Delivery number already exists') return 409;
if (error.message === 'Invalid delivery') return 400;
if (error.message === 'Invalid lines') return 400;
if (error.message === 'Delivery has no lines') return 400;
@@ -305,7 +307,7 @@ export function register(app, basePath = '') {
* application/json:
* schema:
* type: object
* required: [externalNumber, date, lines]
* required: [externalNumber, date, supplierId, lines]
* properties:
* externalNumber:
* type: string
@@ -315,7 +317,6 @@ export function register(app, basePath = '') {
* format: date-time
* supplierId:
* type: integer
* nullable: true
* lines:
* type: array
* items:
@@ -497,6 +498,9 @@ export function register(app, basePath = '') {
try {
const { externalNumber, date, createdAt, supplierId, lines, files } = parseDeliveryPayload(req);
if (supplierId === undefined || supplierId === null) {
return res.status(400).json({ error: 'No supplier selected' });
}
logDeliveryFiles(files, 'create');
const delivery = await db.create(req.user.id, {
externalNumber,
@@ -795,6 +799,9 @@ export function register(app, basePath = '') {
patch.createdAt = parsed.createdAt;
}
if (Object.prototype.hasOwnProperty.call(parsed.payload, 'supplierId')) {
if (parsed.supplierId === null) {
return res.status(400).json({ error: 'No supplier selected' });
}
patch.supplierId = parsed.supplierId;
}
if (Object.prototype.hasOwnProperty.call(parsed.payload, 'lines')) {