This commit is contained in:
seb
2026-10-16 19:36:08 +02:00
parent 4a7a02a0a4
commit 7ad8a3a301
5 changed files with 167 additions and 95 deletions

View File

@@ -47,6 +47,7 @@ export default class BookDeliveryDialog extends PureComponent {
let initialAmounts = {};
if (Array.isArray(props.summary?.lines)) {
for (const line of props.summary.lines) {
if (!line.trackStock) continue;
if (props.prefillLineId != null) {
initialAmounts[line.id] =
line.id === props.prefillLineId
@@ -174,6 +175,7 @@ export default class BookDeliveryDialog extends PureComponent {
const amounts = {};
if (Array.isArray(summary?.lines)) {
for (const line of summary.lines) {
if (!line.trackStock) continue;
if (prefillLineId != null) {
amounts[line.id] =
line.id === prefillLineId
@@ -208,6 +210,7 @@ export default class BookDeliveryDialog extends PureComponent {
if (!summary?.lines) return;
const amounts = {};
for (const line of summary.lines) {
if (!line.trackStock) continue;
amounts[line.id] = line.remainingAmount > 0 ? line.remainingAmount : 0;
}
this.setState({ amountsToBook: amounts });
@@ -218,6 +221,7 @@ export default class BookDeliveryDialog extends PureComponent {
if (!summary?.lines) return;
const amounts = {};
for (const line of summary.lines) {
if (!line.trackStock) continue;
amounts[line.id] = 0;
}
this.setState({ amountsToBook: amounts });
@@ -229,6 +233,7 @@ export default class BookDeliveryDialog extends PureComponent {
if (!summary?.lines) return;
const linesToBook = summary.lines
.filter((line) => line.trackStock)
.map((line) => ({
manifestarticleId: line.id,
sku: line.sku,
@@ -382,12 +387,12 @@ export default class BookDeliveryDialog extends PureComponent {
renderLinesTable() {
const { summary, amountsToBook, isBooking } = this.state;
const lines = summary?.lines || [];
const lines = (summary?.lines || []).filter((l) => l.trackStock);
if (lines.length === 0) {
return (
<Alert severity="info" sx={{ my: 2 }}>
Diese Lieferung enthält keine Artikelpositionen zum Einbuchen.
Diese Lieferung enthält keine lagergeführten Artikel zum Einbuchen.
</Alert>
);
}
@@ -490,7 +495,8 @@ export default class BookDeliveryDialog extends PureComponent {
warehouseError,
} = this.state;
const lines = summary?.lines || [];
const lines = (summary?.lines || []).filter((l) => l.trackStock);
const hasTrackStock = lines.length > 0;
const prefillLine =
this.props.prefillLineId != null
? lines.find((l) => l.id === this.props.prefillLineId)
@@ -502,7 +508,7 @@ export default class BookDeliveryDialog extends PureComponent {
const countLinesToBook = lines.filter(
(l) => Number(amountsToBook[l.id]) > 0
).length;
const isFullyBooked = summary?.status === 'booked';
const isFullyBooked = hasTrackStock && summary?.status === 'booked';
const selectedWarehouse = warehouses.find((w) => w.id === selectedWarehouseId);
const isWarehouseMissing = !selectedWarehouseId;
@@ -554,7 +560,7 @@ export default class BookDeliveryDialog extends PureComponent {
)}
{this.renderLinesTable()}
{!isFullyBooked && lines.length > 0 && (
{!isFullyBooked && hasTrackStock && (
<Box sx={{ display: 'flex', gap: 1, mb: 2 }}>
<Button
size="small"
@@ -576,75 +582,77 @@ export default class BookDeliveryDialog extends PureComponent {
</Box>
)}
{warehouses.length === 0 && !isFullyBooked && (
{hasTrackStock && warehouses.length === 0 && !isFullyBooked && (
<Alert severity="error" sx={{ mb: 2 }}>
Es ist noch kein Lager eingerichtet. Bitte legen Sie unter „Artikel → Lager“ zuerst ein Lager an.
</Alert>
)}
<Box
sx={{
display: 'flex',
gap: 2,
mb: 2,
flexDirection: { xs: 'column', sm: 'row' },
}}
>
<FormControl
size="small"
required
error={Boolean(warehouseError)}
disabled={isBooking || isFullyBooked}
sx={{ minWidth: { sm: 240 }, flex: { sm: '0 0 auto' } }}
{hasTrackStock && (
<Box
sx={{
display: 'flex',
gap: 2,
mb: 2,
flexDirection: { xs: 'column', sm: 'row' },
}}
>
<InputLabel id="warehouse-select-label">Ziellager *</InputLabel>
<Select
labelId="warehouse-select-label"
id="warehouse-select"
value={selectedWarehouseId ?? ''}
label="Ziellager *"
onChange={this.handleWarehouseChange}
startAdornment={
<WarehouseIcon
sx={{ mr: 1, color: 'text.secondary', fontSize: 20 }}
/>
}
<FormControl
size="small"
required
error={Boolean(warehouseError)}
disabled={isBooking || isFullyBooked}
sx={{ minWidth: { sm: 240 }, flex: { sm: '0 0 auto' } }}
>
{warehouses.length === 0 ? (
<MenuItem value="" disabled>
Keine Lager vorhanden
</MenuItem>
) : (
warehouses.map((wh) => (
<MenuItem key={wh.id} value={wh.id}>
{wh.name}
<InputLabel id="warehouse-select-label">Ziellager *</InputLabel>
<Select
labelId="warehouse-select-label"
id="warehouse-select"
value={selectedWarehouseId ?? ''}
label="Ziellager *"
onChange={this.handleWarehouseChange}
startAdornment={
<WarehouseIcon
sx={{ mr: 1, color: 'text.secondary', fontSize: 20 }}
/>
}
>
{warehouses.length === 0 ? (
<MenuItem value="" disabled>
Keine Lager vorhanden
</MenuItem>
))
) : (
warehouses.map((wh) => (
<MenuItem key={wh.id} value={wh.id}>
{wh.name}
</MenuItem>
))
)}
</Select>
{warehouseError ? (
<FormHelperText>{warehouseError}</FormHelperText>
) : (
<FormHelperText>Pflichtfeld: Ziellager für die Buchung</FormHelperText>
)}
</Select>
{warehouseError ? (
<FormHelperText>{warehouseError}</FormHelperText>
) : (
<FormHelperText>Pflichtfeld: Ziellager für die Buchung</FormHelperText>
)}
</FormControl>
</FormControl>
<TextField
fullWidth
size="small"
label="Buchungstext (Ledger-Referenz)"
value={transactionText}
onChange={this.handleTransactionTextChange}
disabled={isBooking || isFullyBooked}
helperText="Wird als Transaktionstext in das Ledger übernommen"
/>
</Box>
<TextField
fullWidth
size="small"
label="Buchungstext (Ledger-Referenz)"
value={transactionText}
onChange={this.handleTransactionTextChange}
disabled={isBooking || isFullyBooked}
helperText="Wird als Transaktionstext in das Ledger übernommen"
/>
</Box>
)}
{isFullyBooked ? (
<Alert severity="success" icon={<CheckCircleOutlineOutlinedIcon />}>
Alle Artikel dieser Lieferung sind bereits vollständig im Lager verbucht.
</Alert>
) : totalToBook > 0 ? (
) : hasTrackStock && totalToBook > 0 ? (
<Alert severity={selectedWarehouseId ? 'info' : 'warning'}>
{selectedWarehouseId ? (
<>
@@ -659,11 +667,11 @@ export default class BookDeliveryDialog extends PureComponent {
</>
)}
</Alert>
) : (
) : hasTrackStock ? (
<Alert severity="warning">
Wählen Sie mindestens eine Menge größer als 0 aus, um den Lagerzugang zu buchen.
</Alert>
)}
) : null}
</>
)}
</DialogContent>