public void Apply(DisposalOccurredEvent @event) { var holding = _Holdings[@event.Stock]; if (holding == null) { throw new NoSharesOwnedException("No shares owned"); } var disposal = new Disposal { Id = @event.TransactionId, Date = @event.Date, Stock = holding.Stock, Comment = @event.Comment, Units = @event.Units, AveragePrice = @event.AveragePrice, TransactionCosts = @event.TransactionCosts, CreateCashTransaction = @event.CreateCashTransaction }; var handler = _TransactionHandlers.GetService <Disposal>(); handler.Apply(disposal, holding, _CashAccount); _Transactions.Add(disposal); }
public void DisposeOfShares(Guid stockId, Date disposalDate, int units, decimal averagePrice, decimal transactionCosts, CgtCalculationMethod cgtMethod, bool createCashTransaction, string comment, Guid transactionId) { var @event = new DisposalOccurredEvent(Id, Version, transactionId, disposalDate, stockId, comment) { Units = units, AveragePrice = averagePrice, TransactionCosts = transactionCosts, CgtMethod = cgtMethod, CreateCashTransaction = createCashTransaction }; Apply(@event); PublishEvent(@event); }