|
@@ -37,7 +37,7 @@ public class StockForecastOrderData(ProductLink product, ProductStyleLink style,
|
|
|
|
|
|
public class QuantityBreakup(Guid jobID, Guid requiID, string description, double qty)
|
|
|
{
|
|
|
- public Guid JobID { get; set; } = jobID;
|
|
|
+ public Guid JobID { get; set; } = jobID != Guid.Empty ? jobID : throw new ArgumentException("jobID cannot be Guid.Empty!", "jobID");
|
|
|
|
|
|
public Guid JobRequiItemID { get; set; } = requiID;
|
|
|
|
|
@@ -269,6 +269,23 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
HiddenColumns.Add(x => x.Product.Image.ID);
|
|
|
}
|
|
|
|
|
|
+ public bool Validate()
|
|
|
+ {
|
|
|
+ if(OrderType == StockForecastOrderingType.Breakup)
|
|
|
+ {
|
|
|
+ foreach(var item in Items)
|
|
|
+ {
|
|
|
+ var sum = item.Breakups.Sum(x => x.Quantity);
|
|
|
+ if(sum > item.GetTotalQuantity(OrderType))
|
|
|
+ {
|
|
|
+ MessageWindow.ShowMessage($"Not enough being ordered for {item.Product.Code}/{item.Style.Code}: requires at least {sum}", "Not enough");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
#region UI Component
|
|
|
|
|
|
private Component? _uiComponent;
|
|
@@ -482,6 +499,8 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
DoChanged();
|
|
|
}
|
|
|
|
|
|
+ #region Order Strategy
|
|
|
+
|
|
|
private SupplierProduct? SelectSupplierProduct(IEnumerable<SupplierProduct> supplierProducts, StockForecastOrderingItem item)
|
|
|
{
|
|
|
switch (item.OrderStrategy)
|
|
@@ -534,6 +553,8 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ #endregion
|
|
|
+
|
|
|
private bool _loadedColumns = false;
|
|
|
protected override DynamicGridColumns LoadColumns()
|
|
|
{
|
|
@@ -697,23 +718,6 @@ public class StockForecastOrderingGrid : DynamicItemsListGrid<StockForecastOrder
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // private void LoadJobData(IEnumerable<Guid> ids)
|
|
|
- // {
|
|
|
- // var neededIDs = ids.Where(x => !JobDetails.ContainsKey(x)).ToArray();
|
|
|
- // if(neededIDs.Length > 0)
|
|
|
- // {
|
|
|
- // var details = Client.Query(
|
|
|
- // new Filter<Job>(x => x.ID).InList(neededIDs),
|
|
|
- // Columns.None<Job>().Add(x => x.ID)
|
|
|
- // .Add(x => x.JobNumber)
|
|
|
- // .Add(x => x.Name));
|
|
|
- // foreach(var job in details.ToObjects<Job>())
|
|
|
- // {
|
|
|
- // JobDetails[job.ID] = job;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
private class QuantityControl : ContentControl
|
|
|
{
|
|
|
private readonly StockForecastOrderingItem Item;
|