This commit is contained in:
seb
2026-10-27 00:28:06 +01:00
parent f52ab1be0c
commit 75691e6afc
21 changed files with 2458 additions and 60 deletions

View File

@@ -224,14 +224,21 @@ export const orderDraftAutomat = createManifestDraftAutomat({
name: 'order-draft',
});
/** Shared singleton automat for retoure draft. */
export const retoureDraftAutomat = createManifestDraftAutomat({
kind: 'retoure',
name: 'retoure-draft',
});
/**
* Returns the draft automat for a given manifest kind.
* @param {'quote'|'order'} kind
* @param {'quote'|'order'|'retoure'} kind
* @returns {Automat|null}
*/
export function getManifestDraftAutomat(kind) {
if (kind === 'quote') return quoteDraftAutomat;
if (kind === 'order') return orderDraftAutomat;
if (kind === 'retoure') return retoureDraftAutomat;
return null;
}
@@ -454,10 +461,10 @@ export function createManifestEditAutomat({ kind, name }) {
shipments: doc.shipments || [],
payments: doc.payments || [],
shippings: doc.shippings || [],
orderTotal: doc.orderTotal ?? null,
paidTotal: doc.paidTotal ?? null,
paid: Boolean(doc.paid),
shipped: Boolean(doc.shipped),
orderTotal: doc.orderTotal ?? doc.grossTotal ?? doc.gross_total ?? null,
paidTotal: doc.paidTotal ?? doc.paid_total ?? null,
paid: Boolean(doc.paid ?? doc.isPaid ?? doc.is_paid),
shipped: Boolean(doc.shipped ?? doc.isShipped ?? doc.is_shipped),
delivered: Boolean(doc.delivered),
baseline,
isDirty: false,
@@ -605,13 +612,20 @@ export const orderEditAutomat = createManifestEditAutomat({
name: 'order-edit',
});
/** Shared singleton automat for the single last edited retoure. */
export const retoureEditAutomat = createManifestEditAutomat({
kind: 'retoure',
name: 'retoure-edit',
});
/**
* Returns the edit automat for a given manifest kind.
* @param {'quote'|'order'} kind
* @param {'quote'|'order'|'retoure'} kind
* @returns {Automat|null}
*/
export function getManifestEditAutomat(kind) {
if (kind === 'quote') return quoteEditAutomat;
if (kind === 'order') return orderEditAutomat;
if (kind === 'retoure') return retoureEditAutomat;
return null;
}