Compare commits
2 Commits
bea427f3df
...
b3051953b0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3051953b0 | ||
|
|
cb2f6ad37f |
@@ -40,6 +40,24 @@ function computeShippedBySku(shipments) {
|
||||
return map;
|
||||
}
|
||||
|
||||
// MARK: helper to determine next shipment number preview
|
||||
export function getNextShipmentNumber(orderNumber, shipments = []) {
|
||||
if (!orderNumber) return '–';
|
||||
let maxIdx = 0;
|
||||
for (const s of shipments || []) {
|
||||
const num = String(s.number ?? '').trim();
|
||||
const match = num.match(/-L-(\d+)$/i) || num.match(/-(\d+)$/);
|
||||
if (match) {
|
||||
const parsed = parseInt(match[1], 10);
|
||||
if (!Number.isNaN(parsed) && parsed > maxIdx) {
|
||||
maxIdx = parsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
const nextIdx = maxIdx > 0 ? maxIdx + 1 : ((shipments?.length || 0) + 1);
|
||||
return `${orderNumber}-L-${nextIdx}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialog for selecting items and quantities to create a shipment from a sales order.
|
||||
* Calls POST /api/order/:id/shipment.
|
||||
@@ -228,6 +246,7 @@ export default class OrderShipmentDialog extends PureComponent {
|
||||
render() {
|
||||
const { open, onClose, orderNumber, lines = [], shipments = [] } = this.props;
|
||||
const { date, externalNumber, lineAmounts, selectedSkus, saving, error } = this.state;
|
||||
const nextShipmentNumber = getNextShipmentNumber(orderNumber, shipments);
|
||||
|
||||
const shippedBySku = computeShippedBySku(shipments);
|
||||
const activeLines = lines.filter((l) => Boolean(l.sku));
|
||||
@@ -293,7 +312,7 @@ export default class OrderShipmentDialog extends PureComponent {
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
{/* Header controls: date and external reference */}
|
||||
{/* Header controls: date, preview shipment number, and external reference */}
|
||||
<Stack direction={{ xs: 'column', sm: 'row' }} spacing={2} sx={{ mb: 2.5 }}>
|
||||
<TextField
|
||||
size="small"
|
||||
@@ -303,7 +322,19 @@ export default class OrderShipmentDialog extends PureComponent {
|
||||
disabled={saving}
|
||||
onChange={(e) => this.setState({ date: e.target.value })}
|
||||
slotProps={{ inputLabel: { shrink: true } }}
|
||||
sx={{ minWidth: 170 }}
|
||||
sx={{ minWidth: 160 }}
|
||||
/>
|
||||
<TextField
|
||||
size="small"
|
||||
label="Lieferschein-Nr."
|
||||
value={nextShipmentNumber}
|
||||
disabled
|
||||
slotProps={{
|
||||
input: {
|
||||
readOnly: true,
|
||||
},
|
||||
}}
|
||||
sx={{ minWidth: 190 }}
|
||||
/>
|
||||
<TextField
|
||||
size="small"
|
||||
|
||||
@@ -24,8 +24,6 @@ import AddIcon from '@mui/icons-material/Add';
|
||||
import DeleteOutlinedIcon from '@mui/icons-material/DeleteOutlined';
|
||||
import CheckCircleOutlineOutlinedIcon from '@mui/icons-material/CheckCircleOutlineOutlined';
|
||||
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
||||
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
|
||||
import Inventory2Icon from '@mui/icons-material/Inventory2';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import AppDialog from '../AppDialog';
|
||||
import { shipment as shipmentApi, shipping as shippingApi } from '../../api';
|
||||
@@ -174,7 +172,6 @@ export default class ShipmentDetailDialog extends PureComponent {
|
||||
this.handleDeletePackage = this.handleDeletePackage.bind(this);
|
||||
this.handleMarkPackageShipped = this.handleMarkPackageShipped.bind(this);
|
||||
this.handleStateChange = this.handleStateChange.bind(this);
|
||||
this.handleNavigateFull = this.handleNavigateFull.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@@ -260,7 +257,7 @@ export default class ShipmentDetailDialog extends PureComponent {
|
||||
this.setState((prev) => ({
|
||||
shipment: { ...prev.shipment, state: newState },
|
||||
}));
|
||||
const label = newState === 'delivered' ? 'Geliefert' : newState === 'returned' ? 'Retoure' : 'Neu';
|
||||
const label = newState === 'delivered' ? 'Versendet' : newState === 'returned' ? 'Retoure' : 'Neu';
|
||||
enqueueSnackbar(`Lieferstatus geändert: ${label}`, { variant: 'success' });
|
||||
await Promise.all([
|
||||
orderAutomat.actions.reload(),
|
||||
@@ -274,14 +271,6 @@ export default class ShipmentDetailDialog extends PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
handleNavigateFull() {
|
||||
const { shipment, onClose, onNavigate } = this.props;
|
||||
onClose?.();
|
||||
if (onNavigate && shipment?.id) {
|
||||
onNavigate(`/auftrag/ausliefern?shipmentId=${shipment.id}`);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { open, onClose } = this.props;
|
||||
const { shipment, loading, error, addPackageDialogOpen, busyAction } = this.state;
|
||||
@@ -290,7 +279,6 @@ export default class ShipmentDetailDialog extends PureComponent {
|
||||
|
||||
const shLines = Array.isArray(shipment.lines) ? shipment.lines : [];
|
||||
const shPackages = Array.isArray(shipment.shippings) ? shipment.shippings : [];
|
||||
const hasShippedPackages = shPackages.some((p) => p.state === 'shipped');
|
||||
|
||||
return (
|
||||
<AppDialog open={open} onClose={onClose} maxWidth="md" fullWidth>
|
||||
@@ -298,46 +286,23 @@ export default class ShipmentDetailDialog extends PureComponent {
|
||||
<Stack direction="row" spacing={1.5} sx={{ alignItems: 'center' }}>
|
||||
<LocalShippingIcon color="primary" sx={{ fontSize: 28 }} />
|
||||
<Box>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||
<Typography variant="h6" sx={{ fontWeight: 700, lineHeight: 1.2 }}>
|
||||
{shipment.number || 'Lieferschein'}
|
||||
</Typography>
|
||||
<Chip
|
||||
size="small"
|
||||
color={hasShippedPackages ? 'success' : 'default'}
|
||||
label={hasShippedPackages ? 'Im Versand' : 'Bereitstellung'}
|
||||
sx={{ fontWeight: 600, height: 20, fontSize: '0.7rem' }}
|
||||
/>
|
||||
</Box>
|
||||
<Typography variant="h6" sx={{ fontWeight: 700, lineHeight: 1.2 }}>
|
||||
{shipment.number || 'Lieferschein'}
|
||||
</Typography>
|
||||
<Typography variant="caption" color="text.secondary">
|
||||
{shipment.date ? `Datum: ${formatDate(shipment.date)}` : ''}
|
||||
{shipment.externalNumber ? ` • Ref: ${shipment.externalNumber}` : ''}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Stack>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5 }}>
|
||||
<TextField
|
||||
select
|
||||
size="small"
|
||||
label="Lieferstatus"
|
||||
value={shipment.state || 'new'}
|
||||
onChange={(e) => this.handleStateChange(e.target.value)}
|
||||
disabled={busyAction}
|
||||
sx={{ minWidth: 130 }}
|
||||
>
|
||||
<MenuItem value="new">Neu</MenuItem>
|
||||
<MenuItem value="delivered">Geliefert</MenuItem>
|
||||
<MenuItem value="returned">Retoure</MenuItem>
|
||||
</TextField>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={onClose}
|
||||
size="small"
|
||||
sx={{ color: (theme) => theme.palette.grey[500] }}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
</Box>
|
||||
<IconButton
|
||||
aria-label="close"
|
||||
onClick={onClose}
|
||||
size="small"
|
||||
sx={{ color: (theme) => theme.palette.grey[500] }}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
</DialogTitle>
|
||||
|
||||
<DialogContent dividers sx={{ p: 2.5, display: 'flex', flexDirection: 'column', gap: 2.5 }}>
|
||||
@@ -349,9 +314,6 @@ export default class ShipmentDetailDialog extends PureComponent {
|
||||
|
||||
{/* Shipped Article Positions */}
|
||||
<Box>
|
||||
<Typography variant="subtitle2" sx={{ fontWeight: 700, mb: 1 }}>
|
||||
Gelieferte Artikel-Positionen ({shLines.length})
|
||||
</Typography>
|
||||
<TableContainer sx={{ border: '1px solid', borderColor: 'divider', borderRadius: 1.5, bgcolor: WHITE }}>
|
||||
<Table size="small">
|
||||
<TableHead sx={{ bgcolor: SURFACE_RAISED }}>
|
||||
@@ -386,10 +348,7 @@ export default class ShipmentDetailDialog extends PureComponent {
|
||||
|
||||
{/* Shipping Packages / Tracking */}
|
||||
<Box>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 1 }}>
|
||||
<Typography variant="subtitle2" sx={{ fontWeight: 700 }}>
|
||||
Pakete & Sendungsverfolgung ({shPackages.length})
|
||||
</Typography>
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end', mb: shPackages.length > 0 ? 1 : 0 }}>
|
||||
<Button
|
||||
size="small"
|
||||
variant="outlined"
|
||||
@@ -402,14 +361,7 @@ export default class ShipmentDetailDialog extends PureComponent {
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
{shPackages.length === 0 ? (
|
||||
<Box sx={{ p: 2.5, textAlign: 'center', bgcolor: WHITE, borderRadius: 1.5, border: '1px dashed', borderColor: 'divider' }}>
|
||||
<Inventory2Icon sx={{ color: 'text.secondary', fontSize: 28, mb: 0.5 }} />
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
Noch keine Pakete erfasst.
|
||||
</Typography>
|
||||
</Box>
|
||||
) : (
|
||||
{shPackages.length > 0 ? (
|
||||
<Stack spacing={1}>
|
||||
{shPackages.map((pkg) => {
|
||||
const isShipped = pkg.state === 'shipped';
|
||||
@@ -493,25 +445,41 @@ export default class ShipmentDetailDialog extends PureComponent {
|
||||
);
|
||||
})}
|
||||
</Stack>
|
||||
)}
|
||||
) : null}
|
||||
</Box>
|
||||
</DialogContent>
|
||||
|
||||
<DialogActions sx={{ p: 2, justifyContent: 'space-between' }}>
|
||||
<Button variant="outlined" onClick={onClose}>
|
||||
Schließen
|
||||
</Button>
|
||||
|
||||
{this.props.onNavigate && (
|
||||
<DialogActions sx={{ p: 2, justifyContent: 'flex-end' }}>
|
||||
{(!shipment.state || shipment.state === 'new') && (
|
||||
<Button
|
||||
variant="contained"
|
||||
startIcon={<OpenInNewIcon />}
|
||||
onClick={this.handleNavigateFull}
|
||||
sx={{ textTransform: 'none', fontWeight: 600 }}
|
||||
color="primary"
|
||||
disabled={busyAction}
|
||||
onClick={() => this.handleStateChange('delivered')}
|
||||
sx={{ textTransform: 'none', fontWeight: 700 }}
|
||||
>
|
||||
In Auslieferungen öffnen
|
||||
{busyAction ? 'Wird versendet…' : 'Versenden'}
|
||||
</Button>
|
||||
)}
|
||||
{shipment.state === 'delivered' && (
|
||||
<Button
|
||||
variant="contained"
|
||||
color="warning"
|
||||
disabled={busyAction}
|
||||
onClick={() => this.handleStateChange('returned')}
|
||||
sx={{ textTransform: 'none', fontWeight: 700 }}
|
||||
>
|
||||
{busyAction ? 'Wird gebucht…' : 'Retoure'}
|
||||
</Button>
|
||||
)}
|
||||
{shipment.state === 'returned' && (
|
||||
<Chip
|
||||
label="Retoure"
|
||||
color="error"
|
||||
variant="outlined"
|
||||
sx={{ fontWeight: 700, height: 28, fontSize: '0.8rem' }}
|
||||
/>
|
||||
)}
|
||||
</DialogActions>
|
||||
|
||||
{addPackageDialogOpen && (
|
||||
|
||||
@@ -31,6 +31,7 @@ import { notifyError } from '../../utils/notify';
|
||||
import { getMaxDocumentNumber } from '../../utils/documentNumber';
|
||||
import withNavigate from '../withNavigate';
|
||||
import ShipmentDetailDialog from './ShipmentDetailDialog';
|
||||
import { getNextShipmentNumber } from './OrderShipmentDialog';
|
||||
import {
|
||||
formatDate,
|
||||
loadParties,
|
||||
@@ -206,8 +207,18 @@ class NewShipmentModal extends PureComponent {
|
||||
value={date}
|
||||
onChange={(e) => this.setState({ date: e.target.value })}
|
||||
InputLabelProps={{ shrink: true }}
|
||||
sx={{ width: 180 }}
|
||||
sx={{ width: 170 }}
|
||||
/>
|
||||
{currentOrder ? (
|
||||
<TextField
|
||||
label="Lieferschein-Nr."
|
||||
size="small"
|
||||
value={getNextShipmentNumber(currentOrder.number, currentOrder.shipments)}
|
||||
disabled
|
||||
slotProps={{ input: { readOnly: true } }}
|
||||
sx={{ width: 190 }}
|
||||
/>
|
||||
) : null}
|
||||
<TextField
|
||||
label="Referenz"
|
||||
size="small"
|
||||
|
||||
Reference in New Issue
Block a user