This commit is contained in:
seb
2026-10-15 21:54:00 +02:00
parent fafeec93b6
commit 2b2b5b945d
5 changed files with 1120 additions and 178 deletions

View File

@@ -39,15 +39,19 @@ import orderAutomat, {
isOrderDelivered,
} from '../automats/orderAutomat';
import quoteAutomat from '../automats/quoteAutomat';
import shipmentAutomat from '../automats/shipmentAutomat';
import { formatPrice } from '../utils/price';
function getAutomatFor(target) {
return target === 'quote' ? quoteAutomat : orderAutomat;
if (target === 'quote') return quoteAutomat;
if (target === 'shipment') return shipmentAutomat;
return orderAutomat;
}
function getInitialTarget() {
if (typeof window !== 'undefined') {
const p = window.location.pathname;
if (p.startsWith('/auftrag/ausliefern')) return 'shipment';
if (p.startsWith('/auftrag/bestellung')) return 'order';
if (p.startsWith('/auftrag')) return 'quote';
}
@@ -152,7 +156,7 @@ class ChunkCacheMonitor extends PureComponent {
window.addEventListener('keydown', this.handleKeyDown);
this.customEventListener = (event) => {
const reqTarget = event?.detail?.target;
if (reqTarget === 'quote' || reqTarget === 'order') {
if (reqTarget === 'quote' || reqTarget === 'order' || reqTarget === 'shipment') {
this.switchTarget(reqTarget);
} else {
const detected = getInitialTarget();
@@ -292,6 +296,9 @@ class ChunkCacheMonitor extends PureComponent {
if (p.onlyUnpaid) automat.actions.setOnlyUnpaid(true);
if (p.onlyUndelivered) automat.actions.setOnlyUndelivered(true);
}
if (this.state.target === 'shipment') {
if (p.stateFilter) automat.actions.setStateFilter(p.stateFilter);
}
if (p.negativeSeekMonths) automat.actions.addNegativeSeek(p.negativeSeekMonths);
this.setState({ inspectFilterKey: null, selectedChunk: null });
}
@@ -715,9 +722,10 @@ class ChunkCacheMonitor extends PureComponent {
<Stack spacing={0.5}>
{chunkOrders.map(({ item: order, index }) => {
const isOrd = this.state.target === 'order';
const isShip = this.state.target === 'shipment';
const paid = isOrd ? isOrderPaid(order) : false;
const delivered = isOrd ? isOrderDelivered(order) : false;
const gross = order.grossTotal != null ? Number(order.grossTotal) : orderGrossTotal(order.lines);
const gross = order.grossTotal != null ? Number(order.grossTotal) : (order.lines ? orderGrossTotal(order.lines) : 0);
const customer = order.customerName || (order.entityId ? `Kunde #${order.entityId}` : '–');
const posCount = order.positions != null ? order.positions : (order.lines?.length ?? 0);
@@ -772,11 +780,29 @@ class ChunkCacheMonitor extends PureComponent {
/>
</>
)}
{isShip && (
<>
<Chip
size="small"
label={order.state === 'delivered' ? 'Geliefert' : order.state === 'returned' ? 'Retoure' : 'Neu'}
color={order.state === 'delivered' ? 'success' : order.state === 'returned' ? 'error' : 'info'}
sx={{ height: 20, fontSize: '0.7rem' }}
/>
{order.carrier && (
<Chip
size="small"
variant="outlined"
label={order.carrier}
sx={{ height: 20, fontSize: '0.7rem' }}
/>
)}
</>
)}
<Typography
variant="caption"
sx={{ fontWeight: 600, width: 75, textAlign: 'right', fontVariantNumeric: 'tabular-nums' }}
>
{gross > 0 ? formatPrice(gross) : '–'}
{!isShip && gross > 0 ? formatPrice(gross) : (isShip && order.totalQuantity ? `${order.totalQuantity} Stk` : '–')}
</Typography>
</Box>
);
@@ -1046,6 +1072,14 @@ class ChunkCacheMonitor extends PureComponent {
onClick={() => this.switchTarget('order')}
sx={{ cursor: 'pointer', height: 24, fontSize: '0.72rem', fontWeight: this.state.target === 'order' ? 700 : 500 }}
/>
<Chip
size="small"
color={this.state.target === 'shipment' ? 'primary' : 'default'}
variant={this.state.target === 'shipment' ? 'filled' : 'outlined'}
label="Lieferscheine (shipmentAutomat)"
onClick={() => this.switchTarget('shipment')}
sx={{ cursor: 'pointer', height: 24, fontSize: '0.72rem', fontWeight: this.state.target === 'shipment' ? 700 : 500 }}
/>
</Stack>
<Chip
size="small"