Пример #1
0
 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;
 }
Пример #2
0
        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();
        }
Пример #3
0
 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;
 }
Пример #4
0
 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");
 }
Пример #5
0
 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();
     }
 }
Пример #6
0
 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";
 }
Пример #7
0
        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);
        }
Пример #8
0
        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;
        }
Пример #9
0
 private Loan cloneOriginalLoan(Loan originalLoan)
 {
     LoanFactory factory = new LoanFactory(DatabaseFactory.Default);
     return factory.Clone(originalLoan);
 }
Пример #10
0
 public static decimal InterestPaymentPart(string amount, Loan loan)
 {
     return InterestPaymentPart(convertAmount(amount), loan);
 }
Пример #11
0
 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);
 }
Пример #12
0
        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);
        }
Пример #13
0
 private void loadDateComputations(Loan loan)
 {
     endDate.Text = loan.StartDate.AddMonths(loan.Term - 1).ToShortDateString();
 }
Пример #14
0
        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");
            }
        }
Пример #15
0
 private void loadLoanComputations(Loan loan)
 {
     monthlyDue.Text = string.Format("{0:#,##0}", loan.MonthlyDue);
     releaseAmount.Text = string.Format("{0:#,##0}", loan.ReleaseAmount);
 }
Пример #16
0
        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);
        }
Пример #17
0
 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");
 }
Пример #18
0
 private void loadLoanComputations(Loan loan)
 {
     monthlyDue.Text    = string.Format("{0:#,##0}", loan.MonthlyDue);
     releaseAmount.Text = string.Format("{0:#,##0}", loan.ReleaseAmount);
 }
Пример #19
0
 public static decimal PrincipalPaymentPart(decimal amount, Loan loan)
 {
     return amount - InterestPaymentPart(amount, loan);
 }
Пример #20
0
 private void loadDateComputations(Loan loan)
 {
     endDate.Text = loan.StartDate.AddMonths(loan.Term - 1).ToShortDateString();
 }
Пример #21
0
 public static decimal InterestPaymentPart(decimal amount, Loan loan)
 {
     return InterestPaymentPart(amount, loan.Principal, loan.InterestRate, loan.MonthlyDue);
 }
Пример #22
0
        private Loan cloneOriginalLoan(Loan originalLoan)
        {
            LoanFactory factory = new LoanFactory(DatabaseFactory.Default);

            return(factory.Clone(originalLoan));
        }