This commit is contained in:
seb
2026-10-27 08:39:27 +01:00
parent 481ea16a6a
commit fab291f68e
2 changed files with 10 additions and 7 deletions

View File

@@ -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' ? (
<OrderLedgerPanel entries={this.state.ledgerEntries} />
) : null}
</PanelTileGrid>

View File

@@ -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',
});
}