|
|
@@ -243,7 +243,13 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
if (holding.Available.IsEffectivelyEqual(holding.Units))
|
|
|
column.AddItem("(No Requisitions in this Holding", null, null).IsEnabled = false;
|
|
|
else
|
|
|
+ {
|
|
|
column.AddItem("View Requisition Items", null, ViewRequisitions_Click);
|
|
|
+ if (Security.IsAllowed<CanEditAllocatedJobRequisitions>())
|
|
|
+ {
|
|
|
+ column.GetMenu().AddItem("Release allocated stock", null, holding, ReleaseAllocatedStock_Click);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
column.AddSeparator();
|
|
|
|
|
|
@@ -281,6 +287,51 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void ReleaseAllocatedStock_Click(StockHolding holding)
|
|
|
+ {
|
|
|
+ var requiitems = holding.LoadRequisitionItems(true).Where(x => x.ID != Guid.Empty).ToList();
|
|
|
+ var win = new StockHoldingRelocationWindow(holding, requiitems)
|
|
|
+ {
|
|
|
+ ShowFrom = false,
|
|
|
+ IsTargetEditable = false,
|
|
|
+ Title = "Release Stock"
|
|
|
+ };
|
|
|
+ if (win.ShowDialog() == true)
|
|
|
+ {
|
|
|
+ var quantities = win.GetQuantities();
|
|
|
+
|
|
|
+ var updates = new List<StockMovement>();
|
|
|
+ foreach(var requi in requiitems)
|
|
|
+ {
|
|
|
+ if (!quantities.TryGetValue(requi.ID, out var qty) || qty <= 0) continue;
|
|
|
+
|
|
|
+ var mout = holding.CreateMovement();
|
|
|
+ mout.Issued = qty;
|
|
|
+ mout.Cost = holding.AverageValue;
|
|
|
+ mout.JobRequisitionItem.ID = requi.ID;
|
|
|
+ mout.Date = DateTime.Now;
|
|
|
+ mout.Employee.ID = App.EmployeeID;
|
|
|
+ mout.Notes = $"Released from Job Requisition {requi.Requisition.Number}: {requi.Requisition.Description} for Job {requi.Job.JobNumber}";
|
|
|
+ mout.Type = StockMovementType.TransferOut;
|
|
|
+
|
|
|
+ var min = mout.CreateMovement();
|
|
|
+ min.Received = qty;
|
|
|
+ min.Cost = holding.AverageValue;
|
|
|
+ min.JobRequisitionItem.ID = Guid.Empty;
|
|
|
+ min.Date = DateTime.Now;
|
|
|
+ min.Employee.ID = App.EmployeeID;
|
|
|
+ min.Notes = $"Released from Job Requisition {requi.Requisition.Number}: {requi.Requisition.Description} for Job {requi.Job.JobNumber}";
|
|
|
+ min.Type = StockMovementType.TransferIn;
|
|
|
+
|
|
|
+ updates.Add(mout);
|
|
|
+ updates.Add(min);
|
|
|
+ }
|
|
|
+ SaveBatch(StockMovementBatchType.Transfer, updates);
|
|
|
+ DoChanged();
|
|
|
+ Refresh(false, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private class StockIssue : BaseObject
|
|
|
{
|
|
|
[EditorSequence(0)]
|
|
|
@@ -496,8 +547,8 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
|
|
|
updates.AddRange(CreateIssue(holding, issue, requi.ID));
|
|
|
}
|
|
|
+ SaveBatch(StockMovementBatchType.Issue, updates);
|
|
|
DoChanged();
|
|
|
- SaveBatch(StockMovementBatchType.Issue, updates.ToArray());
|
|
|
Refresh(false,true);
|
|
|
}
|
|
|
}
|
|
|
@@ -510,7 +561,7 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
if (DynamicGridUtils.EditObject(sjs))
|
|
|
{
|
|
|
var mvts = CreateIssue(holding, sjs, Guid.Empty);
|
|
|
- SaveBatch(StockMovementBatchType.Issue, mvts.AsArray());
|
|
|
+ SaveBatch(StockMovementBatchType.Issue, mvts.ToArray());
|
|
|
Refresh(false, true);
|
|
|
}
|
|
|
}
|