From fab291f68e1cd490412d8893e30964b63a4cd347 Mon Sep 17 00:00:00 2001 From: seb Date: Tue, 27 Oct 2026 08:39:27 +0100 Subject: [PATCH] u --- src/components/manifest/ManifestForm.jsx | 14 ++++++++------ src/utils/orderLedger.js | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/manifest/ManifestForm.jsx b/src/components/manifest/ManifestForm.jsx index 442c178..c691d97 100644 --- a/src/components/manifest/ManifestForm.jsx +++ b/src/components/manifest/ManifestForm.jsx @@ -246,7 +246,7 @@ class ManifestForm extends PureComponent { if (this.props.mode === 'edit') { void this.loadEdit(); - if (this.props.kind === 'order') { + if (this.props.kind === 'order' || this.props.kind === 'retoure') { this.unsubSseLedger = sseAutomat?.actions?.on?.('ledger', () => { void this.reloadLedger(); }); @@ -404,11 +404,12 @@ class ManifestForm extends PureComponent { } async reloadLedger() { - if (this.props.kind !== 'order' || this.props.mode !== 'edit' || !this.props.docId) return; + if ((this.props.kind !== 'order' && this.props.kind !== 'retoure') || this.props.mode !== 'edit' || !this.props.docId) return; try { const ledgerEntries = await fetchOrderLedgerEntries(this.props.docId, { shipments: this.state.shipments, lines: this.state.lines, + docNumber: this.state.number, }); if (this._cancelled) return; this.setState({ ledgerEntries }); @@ -518,11 +519,12 @@ class ManifestForm extends PureComponent { } let ledgerEntries = []; - if (kind === 'order') { + if (kind === 'order' || kind === 'retoure') { try { ledgerEntries = await fetchOrderLedgerEntries(docId, { shipments, lines: doc.lines, + docNumber: doc.number, }); } catch (lErr) { console.warn('[ManifestForm] Failed to load ledger entries:', lErr); @@ -938,7 +940,7 @@ class ManifestForm extends PureComponent { handleRemoveLine(key) { this.setState((prev) => { const lineToRemove = prev.lines.find((line) => line.key === key); - if (lineToRemove && this.props.kind === 'order') { + if (lineToRemove && (this.props.kind === 'order' || this.props.kind === 'retoure')) { const rawSku = lineToRemove.sku != null ? String(lineToRemove.sku).trim().toLowerCase() : ''; const orderLineId = lineToRemove.id; const lineName = lineToRemove.name != null ? String(lineToRemove.name).trim().toLowerCase() : ''; @@ -977,7 +979,7 @@ class ManifestForm extends PureComponent { handleRemoveAllLines() { this.setState((prev) => { let nextLines = []; - if (this.props.kind === 'order') { + if (this.props.kind === 'order' || this.props.kind === 'retoure') { const shippedSkus = new Set(); for (const sh of prev.shipments || []) { for (const sl of sh.lines || []) { @@ -1506,7 +1508,7 @@ class ManifestForm extends PureComponent { navigate={this.props.navigate} /> ) : null} - {status === 'ready' && kind === 'order' && this.props.mode === 'edit' ? ( + {status === 'ready' && (kind === 'order' || kind === 'retoure') && this.props.mode === 'edit' ? ( ) : null} diff --git a/src/utils/orderLedger.js b/src/utils/orderLedger.js index ba74386..a14a831 100644 --- a/src/utils/orderLedger.js +++ b/src/utils/orderLedger.js @@ -19,6 +19,7 @@ export async function fetchOrderLedgerEntries(orderId, { lines = null, ledgerApi = defaultLedgerApi, shipmentApi = defaultShipmentApi, + docNumber = null, } = {}) { let shipmentList = shipments; if (!shipmentList && orderId) { @@ -77,7 +78,7 @@ export async function fetchOrderLedgerEntries(orderId, { sku: oLine.sku || null, name: oLine.name || null, lineAmount: oLine.amount ?? null, - documentNumber: null, + documentNumber: docNumber || null, documentType: 'order', }); }