public IList <Transaction> Parse(string statementFilePath) { if (!CanParse(statementFilePath)) { return(null); } var statementRows = LoadStatementModel(statementFilePath); if (statementRows == null) { return(null); } var output = new List <Transaction>(); foreach (var row in statementRows) { if (row.Description.Contains("Dividenda")) { var tax = SearchForTax(statementRows, row.ISIN, row.Date.Value); var transaction = new DividendTransaction(Broker.Degiro, row.Date.Value, row.Name, row.Income.Value, tax, row.Currency.Value); output.Add(transaction); } } return(output); }
public IList <Transaction> Parse(string statementFilePath) { if (!CanParse(statementFilePath)) { return(null); } var statement = LoadStatementModel(statementFilePath); if (statement == null || statement.Statement[0].FieldValue != "Activity Statement") { return(null); } var output = new List <Transaction>(); foreach (var dividend in statement.Dividends) { var currency = Enum.Parse <Currency>(dividend.Currency); var tax = SearchForTax(dividend, statement.WithholdingTaxes); var transaction = new DividendTransaction(Broker.Lynx, dividend.Date.Value, dividend.Description, dividend.Amount, tax, currency); output.Add(transaction); } return(output); }
public DividendTransactionView(DividendTransaction transaction, decimal?exchangeRatePerDay, decimal?exchangeRatePerYear, Currency exchangedToCurrency) : base(transaction, exchangeRatePerDay, exchangeRatePerYear, exchangedToCurrency) { ExchangedPerDayIncome = transaction.Income * exchangeRatePerDay; ExchangedPerYearIncome = transaction.Income * exchangeRatePerYear; ExchangedPerDayTax = transaction.Tax * exchangeRatePerDay; ExchangedPerYearTax = transaction.Tax * exchangeRatePerYear; }
/// <summary> /// Processes the given event <paramref name="eventData"/> /// </summary> /// <param name="eventData">Event data</param> public void Handle(TransactionDividendOrderAddedEvent eventData) { if (_writerRepository.GetById(eventData.AggregateId) != null) { return; } var stock = _stockRepository.GetById(eventData.StockId); if (stock == null) { throw new EventHandlerException($"No Stock found with id: {eventData.StockId}", typeof(TransactionSellingOrderAddedEventHandler)); } var item = new DividendTransaction(eventData.AggregateId) { OriginalVersion = eventData.Version, Description = eventData.Description, Image = eventData.Image, OrderCosts = eventData.OrderCosts, OrderDate = eventData.OrderDate, PricePerShare = eventData.PricePerShare, Stock = stock, Tag = eventData.Tag, Taxes = eventData.Taxes, Shares = eventData.Shares, Action = "Dividende", PositionSize = eventData.PositionSize }; _writerRepository.Add(item); //Add to transaction book _transactionBook.AddEntry(new DividendTransactionBookEntry( eventData.StockId, eventData.AggregateId, eventData.OrderDate, eventData.Shares, eventData.PricePerShare, eventData.OrderCosts, eventData.Taxes)); }