|
@@ -123,7 +123,7 @@ public class StockSummaryOrderingResult
|
|
|
|
|
|
public class StockSummaryOrderingGrid : DynamicItemsListGrid<StockSummaryOrderingItem>, ISpecificGrid
|
|
|
{
|
|
|
- private SupplierProduct[] SupplierProducts = [];
|
|
|
+ private List<SupplierProduct> SupplierProducts = [];
|
|
|
private SupplierLink[] Suppliers = [];
|
|
|
|
|
|
public double TotalQuantity => Items.Sum(x => x.GetTotalQuantity(OrderType));
|
|
@@ -284,7 +284,7 @@ public class StockSummaryOrderingGrid : DynamicItemsListGrid<StockSummaryOrderin
|
|
|
.And(x => x.SupplierLink.ID).IsNotEqualTo(Guid.Empty),
|
|
|
supplierColumns,
|
|
|
new SortOrder<SupplierProduct>(x => x.SupplierLink.Code))
|
|
|
- .ToArray<SupplierProduct>();
|
|
|
+ .ToList<SupplierProduct>();
|
|
|
|
|
|
Suppliers = SupplierProducts.Select(x => x.SupplierLink).DistinctBy(x => x.ID).ToArray();
|
|
|
|
|
@@ -343,7 +343,7 @@ public class StockSummaryOrderingGrid : DynamicItemsListGrid<StockSummaryOrderin
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- foreach(var id in qty.JobTotals.Keys)
|
|
|
+ foreach(var id in item.GetJobRequiredQuantities().Keys)
|
|
|
{
|
|
|
qty.JobTotals[id] = 0;
|
|
|
}
|
|
@@ -543,6 +543,23 @@ public class StockSummaryOrderingGrid : DynamicItemsListGrid<StockSummaryOrderin
|
|
|
{
|
|
|
var supplierProducts = SupplierProducts.Where(x => x.SupplierLink.ID == Suppliers[idx].ID).ToArray();
|
|
|
|
|
|
+ var contextMenuFunc = (CoreRow[]? rows) =>
|
|
|
+ {
|
|
|
+ var row = rows?.FirstOrDefault();
|
|
|
+ if (row is null) return null;
|
|
|
+
|
|
|
+ var item = LoadItem(row);
|
|
|
+ var supplierProduct = GetSupplierProduct(item, Suppliers[idx].ID);
|
|
|
+ if (supplierProduct is not null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ var menu = new ContextMenu();
|
|
|
+ menu.AddItem("Create Supplier Product", null, new Tuple<StockSummaryOrderingItem, int>(item, idx), CreateSupplierProduct_Click);
|
|
|
+ return menu;
|
|
|
+ };
|
|
|
+
|
|
|
// Making local copy of index so that the lambda can use it, and not the changed value of 'i'.
|
|
|
var qtyColumn = new Tuple<DynamicActionColumn, QuantityControl?>(null!, null);
|
|
|
QuantityColumns[idx] = new DynamicTemplateColumn(row =>
|
|
@@ -554,7 +571,8 @@ public class StockSummaryOrderingGrid : DynamicItemsListGrid<StockSummaryOrderin
|
|
|
})
|
|
|
{
|
|
|
HeaderText = "Qty.",
|
|
|
- Width = 80
|
|
|
+ Width = 80,
|
|
|
+ ContextMenu = contextMenuFunc
|
|
|
};
|
|
|
CostColumns[idx] = new DynamicTextColumn(row =>
|
|
|
{
|
|
@@ -580,6 +598,7 @@ public class StockSummaryOrderingGrid : DynamicItemsListGrid<StockSummaryOrderin
|
|
|
{
|
|
|
HeaderText = "Cost",
|
|
|
Width = 80,
|
|
|
+ ContextMenu = contextMenuFunc,
|
|
|
GetSummary = () =>
|
|
|
{
|
|
|
var i = idx * 2 + 1;
|
|
@@ -596,6 +615,23 @@ public class StockSummaryOrderingGrid : DynamicItemsListGrid<StockSummaryOrderin
|
|
|
ActionColumns.Add(CostColumns[idx]);
|
|
|
}
|
|
|
|
|
|
+ private void CreateSupplierProduct_Click(Tuple<StockSummaryOrderingItem, int> tuple)
|
|
|
+ {
|
|
|
+ var (item, supplierIdx) = tuple;
|
|
|
+
|
|
|
+ var supplierProduct = new SupplierProduct();
|
|
|
+ supplierProduct.Product.CopyFrom(item.Product);
|
|
|
+ supplierProduct.Style.CopyFrom(item.Style);
|
|
|
+ supplierProduct.Dimensions.CopyFrom(item.Dimensions);
|
|
|
+ supplierProduct.SupplierLink.CopyFrom(Suppliers[supplierIdx]);
|
|
|
+
|
|
|
+ if (DynamicGridUtils.EditEntity(supplierProduct))
|
|
|
+ {
|
|
|
+ SupplierProducts.Add(supplierProduct);
|
|
|
+ InvalidateGrid();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static bool Matches(StockSummaryOrderingItem item, SupplierProduct supplierProduct)
|
|
|
{
|
|
|
return item.Product.ID == supplierProduct.Product.ID
|