public void Apply(OpeningBalanceOccurredEvent @event) { var holding = _Holdings[@event.Stock]; if (holding == null) { var stock = _StockResolver.GetStock(@event.Stock); holding = _Holdings.Add(stock, @event.Date); holding.CgtEventOccurred += Holding_CgtEventOccurred; } var openingBalance = new OpeningBalance { Id = @event.TransactionId, Date = @event.Date, Stock = holding.Stock, Comment = @event.Comment, AquisitionDate = @event.AquisitionDate, Units = @event.Units, CostBase = @event.CostBase }; var handler = _TransactionHandlers.GetService <OpeningBalance>(); handler.Apply(openingBalance, holding, _CashAccount); _Transactions.Add(openingBalance); }
public void AddOpeningBalance(Guid stockId, Date transactionDate, Date aquisitionDate, int units, decimal costBase, string comment, Guid transactionId) { var @event = new OpeningBalanceOccurredEvent(Id, Version, transactionId, transactionDate, stockId, comment) { AquisitionDate = aquisitionDate, Units = units, CostBase = costBase }; Apply(@event); PublishEvent(@event); }