u
This commit is contained in:
@@ -21,6 +21,8 @@ function orderErrorStatus(error) {
|
||||
if (error.message === 'Attachment not found') return 404;
|
||||
if (error.message === 'Entity not found') return 404;
|
||||
if (error.message === 'Article not found') return 404;
|
||||
if (error.message === 'No entity selected') return 400;
|
||||
if (error.message === 'Order number already exists') return 409;
|
||||
if (error.message === 'Invalid entityId') return 400;
|
||||
if (error.message === 'Invalid order') return 400;
|
||||
if (error.message === 'Invalid lines') return 400;
|
||||
@@ -148,7 +150,7 @@ export function register(app, basePath = '') {
|
||||
* description: |
|
||||
* Creates a sales order with header and lines in one transaction.
|
||||
* `date` is the document date (expected delivery).
|
||||
* `entityId` must be a company customer (not Lieferanten), or null.
|
||||
* `entityId` must be a company customer (not Lieferanten).
|
||||
* Each line requires `sku` or `name`, `amount`, `net`, and `taxrate` (rate); `pu` defaults to `1`; `rebate` defaults to `0`.
|
||||
* security:
|
||||
* - cookieAuth: []
|
||||
@@ -159,7 +161,7 @@ export function register(app, basePath = '') {
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required: [number, date, lines]
|
||||
* required: [number, date, entityId, lines]
|
||||
* properties:
|
||||
* number:
|
||||
* type: string
|
||||
@@ -169,7 +171,6 @@ export function register(app, basePath = '') {
|
||||
* description: Document date / expected delivery
|
||||
* entityId:
|
||||
* type: integer
|
||||
* nullable: true
|
||||
* description: Customer entity (manifest.entity_id)
|
||||
* externalNumber:
|
||||
* type: string
|
||||
@@ -297,7 +298,10 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
|
||||
const { number, date, createdAt, entityId, externalNumber, lines } = req.body ?? {};
|
||||
if (entityId !== undefined && entityId !== null && (typeof entityId !== 'number' || !Number.isInteger(entityId) || entityId <= 0)) {
|
||||
if (entityId === undefined || entityId === null) {
|
||||
return res.status(400).json({ error: 'No entity selected' });
|
||||
}
|
||||
if (typeof entityId !== 'number' || !Number.isInteger(entityId) || entityId <= 0) {
|
||||
return res.status(400).json({ error: 'Invalid entityId' });
|
||||
}
|
||||
|
||||
@@ -538,7 +542,10 @@ export function register(app, basePath = '') {
|
||||
patch.createdAt = body.createdAt;
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(body, 'entityId')) {
|
||||
if (body.entityId !== null && (typeof body.entityId !== 'number' || !Number.isInteger(body.entityId) || body.entityId <= 0)) {
|
||||
if (body.entityId === null) {
|
||||
return res.status(400).json({ error: 'No entity selected' });
|
||||
}
|
||||
if (typeof body.entityId !== 'number' || !Number.isInteger(body.entityId) || body.entityId <= 0) {
|
||||
return res.status(400).json({ error: 'Invalid entityId' });
|
||||
}
|
||||
patch.entityId = body.entityId;
|
||||
|
||||
Reference in New Issue
Block a user