Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 3
0
        public BankAccountModel CreateEditBankAccount(BankAccountModel model)
        {
            BankAccountEntity entity;

            //is update
            if (model.Id != default(long))
            {
                entity = BankAccountRepository.GetById(model.Id);
                entity = Mapper.Map(model, entity);
            }
            else
            {
                entity = Mapper.Map <BankAccountEntity>(model);
                entity = BankAccountRepository.Insert(entity);
            }
            BankAccountRepository.Save();
            return(Mapper.Map <BankAccountModel>(entity));
        }
Ejemplo n.º 4
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)
            });
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        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);
        }