|
@@ -17,25 +17,31 @@ public class Update_7_63 : DatabaseUpdateScript
|
|
|
public override bool Update()
|
|
|
{
|
|
|
Logger.Send(LogType.Information, "", $"Updating uninitialised stock movement types");
|
|
|
-
|
|
|
+ int iCount = 0;
|
|
|
while (true)
|
|
|
{
|
|
|
- var movements = DbFactory.Provider.Query(
|
|
|
+ var movements = DbFactory.Provider.Query(typeof(StockMovement),
|
|
|
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");
|
|
|
+ .Add(x => x.Batch.Type)
|
|
|
+ .Add("IsTransfer"),
|
|
|
+ top: 1000);
|
|
|
+
|
|
|
+ if (movements.Rows.Count == 0)
|
|
|
+ break;
|
|
|
+
|
|
|
+ iCount += movements.Rows.Count;
|
|
|
+ Logger.Send(LogType.Information, "", $"Updating {iCount} movements");
|
|
|
|
|
|
- foreach(var movement in movements)
|
|
|
+ List<StockMovement> updates = new List<StockMovement>();
|
|
|
+ foreach(var row in movements.Rows)
|
|
|
{
|
|
|
- if (movement.IsTransfer)
|
|
|
+
|
|
|
+ var istransfer = row.Get<bool>("IsTransfer");
|
|
|
+ var movement = row.ToObject<StockMovement>();
|
|
|
+ if (istransfer)
|
|
|
{
|
|
|
if(movement.Received > 0)
|
|
|
{
|
|
@@ -60,8 +66,9 @@ public class Update_7_63 : DatabaseUpdateScript
|
|
|
}
|
|
|
// manually setting original value because originally the same.
|
|
|
movement.SetOriginalValue(x => x.Type, StockMovementType.Receive);
|
|
|
+ updates.Add(movement);
|
|
|
}
|
|
|
- DbFactory.Provider.Save(movements);
|
|
|
+ DbFactory.Provider.Save(updates);
|
|
|
}
|
|
|
return true;
|
|
|
}
|