|
@@ -349,23 +349,36 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
foreach(var requi in requiitems)
|
|
|
{
|
|
|
var qty = getQuantity(requi);
|
|
|
- if (!qty.HasValue || qty.Value <= 0) continue;
|
|
|
+ if (!qty.HasValue || qty.Value == 0) continue;
|
|
|
|
|
|
var mout = holding.CreateMovement();
|
|
|
- mout.Issued = qty.Value;
|
|
|
mout.Cost = holding.AverageValue;
|
|
|
mout.Date = DateTime.Now;
|
|
|
mout.Employee.ID = App.EmployeeID;
|
|
|
- mout.Type = StockMovementType.TransferOut;
|
|
|
|
|
|
var min = mout.CreateMovement();
|
|
|
- min.Received = qty.Value;
|
|
|
min.Cost = holding.AverageValue;
|
|
|
min.Employee.ID = App.EmployeeID;
|
|
|
- min.Type = StockMovementType.TransferIn;
|
|
|
min.Date = mout.Date;
|
|
|
min.Transaction = mout.Transaction;
|
|
|
|
|
|
+ if(qty.Value > 0)
|
|
|
+ {
|
|
|
+ mout.Issued = qty.Value;
|
|
|
+ mout.Type = StockMovementType.TransferOut;
|
|
|
+
|
|
|
+ min.Received = qty.Value;
|
|
|
+ min.Type = StockMovementType.TransferIn;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ min.Issued = -qty.Value;
|
|
|
+ min.Type = StockMovementType.TransferOut;
|
|
|
+
|
|
|
+ mout.Received = -qty.Value;
|
|
|
+ mout.Type = StockMovementType.TransferIn;
|
|
|
+ }
|
|
|
+
|
|
|
modify(requi, mout, min);
|
|
|
|
|
|
updates.Add(mout);
|
|
@@ -605,15 +618,15 @@ public class StockHoldingGrid : DynamicDataGrid<StockHolding>
|
|
|
Columns.None<StockMovement>().Add(x => x.Units).Add(x => x.JobRequisitionItem.ID))
|
|
|
.ToObjects<StockMovement>().GroupBy(x => x.JobRequisitionItem.ID).ToDictionary(x => x.Key, x => x.Sum(x => x.Units));
|
|
|
|
|
|
- DoTransfer(holding, items, x => x.ID == Guid.Empty ? x.Qty : quantities.GetValueOrDefault(x.ID), (requi, mout, min) =>
|
|
|
+ DoTransfer(holding, items, x => x.ID == Guid.Empty ? x.Qty : quantities.GetValueOrDefault(x.ID), (requi, mThis, mThat) =>
|
|
|
{
|
|
|
- mout.JobRequisitionItem.ID = requi.ID;
|
|
|
- mout.Notes = $"Moved to {target.Code} by {App.EmployeeName}";
|
|
|
+ mThis.JobRequisitionItem.ID = requi.ID;
|
|
|
+ mThis.Notes = $"Moved to {target.Code} by {App.EmployeeName}";
|
|
|
|
|
|
- min.JobRequisitionItem.ID = requi.ID;
|
|
|
- min.Notes = $"Moved to {target.Code} by {App.EmployeeName}";
|
|
|
- min.Location.Clear();
|
|
|
- min.Location.ID = target.ID;
|
|
|
+ mThat.JobRequisitionItem.ID = requi.ID;
|
|
|
+ mThat.Notes = $"Moved to {target.Code} by {App.EmployeeName}";
|
|
|
+ mThat.Location.Clear();
|
|
|
+ mThat.Location.ID = target.ID;
|
|
|
}, updates);
|
|
|
}
|
|
|
|