public void Save() { foreach (var account in Accounts) { account.TotalAmount = AccountTransactions.Where(c => c.AccountId == account.AccountId).Sum(c => c.Amount); } write(); }
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); }
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; }
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); } } }