u
This commit is contained in:
@@ -246,7 +246,7 @@ class ManifestForm extends PureComponent {
|
|||||||
|
|
||||||
if (this.props.mode === 'edit') {
|
if (this.props.mode === 'edit') {
|
||||||
void this.loadEdit();
|
void this.loadEdit();
|
||||||
if (this.props.kind === 'order') {
|
if (this.props.kind === 'order' || this.props.kind === 'retoure') {
|
||||||
this.unsubSseLedger = sseAutomat?.actions?.on?.('ledger', () => {
|
this.unsubSseLedger = sseAutomat?.actions?.on?.('ledger', () => {
|
||||||
void this.reloadLedger();
|
void this.reloadLedger();
|
||||||
});
|
});
|
||||||
@@ -404,11 +404,12 @@ class ManifestForm extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async reloadLedger() {
|
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 {
|
try {
|
||||||
const ledgerEntries = await fetchOrderLedgerEntries(this.props.docId, {
|
const ledgerEntries = await fetchOrderLedgerEntries(this.props.docId, {
|
||||||
shipments: this.state.shipments,
|
shipments: this.state.shipments,
|
||||||
lines: this.state.lines,
|
lines: this.state.lines,
|
||||||
|
docNumber: this.state.number,
|
||||||
});
|
});
|
||||||
if (this._cancelled) return;
|
if (this._cancelled) return;
|
||||||
this.setState({ ledgerEntries });
|
this.setState({ ledgerEntries });
|
||||||
@@ -518,11 +519,12 @@ class ManifestForm extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let ledgerEntries = [];
|
let ledgerEntries = [];
|
||||||
if (kind === 'order') {
|
if (kind === 'order' || kind === 'retoure') {
|
||||||
try {
|
try {
|
||||||
ledgerEntries = await fetchOrderLedgerEntries(docId, {
|
ledgerEntries = await fetchOrderLedgerEntries(docId, {
|
||||||
shipments,
|
shipments,
|
||||||
lines: doc.lines,
|
lines: doc.lines,
|
||||||
|
docNumber: doc.number,
|
||||||
});
|
});
|
||||||
} catch (lErr) {
|
} catch (lErr) {
|
||||||
console.warn('[ManifestForm] Failed to load ledger entries:', lErr);
|
console.warn('[ManifestForm] Failed to load ledger entries:', lErr);
|
||||||
@@ -938,7 +940,7 @@ class ManifestForm extends PureComponent {
|
|||||||
handleRemoveLine(key) {
|
handleRemoveLine(key) {
|
||||||
this.setState((prev) => {
|
this.setState((prev) => {
|
||||||
const lineToRemove = prev.lines.find((line) => line.key === key);
|
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 rawSku = lineToRemove.sku != null ? String(lineToRemove.sku).trim().toLowerCase() : '';
|
||||||
const orderLineId = lineToRemove.id;
|
const orderLineId = lineToRemove.id;
|
||||||
const lineName = lineToRemove.name != null ? String(lineToRemove.name).trim().toLowerCase() : '';
|
const lineName = lineToRemove.name != null ? String(lineToRemove.name).trim().toLowerCase() : '';
|
||||||
@@ -977,7 +979,7 @@ class ManifestForm extends PureComponent {
|
|||||||
handleRemoveAllLines() {
|
handleRemoveAllLines() {
|
||||||
this.setState((prev) => {
|
this.setState((prev) => {
|
||||||
let nextLines = [];
|
let nextLines = [];
|
||||||
if (this.props.kind === 'order') {
|
if (this.props.kind === 'order' || this.props.kind === 'retoure') {
|
||||||
const shippedSkus = new Set();
|
const shippedSkus = new Set();
|
||||||
for (const sh of prev.shipments || []) {
|
for (const sh of prev.shipments || []) {
|
||||||
for (const sl of sh.lines || []) {
|
for (const sl of sh.lines || []) {
|
||||||
@@ -1506,7 +1508,7 @@ class ManifestForm extends PureComponent {
|
|||||||
navigate={this.props.navigate}
|
navigate={this.props.navigate}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{status === 'ready' && kind === 'order' && this.props.mode === 'edit' ? (
|
{status === 'ready' && (kind === 'order' || kind === 'retoure') && this.props.mode === 'edit' ? (
|
||||||
<OrderLedgerPanel entries={this.state.ledgerEntries} />
|
<OrderLedgerPanel entries={this.state.ledgerEntries} />
|
||||||
) : null}
|
) : null}
|
||||||
</PanelTileGrid>
|
</PanelTileGrid>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export async function fetchOrderLedgerEntries(orderId, {
|
|||||||
lines = null,
|
lines = null,
|
||||||
ledgerApi = defaultLedgerApi,
|
ledgerApi = defaultLedgerApi,
|
||||||
shipmentApi = defaultShipmentApi,
|
shipmentApi = defaultShipmentApi,
|
||||||
|
docNumber = null,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
let shipmentList = shipments;
|
let shipmentList = shipments;
|
||||||
if (!shipmentList && orderId) {
|
if (!shipmentList && orderId) {
|
||||||
@@ -77,7 +78,7 @@ export async function fetchOrderLedgerEntries(orderId, {
|
|||||||
sku: oLine.sku || null,
|
sku: oLine.sku || null,
|
||||||
name: oLine.name || null,
|
name: oLine.name || null,
|
||||||
lineAmount: oLine.amount ?? null,
|
lineAmount: oLine.amount ?? null,
|
||||||
documentNumber: null,
|
documentNumber: docNumber || null,
|
||||||
documentType: 'order',
|
documentType: 'order',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user