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 { getFirstVal, parseNum, LINE_COLUMNS } from './manifestConfig';
|
||||||
import ArticlePhoto from '../article/ArticlePhoto';
|
import ArticlePhoto from '../article/ArticlePhoto';
|
||||||
import { formatPrice, grossFromNet } from '../../utils/price';
|
import { formatPrice, grossFromNet } from '../../utils/price';
|
||||||
|
import { formatStock } from '../article/searchFormat';
|
||||||
import { primaryPrice, priceBrutto } from '../../utils/articleDetail';
|
import { primaryPrice, priceBrutto } from '../../utils/articleDetail';
|
||||||
import artikelAutomat, { createArticleSelector, getArticle } from '../../automats/artikelAutomat';
|
import artikelAutomat, { createArticleSelector, getArticle } from '../../automats/artikelAutomat';
|
||||||
import { artikelDetailPath } from '../article/articleRoute';
|
import { artikelDetailPath } from '../article/articleRoute';
|
||||||
@@ -598,6 +599,20 @@ class ManifestFormLine extends PureComponent {
|
|||||||
const hasPriceInfo =
|
const hasPriceInfo =
|
||||||
vkNetto != null || vkBrutto != null || ekNetto != null || ekBrutto != null || kind === 'quote' || kind === 'order';
|
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 (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -714,6 +729,35 @@ class ManifestFormLine extends PureComponent {
|
|||||||
whiteSpace: 'nowrap',
|
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 */}
|
{/* Marge */}
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={
|
title={
|
||||||
@@ -911,6 +955,19 @@ class ManifestFormLine extends PureComponent {
|
|||||||
? ((vkNettoNum - priceNetNum) / vkNettoNum) * 100
|
? ((vkNettoNum - priceNetNum) / vkNettoNum) * 100
|
||||||
: null;
|
: 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 (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@@ -1040,8 +1097,8 @@ class ManifestFormLine extends PureComponent {
|
|||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Stored Purchase Price (Netto), VK Netto & VK Brutto */}
|
{/* Stored Purchase Price (Netto), VK Netto, VK Brutto, Marge & Bestand */}
|
||||||
{(priceNet != null || vkNetto != null || vkBrutto != null) && (
|
{(priceNet != null || vkNetto != null || vkBrutto != null || deliveryStockVal != null) && (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@@ -1051,6 +1108,33 @@ class ManifestFormLine extends PureComponent {
|
|||||||
whiteSpace: 'nowrap',
|
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 */}
|
{/* Marge */}
|
||||||
{margeDelivery != null && (
|
{margeDelivery != null && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
|
|||||||
Reference in New Issue
Block a user