u
This commit is contained in:
@@ -22,6 +22,7 @@ import LinkOffOutlinedIcon from '@mui/icons-material/LinkOffOutlined';
|
||||
import { getFirstVal, parseNum, LINE_COLUMNS } from './manifestConfig';
|
||||
import ArticlePhoto from '../article/ArticlePhoto';
|
||||
import { formatPrice, grossFromNet } from '../../utils/price';
|
||||
import { formatStock } from '../article/searchFormat';
|
||||
import { primaryPrice, priceBrutto } from '../../utils/articleDetail';
|
||||
import artikelAutomat, { createArticleSelector, getArticle } from '../../automats/artikelAutomat';
|
||||
import { artikelDetailPath } from '../article/articleRoute';
|
||||
@@ -598,6 +599,20 @@ class ManifestFormLine extends PureComponent {
|
||||
const hasPriceInfo =
|
||||
vkNetto != null || vkBrutto != null || ekNetto != null || ekBrutto != null || kind === 'quote' || kind === 'order';
|
||||
|
||||
const rawWarehouses = Array.isArray(cachedArticle.warehouses) ? cachedArticle.warehouses : [];
|
||||
const isTracked = cachedArticle.track_stock ?? cachedArticle.trackStock ?? (rawWarehouses.length > 0);
|
||||
const stockVal = isTracked === false
|
||||
? null
|
||||
: (cachedArticle.stock != null && !Number.isNaN(Number(cachedArticle.stock))
|
||||
? Number(cachedArticle.stock)
|
||||
: (rawWarehouses.length > 0 || isTracked
|
||||
? rawWarehouses.reduce((sum, wh) => sum + (Number(wh.stock) || 0), 0)
|
||||
: null));
|
||||
const warehouseTooltip = rawWarehouses.length > 0
|
||||
? rawWarehouses.map((w) => `${w.name || 'Lager'}: ${formatStock(w.stock)}`).join(' · ')
|
||||
: (isTracked === false ? 'Keine Bestandsführung' : undefined);
|
||||
const lineAmount = parseNum(getFirstVal(this.props.line?.amount, this.props.line?.menge)) ?? 0;
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@@ -714,6 +729,35 @@ class ManifestFormLine extends PureComponent {
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
>
|
||||
{/* Bestand */}
|
||||
<Tooltip
|
||||
title={
|
||||
warehouseTooltip
|
||||
? `Lagerbestand: ${formatStock(stockVal)} (${warehouseTooltip})`
|
||||
: isTracked === false
|
||||
? 'Keine Bestandsführung (unbegrenzt verfügbar)'
|
||||
: `Verfügbarer Lagerbestand: ${formatStock(stockVal)}`
|
||||
}
|
||||
>
|
||||
<Typography
|
||||
variant="caption"
|
||||
fontWeight={600}
|
||||
sx={{
|
||||
color:
|
||||
stockVal == null
|
||||
? 'text.disabled'
|
||||
: stockVal <= 0
|
||||
? 'error.main'
|
||||
: lineAmount > stockVal
|
||||
? 'warning.main'
|
||||
: 'text.secondary',
|
||||
fontSize: '0.72rem',
|
||||
}}
|
||||
>
|
||||
Bestand: {isTracked === false ? '∞' : formatStock(stockVal)}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
|
||||
{/* Marge */}
|
||||
<Tooltip
|
||||
title={
|
||||
@@ -911,6 +955,19 @@ class ManifestFormLine extends PureComponent {
|
||||
? ((vkNettoNum - priceNetNum) / vkNettoNum) * 100
|
||||
: null;
|
||||
|
||||
const rawWarehouses = Array.isArray(fullArticle.warehouses) ? fullArticle.warehouses : [];
|
||||
const isDeliveryTracked = fullArticle.track_stock ?? fullArticle.trackStock ?? (rawWarehouses.length > 0);
|
||||
const deliveryStockVal = isDeliveryTracked === false
|
||||
? null
|
||||
: (fullArticle.stock != null && !Number.isNaN(Number(fullArticle.stock))
|
||||
? Number(fullArticle.stock)
|
||||
: (rawWarehouses.length > 0 || isDeliveryTracked
|
||||
? rawWarehouses.reduce((sum, wh) => sum + (Number(wh.stock) || 0), 0)
|
||||
: null));
|
||||
const deliveryWarehouseTooltip = rawWarehouses.length > 0
|
||||
? rawWarehouses.map((w) => `${w.name || 'Lager'}: ${formatStock(w.stock)}`).join(' · ')
|
||||
: (isDeliveryTracked === false ? 'Keine Bestandsführung' : undefined);
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@@ -1040,8 +1097,8 @@ class ManifestFormLine extends PureComponent {
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
{/* Stored Purchase Price (Netto), VK Netto & VK Brutto */}
|
||||
{(priceNet != null || vkNetto != null || vkBrutto != null) && (
|
||||
{/* Stored Purchase Price (Netto), VK Netto, VK Brutto, Marge & Bestand */}
|
||||
{(priceNet != null || vkNetto != null || vkBrutto != null || deliveryStockVal != null) && (
|
||||
<Box
|
||||
sx={{
|
||||
display: 'flex',
|
||||
@@ -1051,6 +1108,33 @@ class ManifestFormLine extends PureComponent {
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
>
|
||||
{/* Bestand */}
|
||||
<Tooltip
|
||||
title={
|
||||
deliveryWarehouseTooltip
|
||||
? `Lagerbestand: ${formatStock(deliveryStockVal)} (${deliveryWarehouseTooltip})`
|
||||
: isDeliveryTracked === false
|
||||
? 'Keine Bestandsführung (unbegrenzt verfügbar)'
|
||||
: `Aktueller Lagerbestand: ${formatStock(deliveryStockVal)}`
|
||||
}
|
||||
>
|
||||
<Typography
|
||||
variant="caption"
|
||||
fontWeight={600}
|
||||
sx={{
|
||||
color:
|
||||
deliveryStockVal == null
|
||||
? 'text.disabled'
|
||||
: deliveryStockVal <= 0
|
||||
? 'error.main'
|
||||
: 'text.secondary',
|
||||
fontSize: '0.72rem',
|
||||
}}
|
||||
>
|
||||
Bestand: {isDeliveryTracked === false ? '∞' : formatStock(deliveryStockVal)}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
|
||||
{/* Marge */}
|
||||
{margeDelivery != null && (
|
||||
<Tooltip
|
||||
|
||||
Reference in New Issue
Block a user