|  | @@ -1087,13 +1087,7 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockOrderingItem>
 | 
	
		
			
				|  |  |              ContextMenu = contextMenuFunc,
 | 
	
		
			
				|  |  |              GetSummary = () =>
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  | -                var summary = new GridSummaryColumn
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    Format = "{Sum:C2}",
 | 
	
		
			
				|  |  | -                    SummaryType = Syncfusion.Data.SummaryType.Custom,
 | 
	
		
			
				|  |  | -                    CustomAggregate = new CostAggregate(idx, this)
 | 
	
		
			
				|  |  | -                };
 | 
	
		
			
				|  |  | -                return summary;
 | 
	
		
			
				|  |  | +                return new DynamicGridCustomSummary((rows) => Cost_Aggregate(idx, rows), "C2");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |          ActionColumns.Add(SupplierProductColumns[idx]);
 | 
	
	
		
			
				|  | @@ -1101,6 +1095,23 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockOrderingItem>
 | 
	
		
			
				|  |  |          ActionColumns.Add(CostColumns[idx]);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private double Cost_Aggregate(int supplierIdx, IEnumerable<CoreRow> rows)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        return rows.Sum(row =>
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            var item = LoadItem(row);
 | 
	
		
			
				|  |  | +            var qty = item.GetQuantity(supplierIdx);
 | 
	
		
			
				|  |  | +            if(qty.SupplierProduct is not null)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                return qty.OrderTotal * qty.SupplierProduct.CostPrice;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            else
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                return 0;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      private void CreateSupplierProduct_Click(Tuple<StockOrderingItem, int> tuple)
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |          var (item, supplierIdx) = tuple;
 | 
	
	
		
			
				|  | @@ -1127,47 +1138,4 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockOrderingItem>
 | 
	
		
			
				|  |  |              InvalidateGrid();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -    private class CostAggregate : ISummaryAggregate
 | 
	
		
			
				|  |  | -    {
 | 
	
		
			
				|  |  | -        public double Sum { get; private set; }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private int SupplierIndex;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private StockForecastOrderingGrid Grid;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public CostAggregate(int supplierIndex, StockForecastOrderingGrid grid)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            SupplierIndex = supplierIndex;
 | 
	
		
			
				|  |  | -            Grid = grid;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public Action<IEnumerable, string, PropertyDescriptor> CalculateAggregateFunc()
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            return AggregateFunc;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        private void AggregateFunc(IEnumerable items, string property, PropertyDescriptor args)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            if (items is IEnumerable<DataRowView> rows)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                Sum = 0;
 | 
	
		
			
				|  |  | -                foreach (var dataRow in rows)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    var rowIdx = dataRow.Row.Table.Rows.IndexOf(dataRow.Row);
 | 
	
		
			
				|  |  | -                    var item = Grid.LoadItem(Grid.Data.Rows[rowIdx]);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    var qty = item.GetQuantity(SupplierIndex);
 | 
	
		
			
				|  |  | -                    if(qty.SupplierProduct is not null)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        Sum += qty.OrderTotal * qty.SupplierProduct.CostPrice;
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            else
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                Logger.Send(LogType.Error, "", $"Attempting to calculate aggregate on invalid data type '{items.GetType()}'.");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  |  }
 |