private void addBalanceColumn(DataTable summary) { AccountLoans loans = new AccountLoans(database, account); loans.IncludeClosedLoans = true; Dictionary<long, decimal> runningBalance = new Dictionary<long, decimal>(); Dictionary<long, decimal> runningProfit = new Dictionary<long, decimal>(); foreach (Loan loan in loans) { runningBalance[loan.Id] = loan.TotalPayable; runningProfit[loan.Id] = (loan.ProcessingFee + loan.ReloanFee); } summary.Columns.Add("balance", typeof(decimal)); summary.Columns.Add("profit", typeof(decimal)); foreach (DataRow row in summary.Rows) { long loanId = (long)row["loan_id"]; decimal balanceDeductible = (decimal)row["balance_deductible"]; decimal amount = (decimal)row["amount"]; decimal interestPayment = (decimal)row["interest_payment"]; decimal currentProfit = runningProfit[loanId] + interestPayment; decimal currentBalance = runningBalance[loanId] - balanceDeductible; row["balance"] = currentBalance; row["profit"] = currentProfit; runningBalance[loanId] = currentBalance; runningProfit[loanId] = currentProfit; } }
public bool Withdraw(ITransaction transaction) { if ((Balance - transaction.Amount) < 0 && Type == TypeFactory.CheckingAccount) { return(false); } else if ((Balance - transaction.Amount) < 0 && Type == TypeFactory.BusinessAccount) { if (OverDraftLoan == null) { OverDraftLoan = new BankLoan(.1, transaction.Amount - Balance, TypeFactory.GenerateLoanID(), TypeFactory.OverdraftLoan); AccountLoans.Add(OverDraftLoan); AccountTransactions.Add(transaction); Balance = 0; } else { OverDraftLoan.Amount += transaction.Amount; AccountLoans.Add(OverDraftLoan); } } else { Balance -= transaction.Amount; AccountTransactions.Add(transaction); } return(true); }
public LoanViewForm(Account account) { InitializeComponent(); this.account = account; Text = account.Name + " Loans"; accountLoans = new AccountLoans(DatabaseFactory.Default, account); accountLoans.StartDate = LoanBookForm.TimelineStartDate; accountLoans.EndDate = LoanBookForm.TimelineEndDate; accountLoans.IncludeClosedLoans = true; }
private void form_UpdateForm() { accountLoans = new AccountLoans(DatabaseFactory.Default, account); accountLoans.StartDate = LoanBookForm.TimelineStartDate; accountLoans.EndDate = LoanBookForm.TimelineEndDate; loanGrid.DataSource = accountLoans.Summary; if (FormUpdated != null) { FormUpdated(); } }
private void loadLoanSelector() { if (this.loan == null) { AccountLoans loanList = new AccountLoans(DatabaseFactory.Default, account); foreach (Loan loan in loanList) { loanSelector.Items.Add(loan); } } else { loanSelector.Items.Add(loan); loanSelector.SelectedItem = loan; } }
private void loadLoanSelector(Payment initialPayment = null) { if (this.loan == null) { AccountLoans loanList = new AccountLoans(DatabaseFactory.Default, account); loanList.IncludeClosedLoans = false; foreach (Loan loan in loanList) { loanSelector.Items.Add(loan); } } else { loanSelector.Items.Add(loan); loanSelector.SelectedItem = loan; } }