u
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user