Kaynağa Gözat

Obsoleted IsTransfer

Kenric Nugteren 1 yıl önce
ebeveyn
işleme
5fae482a15

+ 1 - 1
prs.classes/Entities/Product/ProductIssuedAggregate.cs

@@ -10,7 +10,7 @@ namespace Comal.Classes
         public override Expression<Func<StockMovement, DateTime>> Aggregate => x => x.Date;
 
         public override Filter<StockMovement> Filter =>
-            new Filter<StockMovement>(x => x.Issued).IsNotEqualTo(0.0F).And(x => x.IsTransfer).IsEqualTo(false);
+            new Filter<StockMovement>(x => x.Type).IsEqualTo(StockMovementType.Issue);
 
         public override Dictionary<Expression<Func<StockMovement, object>>, Expression<Func<Product, object>>> Links =>
             new Dictionary<Expression<Func<StockMovement, object>>, Expression<Func<Product, object>>>()

+ 1 - 1
prs.classes/Entities/Product/ProductReceivedAggregate.cs

@@ -10,7 +10,7 @@ namespace Comal.Classes
         public override Expression<Func<StockMovement, DateTime>> Aggregate => x => x.Date;
 
         public override Filter<StockMovement> Filter =>
-            new Filter<StockMovement>(x => x.Received).IsNotEqualTo(0.0F).And(x => x.IsTransfer).IsEqualTo(false);
+            new Filter<StockMovement>(x => x.Type).IsEqualTo(StockMovementType.Receive);
 
         public override Dictionary<Expression<Func<StockMovement, object>>, Expression<Func<Product, object>>> Links =>
             new Dictionary<Expression<Func<StockMovement, object>>, Expression<Func<Product, object>>>()

+ 1 - 0
prs.classes/Entities/Stock/StockMovement.cs

@@ -171,6 +171,7 @@ namespace Comal.Classes
         public bool System { get; set; }
 
         [NullEditor]
+        [Obsolete("Replaced with Type")]
         public bool IsTransfer { get; set; } = false;
 
         [NullEditor]

+ 1 - 1
prs.desktop/Panels/Jobs/Summary/JobSummaryGrid.cs

@@ -285,7 +285,7 @@ namespace PRSDesktop
                 x => x.Dimensions.UnitSize,
                 row.Get<StockSummary, String>(c => c.Dimensions.UnitSize),
                 x => x.Job.ID,
-                new Filter<StockMovement>(x => x.IsTransfer).IsEqualTo(false).And(x => x.Issued).IsNotEqualTo(0.0F),
+                new Filter<StockMovement>(x => x.Type).IsEqualTo(StockMovementType.Issue),
                 null
             );
         }

+ 0 - 7
prs.desktop/Panels/Products/Locations/StockHoldingGrid.cs

@@ -302,7 +302,6 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
                 mout.JobRequisitionItem.ID = requiitem.ID;
                 mout.Type = StockMovementType.TransferOut;
                 mout.Date = DateTime.Now;
-                mout.IsTransfer = true;
                 mout.Employee.ID = App.EmployeeID;
                 mout.Notes = $"Moved to {target.Code} by {App.EmployeeName}";
                 updates.Add(mout);
@@ -319,7 +318,6 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
                 min.Transaction = mout.Transaction;
                 min.Type = StockMovementType.TransferIn;
                 min.Date = mout.Date;
-                min.IsTransfer = true;
                 min.Employee.ID = App.EmployeeID;
                 min.Notes = $"Moved From {holding.Location.Code} by {App.EmployeeName}";
                 updates.Add(min);
@@ -366,7 +364,6 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
         movement.Job.Name = Location.Job.Name;
         movement.Location.Description = Location.Description;
         movement.Date = DateTime.Now;
-        movement.IsTransfer = false;
         movement.Employee.ID = App.EmployeeID;
         movement.Type = StockMovementType.Receive;
 
@@ -434,7 +431,6 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
             xferout.JobRequisitionItem.ID = requiID;
             xferout.Issued = issueObj.Qty;
             xferout.Transaction = issue.Transaction;
-            xferout.IsTransfer = true;
             xferout.System = true;
             xferout.Notes = $"Issued by {App.EmployeeName}";
             xferout.Date = issueObj.Date;
@@ -446,7 +442,6 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
             xferin.JobRequisitionItem.ID = requiID;
             xferin.Received = issueObj.Qty;
             xferin.Transaction = issue.Transaction;
-            xferin.IsTransfer = true;
             xferin.System = true;
             xferin.Notes = $"Issued by {App.EmployeeName}";
             xferin.Date = issueObj.Date;
@@ -527,7 +522,6 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
         var movement = CreateMovementFromHolding(holding);
         movement.JobRequisitionItem.ID = requiitems[0].ID;
         movement.Received = holding.Available;
-        movement.IsTransfer = true;
         movement.Type = StockMovementType.TransferIn;
 
         var smg = CheckStockMovementGrid(MovementAction.Transfer, holding);
@@ -543,7 +537,6 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
             var other = CreateMovementFromHolding(holding);
             other.Issued = movement.Received;
             other.Transaction = movement.Transaction;
