|
@@ -71,10 +71,14 @@ public class StockMovementStore : BaseStore<StockMovement>
|
|
|
|
|
|
protected override void AfterSave(IEnumerable<StockMovement> entities)
|
|
|
{
|
|
|
+ // Find all movements that weren't loaded in BeforeSave - i.e., they are new stock movements.
|
|
|
var newIDs = entities.Select(x => x.ID).Where(x => !currentIDs.Contains(x)).ToArray();
|
|
|
+ // Grab the data for these movements.
|
|
|
var newMvts = StockHoldingStore.LoadMovementData(this, newIDs);
|
|
|
+ // Load all the stock holdings for these movements, but only if we haven't loaded them already.
|
|
|
StockHoldingStore.LoadStockHoldings(this, newMvts, holdingData);
|
|
|
|
|
|
+ // Add the new movement data to our data. Note that the above line does the same for holdings.
|
|
|
mvtData = mvtData.Concatenate(newMvts);
|
|
|
|
|
|
// Update the Relevant StockHolding with the details of this movement
|