Esempio n. 1
0
        /// <summary>
        /// Show bank transaction split dialog
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IActionResult Split(string id)
        {
            id = Uri.UnescapeDataString(id);
            var accounts = accountRepository.GetAccountList();
            var bankTrx  = bankTransactionRepository.GetBankTransaction(id);
            var trx      = new Transaction(bankTrx, accounts);

            ViewBag.LastCreditCardStatement = Directory.GetFiles(settingsService.GetCreditCardStatementPath()).OrderByDescending(s => s).FirstOrDefault();
            return(View("Split", trx));
        }
Esempio n. 2
0
        public List <Transaction> MatchCreditCardTransactions(string bankTransactionId, IReadOnlyList <CreditCardTransaction> creditCardTransactions)
        {
            var accounts     = accountRepository.GetAccountList();
            var bankTrx      = bankTransactionRepository.GetBankTransaction(bankTransactionId);
            var bookingRules = bookingRuleRepository.GetBookingRuleList();

            var trxList = new List <Transaction>();

            foreach (var creditCardTransaction in creditCardTransactions)
            {
                var trx = new Transaction(bankTrx, accounts);
                trx.Value       = -1 * creditCardTransaction.Amount;
                trx.BookingDate = bankTrx.BookingDate;
                trx.ValueDate   = creditCardTransaction.TransactionDate;

                MatchBankTransactionByBookingRule(creditCardTransaction.Transaction, trx, bookingRules);

                if (string.IsNullOrEmpty(trx.Text))
                {
                    trx.Text = creditCardTransaction.Transaction;
                }
                trxList.Add(trx);
            }

            return(trxList);
        }