public string SearchForCompanyName(ActivityBuyModel[] activityBuyModels, ESPPModel esppRow) { // Fidelity has a bug in generation and amount can be rounded up in some tables on third number after digit. var foundTransactions = activityBuyModels.Where(i => i.Price == esppRow.PurchasePrice && Math.Ceiling(i.Amount) == Math.Ceiling(esppRow.Amount)); if (foundTransactions.Count() > 1) { // Probability that somebody will get ESPP for 2 companies of exact discounted price and exact amount on one report is close to 0, lets consider it's impossible. // I don't know better way how to find it based on artifacts from page about ESPP. throw new InvalidOperationException("Couldn't properly detect name of company for ESPP."); } return(foundTransactions.First().Name); }
private ESPPTransaction CreateESPPTransaction(ActivityBuyModel[] activityBuyModels, ESPPModel esppRow) { var name = SearchForCompanyName(activityBuyModels, esppRow); return(new ESPPTransaction(Broker.Fidelity, esppRow.Date, name, Currency.USD, esppRow.PurchasePrice, esppRow.MarketPrice, esppRow.Amount)); }
public string SearchForCompanyName(ActivityBuyModel[] activityBuyModels, ESPPModel esppRow) {