|
@@ -47,7 +47,6 @@ public class StockForecastOrderData
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public enum StockForecastOrderingType
|
|
|
{
|
|
|
StockOrder,
|
|
@@ -108,13 +107,13 @@ public class StockForecastOrderingItem : BaseObject
|
|
|
[EnumLookupEditor(typeof(SupplierProductOrderStrategy))]
|
|
|
public SupplierProductOrderStrategy OrderStrategy { get; set; }
|
|
|
|
|
|
- private StockForecastOrderingItemQuantity[] Quantities = [];
|
|
|
+ public StockForecastOrderingItemQuantity[] Quantities = [];
|
|
|
|
|
|
public StockForecastOrderingItemQuantity GetQuantity(int i) => Quantities[i];
|
|
|
|
|
|
public double GetTotalQuantity(StockForecastOrderingType type) => type == StockForecastOrderingType.StockOrder
|
|
|
- ? Quantities.Sum(x => x.StockTotal)
|
|
|
- : Quantities.Sum(x => x.JobTotal);
|
|
|
+ ? Quantities.Sum(x => x.Total)
|
|
|
+ : Quantities.Sum(x => x.Total);
|
|
|
|
|
|
public void SetQuantities(StockForecastOrderingItemQuantity[] quantities)
|
|
|
{
|
|
@@ -198,18 +197,18 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if(OrderType == StockForecastOrderingType.StockOrder && qty.StockTotal > 0)
|
|
|
+ if(OrderType == StockForecastOrderingType.StockOrder && qty.Total > 0)
|
|
|
{
|
|
|
- yield return new(supplier, null, item, qty.StockTotal, supplierProduct);
|
|
|
+ yield return new(supplier, null, item, qty.Total, supplierProduct);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- foreach(var (jobID, q) in qty.JobTotals)
|
|
|
+ foreach(var q in item.Quantities)
|
|
|
{
|
|
|
- if(q > 0)
|
|
|
- {
|
|
|
- yield return new(supplier, new() { ID = jobID }, item, q, supplierProduct);
|
|
|
- }
|
|
|
+ //if(q > 0)
|
|
|
+ //{
|
|
|
+ yield return new(supplier, new() { ID = Guid.Empty }, item, q.Total, supplierProduct);
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -422,12 +421,12 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
|
|
|
private SupplierProduct? SelectSupplierProduct(IEnumerable<SupplierProduct> supplierProducts, StockForecastOrderingItem item)
|
|
|
{
|
|
|
-
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
private double GetRequiredQuantity(StockForecastOrderingItem item, SupplierProduct supplierProduct)
|
|
|
{
|
|
|
-
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
protected override DynamicGridColumns LoadColumns()
|
|
@@ -538,13 +537,13 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
quantities[newIdx] = newQty;
|
|
|
if (OrderType == StockForecastOrderingType.StockOrder)
|
|
|
{
|
|
|
- newQty.StockTotal = 0;
|
|
|
+ newQty.Total = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- foreach (var id in item.GetJobRequiredQuantities().Keys)
|
|
|
+ foreach (var id in item.Quantities)
|
|
|
{
|
|
|
- newQty.JobTotals[id] = 0;
|
|
|
+ newQty.Total = 0;
|
|
|
}
|
|
|
}
|
|
|
item.SetQuantities(quantities);
|
|
@@ -630,11 +629,11 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
Background = new SolidColorBrush(Colors.LightYellow),
|
|
|
BorderThickness = new Thickness(0.0),
|
|
|
MinValue = 0.0,
|
|
|
- Value = Item.GetQuantity(SupplierIndex).StockTotal
|
|
|
+ Value = Item.GetQuantity(SupplierIndex).Total
|
|
|
};
|
|
|
editor.ValueChanged += (o, e) =>
|
|
|
{
|
|
|
- Item.GetQuantity(SupplierIndex).StockTotal = editor.Value ?? default;
|
|
|
+ Item.GetQuantity(SupplierIndex).Total = editor.Value ?? default;
|
|
|
};
|
|
|
Content = editor;
|
|
|
}
|
|
@@ -653,7 +652,7 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
Background = new SolidColorBrush(Colors.White),
|
|
|
BorderThickness = new Thickness(0.0),
|
|
|
IsReadOnly = true,
|
|
|
- Text = string.Format("{0:F2}", Item.GetQuantity(SupplierIndex).JobTotal)
|
|
|
+ Text = string.Format("{0:F2}", Item.GetQuantity(SupplierIndex).Total)
|
|
|
};
|
|
|
Grid.SetColumn(editor, 0);
|
|
|
grid.Children.Add(editor);
|
|
@@ -672,39 +671,39 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
btn.Click += (o, e) =>
|
|
|
{
|
|
|
var qty = Item.GetQuantity(SupplierIndex);
|
|
|
-
|
|
|
- Parent.LoadJobData(qty.JobTotals.Keys);
|
|
|
-
|
|
|
- var items = qty.JobTotals.Select(x =>
|
|
|
- {
|
|
|
- var item = new StockForecastOrderingJobItem
|
|
|
- {
|
|
|
- JobID = x.Key,
|
|
|
- RequiredQuantity = Item.GetJobRequiredQuantities().GetValueOrDefault(x.Key),
|
|
|
- Quantity = x.Value
|
|
|
- };
|
|
|
- if(item.JobID == Guid.Empty)
|
|
|
- {
|
|
|
- item.Job = "General Stock";
|
|
|
- }
|
|
|
- else if(Parent.JobDetails.TryGetValue(item.JobID, out var job))
|
|
|
- {
|
|
|
- item.Job = $"{job.JobNumber}: {job.Name}";
|
|
|
- }
|
|
|
- return item;
|
|
|
- }).ToList();
|
|
|
-
|
|
|
- var window = new StockForecastOrderJobScreen();
|
|
|
- window.Items = items;
|
|
|
- if(window.ShowDialog() == true)
|
|
|
- {
|
|
|
- foreach(var item in items)
|
|
|
- {
|
|
|
- qty.JobTotals[item.JobID] = item.Quantity;
|
|
|
- }
|
|
|
- qty.DoChanged();
|
|
|
- editor.Text = string.Format("{0:F2}", Item.GetQuantity(SupplierIndex).JobTotal);
|
|
|
- }
|
|
|
+
|
|
|
+ // Parent.LoadJobData(qty.JobTotals.Keys);
|
|
|
+ //
|
|
|
+ // var items = qty.JobTotals.Select(x =>
|
|
|
+ // {
|
|
|
+ // var item = new StockForecastOrderingJobItem
|
|
|
+ // {
|
|
|
+ // JobID = x.Key,
|
|
|
+ // RequiredQuantity = Item.GetJobRequiredQuantities().GetValueOrDefault(x.Key),
|
|
|
+ // Quantity = x.Value
|
|
|
+ // };
|
|
|
+ // if(item.JobID == Guid.Empty)
|
|
|
+ // {
|
|
|
+ // item.Job = "General Stock";
|
|
|
+ // }
|
|
|
+ // else if(Parent.JobDetails.TryGetValue(item.JobID, out var job))
|
|
|
+ // {
|
|
|
+ // item.Job = $"{job.JobNumber}: {job.Name}";
|
|
|
+ // }
|
|
|
+ // return item;
|
|
|
+ // }).ToList();
|
|
|
+ //
|
|
|
+ // var window = new StockForecastOrderJobScreen();
|
|
|
+ // window.Items = items;
|
|
|
+ // if(window.ShowDialog() == true)
|
|
|
+ // {
|
|
|
+ // foreach(var item in items)
|
|
|
+ // {
|
|
|
+ // qty.JobTotals[item.JobID] = item.Quantity;
|
|
|
+ // }
|
|
|
+ // qty.DoChanged();
|
|
|
+ // editor.Text = string.Format("{0:F2}", Item.GetQuantity(SupplierIndex).JobTotal);
|
|
|
+ // }
|
|
|
};
|
|
|
grid.Children.Add(btn);
|
|
|
|
|
@@ -766,8 +765,8 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
|
|
|
var instance = LoadItem(row);
|
|
|
var qty = OrderType == StockForecastOrderingType.StockOrder
|
|
|
- ? instance.GetQuantity(idx).StockTotal
|
|
|
- : instance.GetQuantity(idx).JobTotal;
|
|
|
+ ? instance.GetQuantity(idx).Total
|
|
|
+ : instance.GetQuantity(idx).Total;
|
|
|
var supplierProduct = GetSupplierProduct(instance, Suppliers[idx].ID);
|
|
|
if(supplierProduct is not null)
|
|
|
{
|
|
@@ -885,7 +884,7 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
if(supplierProduct is not null)
|
|
|
{
|
|
|
var qty = item.GetQuantity(SupplierIndex);
|
|
|
- Sum += qty.GetTotal(Grid.OrderType) * supplierProduct.CostPrice;
|
|
|
+ Sum += qty.Total /*GetTotal(Grid.OrderType)*/ * supplierProduct.CostPrice;
|
|
|
}
|
|
|
}
|
|
|
}
|