-            other.IsTransfer = true;
             other.Type = StockMovementType.TransferOut;
             other.JobRequisitionItem.ID = requiitems[0].ID;
 

+ 0 - 1
prs.desktop/Panels/Products/Locations/StockTakeWindow.xaml.cs

@@ -419,7 +419,6 @@ namespace PRSDesktop
             var movement = new StockMovement();
 
             movement.Batch.ID = batchID;
-            movement.IsTransfer = false;
             movement.Issued = 0;
             movement.Received = 0;
             movement.Product.ID = holding.Product.ID;

+ 0 - 1
prs.desktop/Panels/Reservation Management/StockSelectionPage.xaml.cs

@@ -104,7 +104,6 @@ public partial class StockSelectionPage : ThemableWindow, INotifyPropertyChanged
         mvt.Dimensions.CopyFrom(model.Holding.Dimensions);
         mvt.Batch.ID = batchid;
         mvt.Employee.ID = App.EmployeeID;
-        mvt.IsTransfer = true;
         mvt.Date = DateTime.Now;
         mvt.Product.ID = Item.Product.ID;
         mvt.Notes = $"Reservation Management Screen - allocating to Job {Item.Job.JobNumber} for Requisition Line";

+ 1 - 1
prs.desktop/Panels/StockSummary/StockSummaryGrid.cs

@@ -190,7 +190,7 @@ public class StockSummaryGrid : DynamicDataGrid<StockSummary>, IDataModelSource
                 x=>x.Dimensions.UnitSize,
                 unitsize,
                 x => x.Job.ID,
-                new Filter<StockMovement>(x=>x.IsTransfer).IsEqualTo(false).And(x=>x.Issued).IsNotEqualTo(0.0F),
+                new Filter<StockMovement>(x => x.Type).IsEqualTo(StockMovementType.Issue),
                 null
             );
         }

+ 1 - 0
prs.shared/Database Update Scripts/DatabaseUpdateScripts.cs

@@ -45,5 +45,6 @@ public static class DatabaseUpdateScripts
         DataUpdater.RegisterUpdateScript<Update_7_55>();
         DataUpdater.RegisterUpdateScript<Update_7_56>();
         DataUpdater.RegisterUpdateScript<Update_7_62>();
+        DataUpdater.RegisterUpdateScript<Update_7_63>();
     }
 }

+ 66 - 0
prs.shared/Database Update Scripts/Update_7_63.cs

@@ -0,0 +1,66 @@
+using com.sun.net.ssl.@internal.ssl;
+using Comal.Classes;
+using InABox.Core;
+using InABox.Database;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PRS.Shared.Database_Update_Scripts;
+
+public class Update_7_63 : DatabaseUpdateScript
+{
+    public override VersionNumber Version => new VersionNumber(7, 63);
+
+    public override bool Update()
+    {
+        Logger.Send(LogType.Information, "", $"Updating uninitialised stock movement types");
+
+        while (true)
+        {
+            var movements = DbFactory.Provider.Query(
+                new Filter<StockMovement>(x => x.Type).IsEqualTo(null),
+                new Columns<StockMovement>(x => x.ID)
+                    .Add(x => x.Received)
+                    .Add(x => x.Issued)
+                    .Add(x => x.IsTransfer)
+                    .Add(x => x.Batch.Type),
+                top: 1000)
+                .ToArray<StockMovement>();
+            if (movements.Length == 0) break;
+
+            Logger.Send(LogType.Information, "", $"Updating {movements.Length} movements");
+
+            foreach(var movement in movements)
+            {
+                if (movement.IsTransfer)
+                {
+                    if(movement.Received > 0)
+                    {
+                        movement.Type = StockMovementType.TransferIn;
+                    }
+                    else
+                    {
+                        movement.Type = StockMovementType.TransferOut;
+                    }
+                }
+                else if(movement.Batch.Type == StockMovementBatchType.Stocktake)
+                {
+                    movement.Type = StockMovementType.StockTake;
+                }
+                else if(movement.Received > 0)
+                {
+                    movement.Type = StockMovementType.Receive;
+                }
+                else
+                {
+                    movement.Type = StockMovementType.Issue;
+                }
+            }
+            DbFactory.Provider.Save(movements);
+        }
+        return true;
+    }
+}

+ 2 - 2
prs.shared/Posters/Timberline/StockMovementTimberlinePoster.cs

@@ -241,7 +241,7 @@ public class Module
                     .Add(x => x.Transaction)
                     .Add(x => x.Job.ID)
                     .Add(x => x.Product.ID)
-                    .Add(x => x.IsTransfer)
+                    .Add(x => x.Type)
                     .Add(x => x.Units)
                     .Add(x => x.Cost)
                     .Add(x => x.Value)
@@ -329,7 +329,7 @@ public class Module
                 var movements = new List<StockMovement>();
                 foreach(var movement in transaction)
                 {
-                    if (!movement.IsTransfer)
+                    if (movement.Type != StockMovementType.TransferOut && movement.Type != StockMovementType.TransferIn)
                     {
                         // Ignore these ones.
                         result.AddSuccess(movement, null);