|
@@ -80,7 +80,8 @@ internal class PurchaseOrderItemStore : BaseStore<PurchaseOrderItem>
|
|
|
x => x.Dimensions.Unit.Formula,
|
|
|
x => x.Dimensions.Unit.Format,
|
|
|
x => x.Dimensions.Unit.Code,
|
|
|
- x => x.Dimensions.Unit.Description
|
|
|
+ x => x.Dimensions.Unit.Description,
|
|
|
+ x => x.Batch.ID
|
|
|
)
|
|
|
).Rows.Select(x => x.ToObject<StockMovement>()).ToList();
|
|
|
if (!result.Any())
|
|
@@ -283,9 +284,19 @@ internal class PurchaseOrderItemStore : BaseStore<PurchaseOrderItem>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ StockMovementBatch? batch = null;
|
|
|
foreach (var movement in movements)
|
|
|
{
|
|
|
- movement.Batch.Type = StockMovementBatchType.Receipt;
|
|
|
+ if(movement.Batch.ID == Guid.Empty)
|
|
|
+ {
|
|
|
+ batch ??= new StockMovementBatch
|
|
|
+ {
|
|
|
+ Type = StockMovementBatchType.Receipt,
|
|
|
+ TimeStamp = DateTime.Now,
|
|
|
+ Notes = $"Received on PO"
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
movement.Date = entity.ReceivedDate;
|
|
|
movement.Product.ID = entity.Product.ID;
|
|
|
movement.Received = entity.Qty;
|
|
@@ -309,6 +320,18 @@ internal class PurchaseOrderItemStore : BaseStore<PurchaseOrderItem>
|
|
|
movement.JobRequisitionItem.ID = jobRequisitionItemID;
|
|
|
}
|
|
|
|
|
|
+ if(batch is not null)
|
|
|
+ {
|
|
|
+ FindSubStore<StockMovementBatch>().Save(batch, "Received on PO");
|
|
|
+ foreach(var movement in movements)
|
|
|
+ {
|
|
|
+ if(movement.Batch.ID == Guid.Empty)
|
|
|
+ {
|
|
|
+ movement.Batch.ID = batch.ID;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
var updates = movements.Where(x => x.IsChanged()).ToList();
|
|
|
if (updates.Any())
|
|
|
FindSubStore<StockMovement>().Save(updates, "Updated by Purchase Order Modification");
|