Преглед изворни кода

Added better default columns to StockMovementGrid

Kenric Nugteren пре 10 месеци
родитељ
комит
099fb16d80

+ 22 - 0
prs.desktop/Panels/Products/Locations/StockMovementGrid.cs

@@ -77,6 +77,28 @@ public class StockMovementGrid : DynamicDataGrid<StockMovement>, IDataModelSourc
         });
     }
 
+    public override DynamicGridColumns GenerateColumns()
+    {
+        var columns = new DynamicGridColumns();
+
+        columns.Add<StockMovement, DateTime>(x => x.Date, 120, "Date", "dd MMM yyyy hh:mm", Alignment.MiddleCenter);
+        columns.Add<StockMovement, string>(x => x.Job.JobNumber, 120, "Job Number", "", Alignment.MiddleCenter);
+        columns.Add<StockMovement, string>(x => x.Location.Code, 120, "Location", "", Alignment.MiddleCenter);
+        columns.Add<StockMovement, string>(x => x.Product.Code, 120, "Product Code", "", Alignment.MiddleCenter);
+        columns.Add<StockMovement, string>(x => x.Product.Name, 0, "Product Name", "", Alignment.MiddleLeft);
+        columns.Add<StockMovement, string>(x => x.Style.Code, 120, "Style", "", Alignment.MiddleCenter);
+        columns.Add<StockMovement, string>(x => x.Dimensions.UnitSize, 120, "Size", "", Alignment.MiddleCenter);
+
+        columns.Add<StockMovement, double>(x => x.Received, 70, "Received", "F2", Alignment.MiddleRight);
+        columns.Add<StockMovement, double>(x => x.Issued, 70, "Issued", "F2", Alignment.MiddleRight);
+        columns.Add<StockMovement, double>(x => x.Cost, 70, "Cost", "C2", Alignment.MiddleRight);
+
+        columns.Add<StockMovement, string>(x => x.Employee.Code, 120, "Employee", "", Alignment.MiddleCenter);
+        columns.Add<StockMovement, StockMovementType>(x => x.Type, 120, "Type", "", Alignment.MiddleCenter);
+
+        return columns;
+    }
+
     public DateTime StartDate { get; set; } = DateTime.MinValue;
     public DateTime EndDate { get; set; } = DateTime.MaxValue;
 

+ 12 - 4
prs.stores/StockMovementStore.cs

@@ -22,9 +22,15 @@ public class StockMovementStore : BaseStore<StockMovement>
 
         if(sm.Job.HasOriginalValue(x => x.ID) && sm.Job.ID != Guid.Empty && sm.JobScope.ID == Guid.Empty)
         {
+            // If we have updated the Job.ID to a non-empty value, we should
+            // update the JobScope to the default job scope for that job.
+
             var scopeID = Guid.Empty;
             if(sm.ID != Guid.Empty)
             {
+                // It's possible that the JobScope ID just wasn't passed up, if
+                // this entity already exists; hence, we shall load the scopeID
+                // from the database just in case.
                 scopeID = Provider.Query(
                     new Filter<StockMovement>(x => x.ID).IsEqualTo(sm.ID),
                     Columns.None<StockMovement>().Add(x => x.JobScope.ID))
@@ -32,6 +38,8 @@ public class StockMovementStore : BaseStore<StockMovement>
             }
             if(scopeID == Guid.Empty)
             {
+                // No scope has been assigned; however, we have a job, so we
+                // load the default scope for the job.
                 sm.JobScope.ID = Provider.Query(
                     new Filter<Job>(x => x.ID).IsEqualTo(sm.Job.ID),
                     Columns.None<Job>().Add(x => x.DefaultScope.ID))
@@ -61,12 +69,12 @@ public class StockMovementStore : BaseStore<StockMovement>
     {
         base.BeforeDelete(entity);
         
-        // We need to do this in before delete, because aotherwise we wont have the data
-        // that we need to pull to properly update the stockholdings
+        // We need to do this in before delete, because otherwise we wont have
+        // the data that we need to pull to properly update the stockholdings
         StockHoldingStore.UpdateStockHolding(this, entity.ID,StockHoldingStore.Action.Decrease);
         
-        // Now let's pull the requisition ID, so that we can clean this up properly
-        // in AfterDelete()
+        // Now let's pull the requisition ID, so that we can clean this up
+        // properly in AfterDelete()
         entity.JobRequisitionItem.ID = Provider.Query(
                 new Filter<StockMovement>(x => x.ID).IsEqualTo(entity.ID),
                 Columns.None<StockMovement>().Add(x => x.JobRequisitionItem.ID)