Пример #1
0
 public void Save()
 {
     foreach (var account in Accounts)
     {
         account.TotalAmount = AccountTransactions.Where(c => c.AccountId == account.AccountId).Sum(c => c.Amount);
     }
     write();
 }
Пример #2
0
        public decimal CalculateAccountBalance(int accountNo)
        {
            Account account = null;

            using (var core = new StandardBusinessLayer(this))
            {
                core.Connect();
                account = core.GetAccount(accountNo);
            }

            //var earlierTransactions = EarlierAccountTransactions.Where(t => t.AccountNo == accountNo).ToList();
            var transactions = AccountTransactions.Where(t => t.AccountNo == accountNo).ToList();

            //var earlierTotalAmount = earlierTransactions.Sum(t => t.Amount);
            var transactionsTotalAmount = transactions.Sum(t => t.Amount);

            //return account.BalanceBroughtForwardAmount + earlierTotalAmount + transactionsTotalAmount;
            return(account.BalanceBroughtForwardAmount + transactionsTotalAmount);
        }
Пример #3
0
        private void FillVerification(Verification verification)
        {
            var accountTransactions  = AccountTransactions.Where(t => t.VerificationNo == verification.No).ToList();
            var cashbookTransactions = CashBookTransactions.Where(t => t.VerificationNo == verification.No).ToList();

            var accountTransactionCollection = new AccountTransactionCollection();

            foreach (var accountTransaction in accountTransactions)
            {
                accountTransactionCollection.Add(accountTransaction);
            }

            var cashbookTransactionCollection = new CashBookTransactionCollection();

            foreach (var cashbookTransaction in cashbookTransactions)
            {
                cashbookTransactionCollection.Add(cashbookTransaction);
            }

            verification.AccountTransactions  = accountTransactionCollection;
            verification.CashBookTransactions = cashbookTransactionCollection;
        }
Пример #4
0
        public void DeleteAccountTransactionsByVerificationNo(int verificationNo)
        {
            using (var core = new StandardBusinessLayer(this))
            {
                core.Connect();

                var transactions = AccountTransactions.Where(t => t.VerificationNo == verificationNo).ToList();

                if (transactions.Count() > 0)
                {
                    var verification = Verifications.FirstOrDefault(v => v.No == transactions[0].VerificationNo);

                    core.DeleteAccountTransactionsByVerificationNo(verificationNo);

                    foreach (var transaction in transactions)
                    {
                        AccountTransactions.Remove(transaction);
                    }

                    FillVerification(verification);
                }
            }
        }