Improve planning data normalization
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m25s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m25s
This commit is contained in:
@@ -31,6 +31,7 @@ import { classifyCutFamily } from '../analytics/cutting';
|
||||
import { adjustSupplyLotInventory, approveSupplyReceipt, consumeSupplyLotForProduction, createSupplyFabricPlan, createSupplyReceipt, deleteSupplyFabricPlan, deleteSupplyReceipt, fetchCuttingSettings, fetchProductAnalytics, fetchSupplySummary } from '../dataService';
|
||||
import { parseProductName } from '../productParsing';
|
||||
import { resolveProductType, type ProductTypeKey } from '../productClassification';
|
||||
import { getPlanningStock } from '../planningStock';
|
||||
import type { CuttingSettings, DateRange, ProductAnalyticsItem, SupplyFabricPlan, SupplyLot, SupplyMovement, SupplyPurchaseNeed, SupplyReceipt, SupplySummary } from '../types';
|
||||
|
||||
type InventoryTab = 'dashboard' | 'balance' | 'receipts' | 'inventory' | 'movements';
|
||||
@@ -230,9 +231,10 @@ const buildDemandRow = (
|
||||
const color = override?.color || metadata.color;
|
||||
const size = (override?.size || metadata.size).toUpperCase();
|
||||
const dailySales = product.quantitySold / rangeDays;
|
||||
const daysOfCover = dailySales > 0 ? product.stock / dailySales : null;
|
||||
const planningStock = getPlanningStock(product.stock);
|
||||
const daysOfCover = dailySales > 0 ? planningStock / dailySales : null;
|
||||
const targetDemand = dailySales * targetCoverageDays;
|
||||
const suggestedUnits = Math.max(0, Math.ceil(targetDemand - product.stock));
|
||||
const suggestedUnits = Math.max(0, Math.ceil(targetDemand - planningStock));
|
||||
const missingData: string[] = [];
|
||||
|
||||
if (planningReviewTypes.has(productType)) missingData.push('tipo');
|
||||
|
||||
Reference in New Issue
Block a user