public BankTransactionModel DeleteBankTransaction(long id)
        {
            var transaction = BankTransactionRepository.GetById(id);

            BankTransactionRepository.Delete(transaction);
            BankTransactionRepository.Save();
            return(Mapper.Map <BankTransactionModel>(transaction));
        }
        protected override IEnumerable <FileParserInput> DownloadTransactions()
        {
            var valueParser =
                ComponentContext.ResolveKeyed <IValueParser>(Constants.UniqueContainerKeys.ValueParserGermanDecimal);

            var account =
                BankAccountRepository.GetByAccountNameAndBankName(Constants.DownloadHandler.AccountNamePaymentService,
                                                                  Constants.DownloadHandler.BankNamePayPal);

            if (account == null)
            {
                account = new BankAccountEntity
                {
                    BankName    = Constants.DownloadHandler.BankNamePayPal,
                    AccountName = Constants.DownloadHandler.AccountNamePaymentService
                };
                BankAccountRepository.Insert(account);
            }

            var balanceEntries =
                Browser.FindElements(By.ClassName("currenciesEntry"))
                .Select(element => (decimal)valueParser.Parse(element.Text.CleanNumberStringFromOther()));
            var balance = balanceEntries.FirstOrDefault();

            Browser.WaitForJavaScript(5000);

            TakeScreenshot("screenshot");

            Browser.Navigate().GoToUrl("https://www.paypal.com/cgi-bin/webscr?cmd=_history-download");

            //set date
            Browser.FindElement(By.Name("from_a")).Clear();
            Browser.FindElement(By.Name("from_b")).Clear();
            Browser.FindElement(By.Name("from_c")).Clear();
            var startDate = DateTime.Now.AddYears(-2).AddDays(1);

            Browser.FindElement(By.Name("from_a")).SendKeys(startDate.Month.ToString()); //Month
            Browser.FindElement(By.Name("from_b")).SendKeys(startDate.Day.ToString());   //Day
            Browser.FindElement(By.Name("from_c")).SendKeys(startDate.Year.ToString());  //Year

            var downloadType = new SelectElement(Browser.FindElement(By.Name("custom_file_type")));

            downloadType.SelectByValue("comma_balaffecting");

            var resultingFile = DownloadFromWebElement(Browser.FindElement(By.Name("submit.x")), "transactions");

            yield return(new FileParserInput
            {
                OwningEntity = account,
                FileParser =
                    ComponentContext.ResolveKeyed <IFileParser>(Constants.UniqueContainerKeys.FileParserPayPal),
                FilePath = resultingFile,
                TargetEntity = typeof(PayPalTransactionEntity),
                Balance = balance,
                BalanceSelectorFunc =
                    () => BankTransactionRepository.TransactionSumForAccountId(account.Id)
            });
        }
        protected override IEnumerable <FileParserInput> DownloadTransactions()
        {
            var downloadResults = new List <FileParserInput>();

            Browser.WaitForJavaScript(12000);
            Browser.FindElement(By.XPath("//*[@data-test='main-nav-kontozentrale']")).Click();
            Browser.WaitForJavaScript();

            //fist ist cumulative account
            for (var i = 1; i < GetAccountLinks().Count; i++)
            {
                GetAccountLinks()[i].Click();
                Browser.WaitForJavaScript(2000);
                var valueParser =
                    ComponentContext.ResolveKeyed <IValueParser>(Constants.UniqueContainerKeys.ValueParserGermanDecimal);
                var balance     = GetAccountBalance().Text.CleanNumberStringFromOther();
                var infoBox     = Browser.FindElement(By.ClassName("info-box"));
                var iban        = infoBox.FindElement(By.TagName("h2")).Text.CleanString();
                var bankAccount = BankAccountRepository.GetByIban(iban);
                if (bankAccount == null)
                {
                    bankAccount = new BankAccountEntity
                    {
                        AccountNumber = iban,
                        Iban          = iban,
                        BankName      = Constants.DownloadHandler.BankNameRaiffeisen,
                        AccountName   = i == 0 ? Constants.DownloadHandler.AccountNameGiro : Constants.DownloadHandler.AccountNameSaving
                    };
                    BankAccountRepository.Insert(bankAccount);
                }

                TakeScreenshot(iban);

                var resultingFile = DownloadFromWebElement(Browser.FindElement(By.ClassName("icon-csv")), iban);
                downloadResults.Add(new FileParserInput
                {
                    OwningEntity = bankAccount,
                    FileParser   =
                        ComponentContext.ResolveKeyed <IFileParser>(Constants.UniqueContainerKeys.FileParserRaiffeisenGiro),
                    FilePath            = resultingFile,
                    TargetEntity        = typeof(RaiffeisenTransactionEntity),
                    Balance             = (decimal)valueParser.Parse(balance),
                    BalanceSelectorFunc =
                        () => BankTransactionRepository.TransactionSumForAccountId(bankAccount.Id)
                });
            }
            downloadResults.AddRange(DownloadDepots());
            return(downloadResults);
        }
        public IEnumerable <CumulativeTransactionModel> CumulativeAccountTransactions()
        {
            var transactions =
                BankTransactionRepository.Query().Include(entity => entity.Account).OrderBy(entity => entity.AvailabilityDate).ToList();
            var transactionModels = Mapper.Map <List <CumulativeTransactionModel> >(transactions);
            var transSum          = 0m;

            foreach (var transaction in transactionModels)
            {
                transSum += transaction.Amount;
                transaction.Cumulative = transSum;
            }

            transactionModels.Reverse();
            return(transactionModels);
        }
