This commit is contained in:
seb
2026-09-26 07:34:37 +02:00
parent 607e6cc0ac
commit e491ecfa47
24 changed files with 2162 additions and 1716 deletions

View File

@@ -44,6 +44,10 @@ export default function create(provider) {
if (!number || !date) {
throw new Error('Invalid order');
}
const createdAt = body.createdAt ? parseDate(body.createdAt) : new Date();
if (body.createdAt && !createdAt) {
throw new Error('Invalid order');
}
const externalNumber = body.externalNumber?.trim?.()
? body.externalNumber.trim()
: null;
@@ -66,6 +70,7 @@ export default function create(provider) {
entityId,
externalNumber,
date,
createdAt,
});
const manifestId = created.rows[0]?.id ?? created.insertId;

View File

@@ -52,11 +52,12 @@ export default function update(provider) {
const hasNumber = Object.prototype.hasOwnProperty.call(patch, 'number');
const hasDate = Object.prototype.hasOwnProperty.call(patch, 'date');
const hasCreatedAt = Object.prototype.hasOwnProperty.call(patch, 'createdAt');
const hasEntityId = Object.prototype.hasOwnProperty.call(patch, 'entityId');
const hasExternalNumber = Object.prototype.hasOwnProperty.call(patch, 'externalNumber');
const hasLines = Object.prototype.hasOwnProperty.call(patch, 'lines');
if (!hasNumber && !hasDate && !hasEntityId && !hasExternalNumber && !hasLines) {
if (!hasNumber && !hasDate && !hasCreatedAt && !hasEntityId && !hasExternalNumber && !hasLines) {
throw new Error('Invalid order');
}
@@ -97,6 +98,14 @@ export default function update(provider) {
}
}
let createdAt = summary.createdAt ? parseDate(summary.createdAt) : null;
if (hasCreatedAt) {
createdAt = parseDate(patch.createdAt);
if (!createdAt) {
throw new Error('Invalid order');
}
}
let entityId = summary.entityId;
if (hasEntityId) {
entityId = await assertCustomerEntity(
@@ -121,6 +130,7 @@ export default function update(provider) {
entityId,
externalNumber,
date,
createdAt,
});
if (hasLines) {