u
This commit is contained in:
@@ -1259,6 +1259,7 @@ class ManifestForm extends PureComponent {
|
|||||||
<ManifestLines
|
<ManifestLines
|
||||||
kind={cfg.kind}
|
kind={cfg.kind}
|
||||||
columns={cfg.columns}
|
columns={cfg.columns}
|
||||||
|
docId={this.props.docId}
|
||||||
lines={lines}
|
lines={lines}
|
||||||
saving={saving}
|
saving={saving}
|
||||||
wide={4}
|
wide={4}
|
||||||
|
|||||||
@@ -609,6 +609,25 @@ class ManifestFormLine extends PureComponent {
|
|||||||
: null));
|
: null));
|
||||||
const lineAmount = parseNum(getFirstVal(this.props.line?.amount, this.props.line?.menge)) ?? 0;
|
const lineAmount = parseNum(getFirstVal(this.props.line?.amount, this.props.line?.menge)) ?? 0;
|
||||||
|
|
||||||
|
const undeliveredOrders = Array.isArray(cachedArticle.undeliveredOrders)
|
||||||
|
? cachedArticle.undeliveredOrders
|
||||||
|
: [];
|
||||||
|
const currentDocId = this.props.docId != null
|
||||||
|
? Number(this.props.docId)
|
||||||
|
: (this.props.line?.manifestId != null ? Number(this.props.line.manifestId) : null);
|
||||||
|
const otherOrders = currentDocId != null && kind === 'order'
|
||||||
|
? undeliveredOrders.filter((ord) => Number(ord.orderId) !== currentDocId)
|
||||||
|
: undeliveredOrders;
|
||||||
|
const reservedInOtherOrders = otherOrders.reduce(
|
||||||
|
(sum, ord) => sum + (Number(ord.amount) || 0),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
const reservedTitle = isTracked !== false && reservedInOtherOrders > 0
|
||||||
|
? `Bereits in anderen Aufträgen reserviert:\n${otherOrders
|
||||||
|
.map((ord) => `• ${ord.orderNumber || (ord.orderId ? `Auftrag #${ord.orderId}` : 'Auftrag')}: ${formatStock(ord.amount)}${ord.customerName ? ` (${ord.customerName})` : ''}`)
|
||||||
|
.join('\n')}`
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -729,19 +748,23 @@ class ManifestFormLine extends PureComponent {
|
|||||||
<Typography
|
<Typography
|
||||||
variant="caption"
|
variant="caption"
|
||||||
fontWeight={600}
|
fontWeight={600}
|
||||||
|
title={reservedTitle}
|
||||||
sx={{
|
sx={{
|
||||||
color:
|
color:
|
||||||
stockVal == null
|
stockVal == null
|
||||||
? 'text.disabled'
|
? 'text.disabled'
|
||||||
: stockVal <= 0
|
: stockVal <= 0
|
||||||
? 'error.main'
|
? 'error.main'
|
||||||
: lineAmount > stockVal
|
: lineAmount > (stockVal - reservedInOtherOrders)
|
||||||
? 'warning.main'
|
? 'warning.main'
|
||||||
: 'text.secondary',
|
: 'text.secondary',
|
||||||
fontSize: '0.72rem',
|
fontSize: '0.72rem',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Bestand: {isTracked === false ? '∞' : formatStock(stockVal)}
|
Bestand: {isTracked === false ? '∞' : formatStock(stockVal)}
|
||||||
|
{isTracked !== false && reservedInOtherOrders > 0
|
||||||
|
? ` (${formatStock(reservedInOtherOrders)} reserviert)`
|
||||||
|
: ''}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
{/* Marge */}
|
{/* Marge */}
|
||||||
@@ -933,6 +956,19 @@ class ManifestFormLine extends PureComponent {
|
|||||||
? rawWarehouses.reduce((sum, wh) => sum + (Number(wh.stock) || 0), 0)
|
? rawWarehouses.reduce((sum, wh) => sum + (Number(wh.stock) || 0), 0)
|
||||||
: null));
|
: null));
|
||||||
|
|
||||||
|
const deliveryUndelivered = Array.isArray(fullArticle.undeliveredOrders)
|
||||||
|
? fullArticle.undeliveredOrders
|
||||||
|
: [];
|
||||||
|
const reservedInOtherOrdersDelivery = deliveryUndelivered.reduce(
|
||||||
|
(sum, ord) => sum + (Number(ord.amount) || 0),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
const reservedTitleDelivery = isDeliveryTracked !== false && reservedInOtherOrdersDelivery > 0
|
||||||
|
? `In Kundenaufträgen reserviert:\n${deliveryUndelivered
|
||||||
|
.map((ord) => `• ${ord.orderNumber || (ord.orderId ? `Auftrag #${ord.orderId}` : 'Auftrag')}: ${formatStock(ord.amount)}${ord.customerName ? ` (${ord.customerName})` : ''}`)
|
||||||
|
.join('\n')}`
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -1069,6 +1105,7 @@ class ManifestFormLine extends PureComponent {
|
|||||||
<Typography
|
<Typography
|
||||||
variant="caption"
|
variant="caption"
|
||||||
fontWeight={600}
|
fontWeight={600}
|
||||||
|
title={reservedTitleDelivery}
|
||||||
sx={{
|
sx={{
|
||||||
color:
|
color:
|
||||||
deliveryStockVal == null
|
deliveryStockVal == null
|
||||||
@@ -1080,6 +1117,9 @@ class ManifestFormLine extends PureComponent {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Bestand: {isDeliveryTracked === false ? '∞' : formatStock(deliveryStockVal)}
|
Bestand: {isDeliveryTracked === false ? '∞' : formatStock(deliveryStockVal)}
|
||||||
|
{isDeliveryTracked !== false && reservedInOtherOrdersDelivery > 0
|
||||||
|
? ` (${formatStock(reservedInOtherOrdersDelivery)} reserviert)`
|
||||||
|
: ''}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
{/* Marge */}
|
{/* Marge */}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class ManifestLines extends PureComponent {
|
|||||||
lines,
|
lines,
|
||||||
saving,
|
saving,
|
||||||
partyId,
|
partyId,
|
||||||
|
docId,
|
||||||
linesColor,
|
linesColor,
|
||||||
dirtyLineFields = {},
|
dirtyLineFields = {},
|
||||||
shipments,
|
shipments,
|
||||||
@@ -145,6 +146,7 @@ class ManifestLines extends PureComponent {
|
|||||||
index={index}
|
index={index}
|
||||||
positionIndex={index + 1}
|
positionIndex={index + 1}
|
||||||
kind={kind}
|
kind={kind}
|
||||||
|
docId={docId}
|
||||||
line={line.key != null ? line : { ...line, key: index }}
|
line={line.key != null ? line : { ...line, key: index }}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
saving={saving}
|
saving={saving}
|
||||||
|
|||||||
Reference in New Issue
Block a user