public Reloan(Database database, Loan loan) { this.database = database; this.originalLoan = loan; LoanFactory factory = new LoanFactory(DatabaseFactory.Default); reloan = factory.Clone(loan); reloan.IsReloan = true; }
public ReloanSaveForm(Account account, Loan loan = null) { this.account = account; this.originalLoan = loan; this.loan = cloneOriginalLoan(loan); reloan = new Reloan(DatabaseFactory.Default, originalLoan); InitializeComponent(); loadLoanSelector(); }
private void copyCommonProperties(Loan inputLoan, Loan outputLoan) { outputLoan.Id = inputLoan.Id; outputLoan.Account = inputLoan.Account; outputLoan.Principal = inputLoan.Principal; outputLoan.InterestRate = inputLoan.InterestRate; outputLoan.ProcessingFeePercentage = inputLoan.ProcessingFeePercentage; outputLoan.TakenDate = inputLoan.TakenDate; outputLoan.StartDate = inputLoan.StartDate; outputLoan.Remarks = inputLoan.Remarks; }
public Loan Create(Loan.LoanType type) { if (type == Loan.LoanType.AmortizedPayment) { return AmortizedLoan(); } else if (type == Loan.LoanType.InterestOnlyPayment) { return PerpetualInterestLoan(); } throw new ArgumentException("Unsupported loan type"); }
public PaymentHistoryForm(Account account, Loan loan = null) { this.account = account; this.loan = loan; InitializeComponent(); if (loan == null) { Text = account.Name + " Payment History For All Loans"; menuStrip.Visible = false; } else { Text = account.Name + " Payment History For " + loan.ToString(); } }
public PaymentForm(Account account, Loan loan = null, Payment payment = null) { this.account = account; this.loan = loan; if (payment == null) { payment = defaultPayment(); } this.payment = payment; this.payment.Account = account; this.payment.Loan = loan; paymentError = new ErrorProvider(this); loanError = new ErrorProvider(this); InitializeComponent(); Text = "Payment Form"; }
public LoanSaveForm(Account account, Loan loan = null) { if (loan == null) { loan = defaultLoan(); } this.account = account; this.loan = loan; this.loan.Account = account; principalError = new ErrorProvider(this); termError = new ErrorProvider(this); interestError = new ErrorProvider(this); processingFeeError = new ErrorProvider(this); InitializeComponent(); loadLoan(loan); }
public Loan Clone(Loan loan) { Loan clone; if (loan.Type == Loan.LoanType.AmortizedPayment) { clone = AmortizedLoan(); copyCommonProperties(loan, clone); clone.Term = loan.Term; } else if (loan.Type == Loan.LoanType.InterestOnlyPayment) { clone = PerpetualInterestLoan(); copyCommonProperties(loan, clone); } else { throw new ArgumentException("Unsupported loan type"); } return clone; }
private Loan cloneOriginalLoan(Loan originalLoan) { LoanFactory factory = new LoanFactory(DatabaseFactory.Default); return factory.Clone(originalLoan); }
public static decimal InterestPaymentPart(string amount, Loan loan) { return InterestPaymentPart(convertAmount(amount), loan); }
public static decimal PrincipalPaymentPart(string amount, Loan loan) { decimal amountValue; if (!decimal.TryParse(amount, out amountValue)) { throw new ArgumentException("Invalid amount."); } return PrincipalPaymentPart(amountValue, loan); }
private void loadLoan(Loan loan) { principalInput.Text = (loan.Principal == 0) ? "" : string.Format("{0:#,##0}", loan.Principal); interestInput.Text = loan.InterestRate.ToString(); processingFee.Text = (loan.ProcessingFeePercentage == 0) ? "" : string.Format("{0:#,##0}", loan.ProcessingFeePercentage); takenDateInput.Value = loan.TakenDate; startDateInput.Value = loan.StartDate; remarks.Text = loan.Remarks; if (loan.Type == Loan.LoanType.AmortizedPayment) { amortizedRadio.Checked = true; termInput.Text = (loan.Term == 0) ? "" : loan.Term.ToString(); termInput.Enabled = true; } else if (loan.Type == Loan.LoanType.InterestOnlyPayment) { monthlyInterestRadio.Checked = true; termInput.Enabled = false; } loadLoanComputations(loan); loadDateComputations(loan); }
private void loadDateComputations(Loan loan) { endDate.Text = loan.StartDate.AddMonths(loan.Term - 1).ToShortDateString(); }
private void toggleLoanType(Loan.LoanType type) { LoanFactory factory = new LoanFactory(DatabaseFactory.Default); if (type == Loan.LoanType.AmortizedPayment) { int term; bool parseResult = int.TryParse(termInput.Text, out term); term = parseResult ? term : 0; loan = factory.ConvertToAmortizedLoan(this.loan as PerpetualInterestLoan, term); } else if (type == Loan.LoanType.InterestOnlyPayment) { loan = factory.ConvertToPerpetualInterestLoan(this.loan as AmortizedLoan); } else { throw new ArgumentException("Unsupported loan type"); } }
private void loadLoanComputations(Loan loan) { monthlyDue.Text = string.Format("{0:#,##0}", loan.MonthlyDue); releaseAmount.Text = string.Format("{0:#,##0}", loan.ReleaseAmount); }
public static decimal MonthlyDue(Loan.LoanType type, string principal, string interest, string term = "0", bool nearestTenth = true) { decimal principalValue, interestValue; int termValue; if (!decimal.TryParse(principal, out principalValue)) { throw new ArgumentException("Invalid principal value"); } if (!decimal.TryParse(interest, out interestValue)) { throw new ArgumentException("Invalid interest value"); } if (type == Loan.LoanType.AmortizedPayment) { if (!int.TryParse(term, out termValue)) { throw new ArgumentException("Invalid term value"); } } else { termValue = 0; } return MonthlyDue(type, principalValue, interestValue, termValue, nearestTenth); }
public static decimal MonthlyDue(Loan.LoanType type, decimal principal, decimal interest, int term = 0, bool nearestTenth = true) { if (type == Loan.LoanType.AmortizedPayment) { return LoanCalculator.Amortization(principal, term, interest, nearestTenth); } else if (type == Loan.LoanType.InterestOnlyPayment) { return LoanCalculator.PayableInterest(principal, interest, nearestTenth); } throw new ArgumentException("Unsupported loan type"); }
public static decimal PrincipalPaymentPart(decimal amount, Loan loan) { return amount - InterestPaymentPart(amount, loan); }
public static decimal InterestPaymentPart(decimal amount, Loan loan) { return InterestPaymentPart(amount, loan.Principal, loan.InterestRate, loan.MonthlyDue); }
private Loan cloneOriginalLoan(Loan originalLoan) { LoanFactory factory = new LoanFactory(DatabaseFactory.Default); return(factory.Clone(originalLoan)); }