Improve planning data normalization
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m25s

This commit is contained in:
Cauê Faleiros
2026-07-20 11:24:47 -03:00
parent 3066ba06a2
commit 9af5f296a7
9 changed files with 112 additions and 18 deletions

View File

@@ -14,6 +14,7 @@ import { decodeProductGroupKey, normalizeProductText, parseProductName } from '.
import { formatColorLabel } from '../displayFormatters';
import { getProductColor } from '../productColors';
import { getDominantProductType, getProductTypeConfig, resolveProductType, type ProductTypeKey } from '../productClassification';
import { getPlanningStock } from '../planningStock';
import type { CuttingSettings, DateRange, ProductAnalyticsItem, ProductionOrderItem } from '../types';
type VariantRow = ProductAnalyticsItem & {
@@ -263,7 +264,7 @@ const ProductGroupDetails = () => {
const dailySales = product.quantitySold / rangeDays;
const projectedDemand = dailySales * REPLENISHMENT_TARGET_DAYS;
const openProductionQuantity = openProductionByProductId[product.id] || 0;
const availableQuantity = product.stock + openProductionQuantity;
const availableQuantity = getPlanningStock(product.stock) + openProductionQuantity;
const suggestedReplenishment = Math.max(0, Math.ceil(projectedDemand - availableQuantity));
return {