Example #5
0
        protected override IEnumerable <FileParserInput> DownloadTransactions()
        {
            Browser.WaitForJavaScript(5000);

            var ibanRaw     = Browser.FindElement(By.ClassName("accountText")).Text; //First is Tagesgeld
            var iban        = ibanRaw.Split(':')[1].CleanString();
            var balanceStr  = Browser.FindElement(new ByChained(By.ClassName("currency"), By.ClassName("amountblock-wrapper"))).Text;
            var valueParser =
                ComponentContext.ResolveKeyed <IValueParser>(Constants.UniqueContainerKeys.ValueParserGermanDecimal);
            var balance = (decimal)valueParser.Parse(balanceStr);

            Browser.FindElement(By.ClassName("accountInfo-wrapper")).Click();
            Browser.WaitForJavaScript();

            var bankAccount = BankAccountRepository.GetByIban(iban);

            if (bankAccount == null)
            {
                bankAccount = new BankAccountEntity
                {
                    AccountNumber = iban,
                    Iban          = iban,
                    BankName      = Constants.DownloadHandler.BankNameRci,
                    AccountName   = Constants.DownloadHandler.AccountNameSaving
                };
                BankAccountRepository.Insert(bankAccount);
            }

            TakeScreenshot(iban);

            var exportButton = Browser.FindElement(By.ClassName("transactions-csv-export"));
            var file         = DownloadFromWebElement(exportButton, iban);

            yield return(new FileParserInput
            {
                Balance = balance,
                BalanceSelectorFunc = () => BankTransactionRepository.TransactionSumForAccountId(bankAccount.Id),
                FileParser = ComponentContext.ResolveKeyed <IFileParser>(Constants.UniqueContainerKeys.FileParserRci),
                FilePath = file,
                OwningEntity = bankAccount,
                TargetEntity = typeof(RciTransactionEntity)
            });
        }
        public IEnumerable <BankTransactionModel> GetBankTransactionsForAccountId(long id)
        {
            var transactions = BankTransactionRepository.GetAllForAccountId(id).OrderByDescending(entity => entity.AvailabilityDate);

            return(Mapper.Map <IEnumerable <BankTransactionModel> >(transactions));
        }
