浏览代码

Replacing StockLocation.CurrentStockTake DateTime with StockMovementBatchLink for better tracking of Stocktakes

frogsoftware 2 月之前
父节点
当前提交
9e8d8b1ca2

+ 13 - 2
prs.classes/Entities/Stock/StockLocation/StockLocation.cs

@@ -114,9 +114,20 @@ namespace Comal.Classes
         [EditorSequence("Stocktake",3)] 
         public DateTime NextStocktake { get; set; } = DateTime.MaxValue;
 
-        [EditorSequence("Stocktake",4)] 
-        [DateEditor] 
+        [NullEditor] 
+        [Obsolete("Replaced with StocktakeLink", false)]
         public DateTime CurrentStocktake { get; set; } = DateTime.MinValue;
+        
+        private class StocktakeLookup : LookupDefinitionGenerator<StockMovementBatch, StockLocation>
+        {
+            public override Filter<StockMovementBatch> DefineFilter(StockLocation[] items)
+            {
+                return new Filter<StockMovementBatch>(x => x.Type).IsEqualTo(StockMovementBatchType.Stocktake);
+            }
+        }
+        [LookupDefinition(typeof(StocktakeLookup))]
+        [EditorSequence("Stocktake",4)] 
+        public StockMovementBatchLink Stocktake { get; set; }
 
         private static DateTime CalculateNextStockTake(DateTime last, StockTakeFrequency frequency)
         {

+ 0 - 20
prs.classes/Entities/Stock/StockMovement/StockMovementBatch.cs

@@ -54,24 +54,4 @@ namespace Comal.Classes
 
         public RequisitionLink Requisition { get; set; }
     }
-
-    public class StockMovementBatchLink : EntityLink<StockMovementBatch>, IStockMovementBatch
-    {
-        [EnumLookupEditor(typeof(StockMovementBatchType), Visible = Visible.Optional, Editable = Editable.Hidden)]
-        public StockMovementBatchType Type { get; set; }
-
-        [MemoEditor(Visible = Visible.Optional, Editable = Editable.Hidden)]
-        public string Notes { get; set; }
-
-        [NullEditor]
-        public int Documents { get; set; }
-
-        [NullEditor]
-        public override Guid ID { get; set; }
-    }
-
-    [UserTracking(typeof(StockMovement))]
-    public class StockMovementBatchDocument : EntityDocument<StockMovementBatchLink>, ILicense<WarehouseLicense>, IManyToMany<StockMovementBatch,Document>
-    {
-    }
 }

+ 9 - 0
prs.classes/Entities/Stock/StockMovement/StockMovementBatchDocument.cs

@@ -0,0 +1,9 @@
+using InABox.Core;
+
+namespace Comal.Classes
+{
+    [UserTracking(typeof(StockMovement))]
+    public class StockMovementBatchDocument : EntityDocument<StockMovementBatchLink>, ILicense<WarehouseLicense>, IManyToMany<StockMovementBatch,Document>
+    {
+    }
+}

+ 20 - 0
prs.classes/Entities/Stock/StockMovement/StockMovementBatchLink.cs

@@ -0,0 +1,20 @@
+using System;
+using InABox.Core;
+
+namespace Comal.Classes
+{
+    public class StockMovementBatchLink : EntityLink<StockMovementBatch>, IStockMovementBatch
+    {
+        [EnumLookupEditor(typeof(StockMovementBatchType), Visible = Visible.Optional, Editable = Editable.Hidden)]
+        public StockMovementBatchType Type { get; set; }
+
+        [MemoEditor(Visible = Visible.Optional, Editable = Editable.Hidden)]
+        public string Notes { get; set; }
+
+        [NullEditor]
+        public int Documents { get; set; }
+
+        [PopupEditor(typeof(StockMovementBatchLink))]
+        public override Guid ID { get; set; }
+    }
+}

+ 3 - 2
prs.desktop/Panels/Products/Locations/StockLocationGrid.cs

@@ -33,6 +33,7 @@ public class StockLocationGrid : DynamicDataGrid<StockLocation>
         HiddenColumns.Add(x => x.StocktakeFrequency);
         HiddenColumns.Add(x => x.LastStocktake);
         HiddenColumns.Add(x => x.CurrentStocktake);
+        HiddenColumns.Add(x => x.Stocktake.ID);
         HiddenColumns.Add(x => x.NextStocktake);
         
         ActionColumns.Add(new DynamicImageColumn(StockTakeStatusImage) { ToolTip = StockTakeStatusToolTip, Position = DynamicActionColumnPosition.Start });
@@ -47,7 +48,7 @@ public class StockLocationGrid : DynamicDataGrid<StockLocation>
     {
         return row == null
             ? column.TextToolTip("Indicates the Stocktake status of this location")
-            : !row.Get<StockLocation, DateTime>(x => x.CurrentStocktake).IsEmpty()
+            : !row.Get<StockLocation, DateTime>(x => x.CurrentStocktake).IsEmpty() || row.Get<StockLocation, Guid>(x => x.Stocktake.ID) != Guid.Empty
                 ? column.TextToolTip("Stocktake in progress")
                 : !row.Get<StockLocation, DateTime>(x => x.NextStocktake).IsEmpty()
                     ? column.TextToolTip(
@@ -59,7 +60,7 @@ public class StockLocationGrid : DynamicDataGrid<StockLocation>
     {
         return row == null
             ? _stocktakeheader
-            : !row.Get<StockLocation, DateTime>(x => x.CurrentStocktake).IsEmpty()
+            : !row.Get<StockLocation, DateTime>(x => x.CurrentStocktake).IsEmpty() || row.Get<StockLocation, Guid>(x => x.Stocktake.ID) != Guid.Empty
                 ? _stocktakeinprogress
                 : !row.Get<StockLocation, DateTime>(x => x.NextStocktake).IsEmpty()
                     ? row.Get<StockLocation, DateTime>(x => x.NextStocktake).Date > DateTime.Today