|
|
@@ -472,6 +472,25 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockOrderingItem>
|
|
|
return supplierProduct;
|
|
|
}
|
|
|
|
|
|
+ private void SetSupplierProduct(StockOrderingItem item, SupplierProduct supplierProduct)
|
|
|
+ {
|
|
|
+ var supplierIdx = Suppliers.WithIndex()
|
|
|
+ .FirstOrDefault(x => x.Value.ID == supplierProduct.SupplierLink.ID, new KeyValuePair<int, SupplierLink>(-1, null)).Key;
|
|
|
+ if(supplierIdx != -1)
|
|
|
+ {
|
|
|
+ var qty = item.GetQuantity(supplierIdx);
|
|
|
+ if(OrderType == StockForecastOrderingType.Breakup)
|
|
|
+ {
|
|
|
+ qty.Breakups.Clear();
|
|
|
+ foreach(var (id, q) in item.GetJobRequiredQuantities())
|
|
|
+ {
|
|
|
+ qty.Breakups[id] = q;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ qty.OrderTotal = GetRequiredQuantity(item, supplierProduct);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void CalculateSupplierProduct(StockOrderingItem item)
|
|
|
{
|
|
|
var selectedSupplierProducts = new List<SupplierProduct>();
|
|
|
@@ -483,25 +502,10 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockOrderingItem>
|
|
|
selectedSupplierProducts.Add(supplierProduct);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
var selectedSupplierProduct = SelectSupplierProduct(selectedSupplierProducts, item);
|
|
|
if(selectedSupplierProduct is not null)
|
|
|
{
|
|
|
- var supplierIdx = Suppliers.WithIndex()
|
|
|
- .FirstOrDefault(x => x.Value.ID == selectedSupplierProduct.SupplierLink.ID, new KeyValuePair<int, SupplierLink>(-1, null)).Key;
|
|
|
- if(supplierIdx != -1)
|
|
|
- {
|
|
|
- var qty = item.GetQuantity(supplierIdx);
|
|
|
- if(OrderType == StockForecastOrderingType.Breakup)
|
|
|
- {
|
|
|
- qty.Breakups.Clear();
|
|
|
- foreach(var (id, q) in item.GetJobRequiredQuantities())
|
|
|
- {
|
|
|
- qty.Breakups[id] = q;
|
|
|
- }
|
|
|
- }
|
|
|
- qty.OrderTotal = GetRequiredQuantity(item, selectedSupplierProduct);
|
|
|
- }
|
|
|
+ SetSupplierProduct(item, selectedSupplierProduct);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1113,7 +1117,12 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockOrderingItem>
|
|
|
var qty = item.GetQuantity(supplierIdx);
|
|
|
if(qty.SupplierProduct is null)
|
|
|
{
|
|
|
- CalculateSupplierProduct(item, supplierIdx);
|
|
|
+ var hasSelected = item.Quantities.Any(x => x.SupplierProduct is not null);
|
|
|
+ var sp = CalculateSupplierProduct(item, supplierIdx);
|
|
|
+ if(!hasSelected && sp is not null)
|
|
|
+ {
|
|
|
+ SetSupplierProduct(item, sp);
|
|
|
+ }
|
|
|
}
|
|
|
InvalidateGrid();
|
|
|
}
|