/// <summary>
        ///     Load the given file into a <see cref="StatementModel" />.
        /// </summary>
        /// <param name="fileName">The file to load.</param>
        /// <param name="accountType">
        ///     The account type to classify these transactions. This is useful when merging one statement to another. For example,
        ///     merging a cheque account
        ///     export with visa account export, each can be classified using an account type.
        /// </param>
        public StatementModel Load(string fileName, AccountType accountType)
        {
            this.importUtilities.AbortIfFileDoesntExist(fileName, this.userMessageBox);

            var transactions = new List<Transaction>();
            foreach (string line in ReadLines(fileName))
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }

                string[] split = line.Split(',');
                decimal amount;
                NamedTransaction transactionType = FetchTransactionType(split, 1, 2, out amount);
                var transaction = new Transaction
                {
                    AccountType = accountType,
                    Reference1 = this.importUtilities.SafeArrayFetchString(split, 0),
                    TransactionType = transactionType,
                    Amount = amount,
                    Description = this.importUtilities.SafeArrayFetchString(split, 3),
                    Date = this.importUtilities.SafeArrayFetchDate(split, 4),
                };
                transactions.Add(transaction);
            }

            return new StatementModel(this.logger)
            {
                FileName = fileName,
                LastImport = DateTime.Now,
            }.LoadTransactions(transactions);
        }
        /// <summary>
        ///     Import the given file.  It is recommended to call <see cref="IBankStatementImporterRepository.CanImport" /> first.
        ///     If the file cannot
        ///     be imported by any of this repositories importers a <see cref="NotSupportedException" /> will be thrown.
        /// </summary>
        public StatementModel Import(string fullFileName, AccountType accountType)
        {
            foreach (IBankStatementImporter importer in this.importers)
            {
                if (importer.TasteTest(fullFileName))
                {
                    return importer.Load(fullFileName, accountType);
                }
            }

            throw new NotSupportedException("The requested file name cannot be loaded. It is not of any known format.");
        }
Example #3
0
 public BankBalance(AccountType account, decimal balance)
 {
     Account = account;
     Balance = balance;
 }
 public void PromptUserForAccountType()
 {
     this.filterMode = FilterMode.AccountType;
     List<AccountType> accountTypeList = this.accountTypeRepository.ListCurrentlyUsedAccountTypes().ToList();
     accountTypeList.Insert(0, null);
     AccountTypes = accountTypeList;
     SelectedAccountType = Criteria.AccountType;
     this.dialogCorrelationId = Guid.NewGuid();
     var dialogRequest = new ShellDialogRequestMessage(BudgetAnalyserFeature.Dashboard, this, ShellDialogType.OkCancel)
     {
         CorrelationId = this.dialogCorrelationId,
         Title = "Global Filters - Account Type",
     };
     RaisePropertyChanged(() => IsAccountFilterView);
     RaisePropertyChanged(() => IsDateFilterView);
     MessengerInstance.Send(dialogRequest);
 }
        private void ShowDialogCommon(string title)
        {
            Canceled = false;
            List<AccountType> accountsToShow = this.accountTypeRepository.ListCurrentlyUsedAccountTypes().ToList();
            BankAccounts = accountsToShow.OrderBy(a => a.Name);
            SelectedBankAccount = null;
            this.dialogCorrelationId = Guid.NewGuid();
            var dialogRequest = new ShellDialogRequestMessage(BudgetAnalyserFeature.LedgerBook, this, ShellDialogType.OkCancel)
            {
                CorrelationId = this.dialogCorrelationId,
                Title = title,
            };

            MessengerInstance.Send(dialogRequest);
        }
 private void AddNewBankBalance()
 {
     BankBalances.Add(new BankBalance(SelectedBankAccount, BankBalance));
     SelectedBankAccount = null;
     BankBalance = 0;
 }