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 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; } }