|
@@ -266,8 +266,11 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
column.AddItem("Relocate Items", null, r => RelocateItems(holding, requiitems.ToArray()));
|
|
|
}
|
|
|
|
|
|
- private class StockJobSelection : BaseObject
|
|
|
+ private class StockIssue : BaseObject
|
|
|
{
|
|
|
+ [EditorSequence(0)]
|
|
|
+ public DateTime Date { get; set; } = DateTime.Now;
|
|
|
+
|
|
|
[EditorSequence(1)]
|
|
|
public JobLink Job { get; set; }
|
|
|
|
|
@@ -283,7 +286,7 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
var quantities = win.GetQuantities();
|
|
|
var target = win.GetTargetLocation();
|
|
|
|
|
|
- List<StockMovement> updates = new List<StockMovement>();
|
|
|
+ var updates = new List<StockMovement>();
|
|
|
foreach (var requiitem in requiitems)
|
|
|
{
|
|
|
if (!quantities.TryGetValue(requiitem.ID, out var qty)) continue;
|
|
@@ -411,14 +414,15 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- private IEnumerable<StockMovement> CreateIssue(StockHolding holding, double qty, Guid jobID, Guid requiID)
|
|
|
+ private IEnumerable<StockMovement> CreateIssue(StockHolding holding, StockIssue issueObj, Guid requiID)
|
|
|
{
|
|
|
var issue = CreateMovementFromHolding(holding);
|
|
|
- issue.Job.ID = jobID;
|
|
|
+ issue.Job.ID = issueObj.Job.ID;
|
|
|
issue.Type = StockMovementType.Issue;
|
|
|
issue.JobRequisitionItem.ID = requiID;
|
|
|
- issue.Issued = qty;
|
|
|
+ issue.Issued = issueObj.Qty;
|
|
|
issue.Notes = $"Issued by {App.EmployeeName}";
|
|
|
+ issue.Date = issueObj.Date;
|
|
|
yield return issue;
|
|
|
|
|
|
if (holding.Job.ID != issue.Job.ID)
|
|
@@ -426,20 +430,24 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
var xferout = CreateMovementFromHolding(holding);
|
|
|
xferout.Type = StockMovementType.TransferOut;
|
|
|
xferout.JobRequisitionItem.ID = requiID;
|
|
|
- xferout.Issued = qty;
|
|
|
+ xferout.Issued = issueObj.Qty;
|
|
|
xferout.Transaction = issue.Transaction;
|
|
|
xferout.IsTransfer = true;
|
|
|
+ xferout.System = true;
|
|
|
xferout.Notes = $"Issued by {App.EmployeeName}";
|
|
|
+ xferout.Date = issueObj.Date;
|
|
|
yield return xferout;
|
|
|
|
|
|
var xferin = CreateMovementFromHolding(holding);
|
|
|
xferin.Job.ID = issue.Job.ID;
|
|
|
xferin.Type = StockMovementType.TransferIn;
|
|
|
xferin.JobRequisitionItem.ID = requiID;
|
|
|
- xferin.Received = qty;
|
|
|
+ xferin.Received = issueObj.Qty;
|
|
|
xferin.Transaction = issue.Transaction;
|
|
|
xferin.IsTransfer = true;
|
|
|
+ xferin.System = true;
|
|
|
xferin.Notes = $"Issued by {App.EmployeeName}";
|
|
|
+ xferin.Date = issueObj.Date;
|
|
|
yield return xferin;
|
|
|
}
|
|
|
}
|
|
@@ -463,7 +471,11 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
{
|
|
|
if (!quantities.TryGetValue(requi.ID, out var qty)) continue;
|
|
|
|
|
|
- updates.AddRange(CreateIssue(holding, qty, requi.ID != Guid.Empty ? requi.Job.ID : holding.Job.ID, requi.ID));
|
|
|
+ var issue = new StockIssue();
|
|
|
+ issue.Job.ID = requi.ID != Guid.Empty ? requi.Job.ID : holding.Job.ID;
|
|
|
+ issue.Qty = qty;
|
|
|
+
|
|
|
+ updates.AddRange(CreateIssue(holding, issue, requi.ID));
|
|
|
}
|
|
|
DoChanged();
|
|
|
Refresh(false,true);
|
|
@@ -472,19 +484,19 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- var sjs = new StockJobSelection();
|
|
|
+ var sjs = new StockIssue();
|
|
|
sjs.Job.ID = holding.Job.ID;
|
|
|
sjs.Qty = requiitems[0].Qty;
|
|
|
|
|
|
- var sjg = new DynamicItemsListGrid<StockJobSelection>();
|
|
|
+ var sjg = new DynamicItemsListGrid<StockIssue>();
|
|
|
sjg.OnValidate += (sender, items, errors) =>
|
|
|
{
|
|
|
if (items[0].Qty > requiitems[0].Qty)
|
|
|
errors.Add($"Qty must not exceed {requiitems[0].Qty}");
|
|
|
};
|
|
|
- if (sjg.EditItems(new StockJobSelection[] { sjs }))
|
|
|
+ if (sjg.EditItems(new StockIssue[] { sjs }))
|
|
|
{
|
|
|
- var mvts = CreateIssue(holding, sjs.Qty, sjs.Job.ID, Guid.Empty);
|
|
|
+ var mvts = CreateIssue(holding, sjs, Guid.Empty);
|
|
|
SaveBatch(StockMovementBatchType.Issue, mvts.AsArray());
|
|
|
}
|
|
|
}
|