Example #7
0
        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);
        }
        protected override IEnumerable <FileParserInput> DownloadTransactions()
        {
            var downloadResults = new List <FileParserInput>();
            var valueParser     =
                ComponentContext.ResolveKeyed <IValueParser>(Constants.UniqueContainerKeys.ValueParserGermanDecimal);

            //bankaccount
            var iban    = GetAccounts()[0].FindElement(By.ClassName("iban")).Text.CleanString();
            var balance = (decimal)valueParser.Parse(
                GetAccounts()[0].FindElement(new ByChained(By.ClassName("amount"), By.TagName("span"))).Text);

            GetAccounts()[0].FindElement(By.ClassName("evt-paymentTransaction")).Click();

            var bankAccount = BankAccountRepository.GetByIban(iban);

            if (bankAccount == null)
            {
                bankAccount = new BankAccountEntity
                {
                    AccountNumber = iban,
                    Iban          = iban,
                    BankName      = Constants.DownloadHandler.BankNameDkb,
                    AccountName   = Constants.DownloadHandler.AccountNameGiro
                };
                BankAccountRepository.Insert(bankAccount);
            }
            var resultingFile = DownloadAndScreenshot(iban, "[id*=transactionDate]", "[id*=toTransactionDate]");

            downloadResults.Add(new FileParserInput
            {
                OwningEntity         = bankAccount,
                FileParser           = ComponentContext.ResolveKeyed <IFileParser>(Constants.UniqueContainerKeys.FileParserDkbGiro),
                FilePath             = resultingFile,
                TargetEntity         = typeof(DkbTransactionEntity),
                UniqueIdGroupingFunc = entity => ((DkbTransactionEntity)entity).AvailabilityDate.Date,
                OrderingFuncs        = new List <Func <object, object> > {
                    o => ((DkbTransactionEntity)o).AvailabilityDate.Date, o => ((DkbTransactionEntity)o).Text, o => ((DkbTransactionEntity)o).Amount
                },
                Balance             = balance,
                BalanceSelectorFunc =
                    () => BankTransactionRepository.TransactionSumForAccountId(bankAccount.Id)
            });

            NavigateHome();

            //credit card
            var creditCardNumberMasked = GetAccounts()[1].FindElement(By.XPath("td[1]/div[2]")).Text.CleanString();
            var creditBalance          = (decimal)valueParser.Parse(
                GetAccounts()[1].FindElement(new ByChained(By.ClassName("amount"), By.TagName("span"))).Text);

            GetAccounts()[1].FindElement(By.ClassName("evt-paymentTransaction")).Click();

            var creditCardAccount = CreditCardAccountRepository.GetByAccountNumberAndBankName(creditCardNumberMasked,
                                                                                              Constants.DownloadHandler.BankNameDkb);

            if (creditCardAccount == null)
            {
                creditCardAccount = new CreditCardEntity
                {
                    AccountNumber    = creditCardNumberMasked,
                    CreditCardNumber = null,
                    BankName         = Constants.DownloadHandler.BankNameDkb,
                    AccountName      = Constants.DownloadHandler.AccountNameVisa
                };
                CreditCardAccountRepository.Insert(creditCardAccount);
            }
            resultingFile = DownloadAndScreenshot(creditCardNumberMasked, "[id*=postingDate]", "[id*=toPostingDate]");
            downloadResults.Add(new FileParserInput
            {
                OwningEntity = creditCardAccount,
                FileParser   =
                    ComponentContext.ResolveKeyed <IFileParser>(Constants.UniqueContainerKeys.FileParserDkbCredit),
                FilePath             = resultingFile,
                TargetEntity         = typeof(DkbCreditTransactionEntity),
                UniqueIdGroupingFunc = entity => ((DkbCreditTransactionEntity)entity).AvailabilityDate.Date,
                OrderingFuncs        = new List <Func <object, object> > {
                    o => ((DkbCreditTransactionEntity)o).AvailabilityDate.Date, o => ((DkbCreditTransactionEntity)o).Text, o => ((DkbCreditTransactionEntity)o).Amount
                },
                Balance             = creditBalance,
                BalanceSelectorFunc = () => BankTransactionRepository.TransactionSumForAccountId(creditCardAccount.Id)
            });
            return(downloadResults);
        }
        protected override IEnumerable <FileParserInput> DownloadTransactions()
        {
            var valueParserDe =
                ComponentContext.ResolveKeyed <IValueParser>(Constants.UniqueContainerKeys.ValueParserGermanDecimal);
            var valueParserEn =
                ComponentContext.ResolveKeyed <IValueParser>(Constants.UniqueContainerKeys.ValueParserEnglishDecimal);

            Browser.WaitForJavaScript(7500);

            //settings
            Browser.FindElement(By.XPath("//*[@class='UIMenu']/ul/li[4]/a")).Click();
            Browser.WaitForJavaScript(5000);
            var     iban          = Browser.FindElements(By.ClassName("iban-split")).Select(element => element.Text).Aggregate("", (s, s1) => s + s1).CleanString();
            var     balanceString = Browser.FindElement(By.ClassName("UIHeader__account-balance")).Text.ExtractDecimalNumberString();
            decimal balance;

            if (balanceString.IndexOf(",", StringComparison.Ordinal) < balanceString.IndexOf(".", StringComparison.Ordinal))
            {
                balance = (decimal)valueParserEn.Parse(balanceString);
            }
            else
            {
                balance = (decimal)valueParserDe.Parse(balanceString);
            }

            var bankAccount = CreditCardAccountRepository.GetByAccountNumberAndBankName(iban, Constants.DownloadHandler.BankNameNumber26);

            if (bankAccount == null)
            {
                bankAccount =
                    CreditCardAccountRepository.Query()
                    .First(
                        entity =>
                        entity.BankName == Constants.DownloadHandler.BankNameNumber26 &&
                        entity.AccountName == Constants.DownloadHandler.AccountNameMasterCard);
                if (bankAccount == null)
                {
                    bankAccount = new CreditCardEntity
                    {
                        AccountNumber = iban,
                        BankName      = Constants.DownloadHandler.BankNameNumber26,
                        AccountName   = Constants.DownloadHandler.AccountNameMasterCard
                    };
                    CreditCardAccountRepository.Insert(bankAccount);
                }
            }

            NavigateHome();

            TakeScreenshot(iban);

            //Click download button
            Browser.FindElement(By.ClassName("csv")).Click();
            Browser.WaitForJavaScript();
            //Click previous a few times
            Browser.FindElement(By.ClassName("ui-datepicker-today")).Click();
            Browser.WaitForJavaScript(100);
            for (int i = 0; i < 6; i++)
            {
                Browser.FindElement(By.ClassName("ui-datepicker-prev")).Click();
                Browser.WaitForJavaScript(100);
            }
            //Click first day of month
            Browser.FindElement(new ByChained(By.ClassName("ui-datepicker-calendar"), By.XPath("//*[@data-handler='selectDay']"))).Click();

            var resultingFile = DownloadFromWebElement(Browser.FindElement(By.ClassName("ok")), iban);

            yield return(new FileParserInput
            {
                OwningEntity = bankAccount,
                FileParser = ComponentContext.ResolveKeyed <IFileParser>(Constants.UniqueContainerKeys.FileParserNumber26),
                FilePath = resultingFile,
                TargetEntity = typeof(Number26TransactionEntity),
                Balance = balance,
                BalanceSelectorFunc =
                    () => BankTransactionRepository.TransactionSumForAccountId(bankAccount.Id)
            });
        }
Example #10
0
 public BankTransactionController()
 {
     _bankTransactionManager    = new BankTransactionManager(new BankTransactionFactory(), new BankTransactionsFileToTextConverter(), new BankTransactionRepository());
     _bankTransactionRepository = new BankTransactionRepository();
 }