public IEnumerable <BankTransactionModel> GetBankTransactionsForAccountId(long id) { var transactions = BankTransactionRepository.GetAllForAccountId(id).OrderByDescending(entity => entity.AvailabilityDate); return(Mapper.Map <IEnumerable <BankTransactionModel> >(transactions)); }
protected override IEnumerable <FileParserInput> DownloadTransactions() { var transactions = new List <FileParserInput>(); try { Browser.WaitForJavaScript(5000); //Konto var accountNumber = Browser.FindElements(By.ClassName("C0"))[3].Text; var iban = GetIban(); //go to account transactions Browser.Navigate().GoToUrl("https://konto.flatex.at/banking-flatex.at/accountPostingsFormAction.do"); Browser.WaitForJavaScript(); var balanceString = Browser.FindElements(new ByChained(By.ClassName("Details"), By.ClassName("Value")))[0].Text .ExtractDecimalNumberString(); var valueParserDe = ComponentContext.ResolveKeyed <IValueParser>(Constants.UniqueContainerKeys.ValueParserGermanDecimal); var balance = (decimal)valueParserDe.Parse(balanceString); //Date range -1 year var fromDate = Browser.FindElement(By.Id("accountPostingsForm_dateRangeComponent_startDate")); fromDate.SetAttribute("value", DateTime.Today.AddMonths(-2).ToString("dd.MM.yyyy")); Browser.FindElement(By.Id("accountPostingsForm_applyFilterButton")).Click(); //excel download TakeScreenshot(iban); var resultingFile = DownloadFromWebElement(Browser.FindElement(By.Id("accountPostingsForm_excelExportButton")), iban); //check for account or create new var bankAccount = BankAccountRepository.GetByIban(iban); if (bankAccount == null) { bankAccount = new BankAccountEntity { AccountNumber = accountNumber, Iban = iban, BankName = Constants.DownloadHandler.BankNameFlatex, AccountName = Constants.DownloadHandler.AccountNameGiro }; BankAccountRepository.Insert(bankAccount); } transactions.Add(new FileParserInput { OwningEntity = bankAccount, FileParser = ComponentContext.ResolveKeyed <IFileParser>(Constants.UniqueContainerKeys.FileParserFlatexGiro), FilePath = resultingFile, TargetEntity = typeof(FlatexTransactionEntity), Balance = balance, BalanceSelectorFunc = () => BankTransactionRepository.GetAllForAccountId(bankAccount.Id).Sum(entity => entity.Amount) }); } catch (Exception ex) { Logger.LogWarning(ex, "Exception occured while downloading Flatex Giro transactions"); } try { //Depot NavigateHome(); Browser.WaitForJavaScript(5000); var portfolioNumber = Browser.FindElements(By.ClassName("C0"))[5].Text; Browser.Navigate().GoToUrl("https://konto.flatex.at/banking-flatex.at/depositStatementFormAction.do"); TakeScreenshot(portfolioNumber); var resultingFile = DownloadFromWebElement( Browser.FindElement(By.Id("depositStatementForm_excelExportButton")), portfolioNumber); var portfolio = PortfolioRepository.GetByPortfolioNumberAndBankName(portfolioNumber, Constants.DownloadHandler.BankNameFlatex); if (portfolio == null) { portfolio = new PortfolioEntity { PortfolioNumber = portfolioNumber, BankName = Constants.DownloadHandler.BankNameFlatex, AccountName = Constants.DownloadHandler.AccountNameDepot }; PortfolioRepository.Insert(portfolio); } transactions.Add(new FileParserInput { OwningEntity = portfolio, FileParser = ComponentContext.ResolveKeyed <IFileParser>(Constants.UniqueContainerKeys.FileParserFlatexDepot), FilePath = resultingFile, TargetEntity = typeof(FlatexPositionEntity) }); } catch (Exception ex) { Logger.LogWarning(ex, "Exception occured while downloading Flatex Portfolio transactions"); } return(transactions); }