Ejemplo n.º 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;
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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");
 }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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";
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 9
0
 private Loan cloneOriginalLoan(Loan originalLoan)
 {
     LoanFactory factory = new LoanFactory(DatabaseFactory.Default);
     return factory.Clone(originalLoan);
 }
Ejemplo n.º 10
0
 public static decimal InterestPaymentPart(string amount, Loan loan)
 {
     return InterestPaymentPart(convertAmount(amount), loan);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 13
0
 private void loadDateComputations(Loan loan)
 {
     endDate.Text = loan.StartDate.AddMonths(loan.Term - 1).ToShortDateString();
 }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 15
0
 private void loadLoanComputations(Loan loan)
 {
     monthlyDue.Text = string.Format("{0:#,##0}", loan.MonthlyDue);
     releaseAmount.Text = string.Format("{0:#,##0}", loan.ReleaseAmount);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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");
 }
Ejemplo n.º 18
0
 private void loadLoanComputations(Loan loan)
 {
     monthlyDue.Text    = string.Format("{0:#,##0}", loan.MonthlyDue);
     releaseAmount.Text = string.Format("{0:#,##0}", loan.ReleaseAmount);
 }
Ejemplo n.º 19
0
 public static decimal PrincipalPaymentPart(decimal amount, Loan loan)
 {
     return amount - InterestPaymentPart(amount, loan);
 }
Ejemplo n.º 20
0
 private void loadDateComputations(Loan loan)
 {
     endDate.Text = loan.StartDate.AddMonths(loan.Term - 1).ToShortDateString();
 }
Ejemplo n.º 21
0
 public static decimal InterestPaymentPart(decimal amount, Loan loan)
 {
     return InterestPaymentPart(amount, loan.Principal, loan.InterestRate, loan.MonthlyDue);
 }
Ejemplo n.º 22
0
        private Loan cloneOriginalLoan(Loan originalLoan)
        {
            LoanFactory factory = new LoanFactory(DatabaseFactory.Default);

            return(factory.Clone(originalLoan));
        }