Ejemplo n.º 1
0
        public void half_way_balances()
        {
            var lt       = new HalfWayLoanType();
            var balances = lt.GetBalances(1000, 3).ToArray();

            Assert.That(balances.Length, Is.EqualTo(3));

            Assert.That(balances[0], Is.EqualTo(1000));
            Assert.That(balances[1], Is.EqualTo(500));
            Assert.That(balances[2], Is.EqualTo(0));
        }
Ejemplo n.º 2
0
        public void next_early_payment_for_halfway_loan()
        {
            var now = new DateTime(2013, 01, 01);

            var type = new HalfWayLoanType();
            var loan = new Loan()
            {
                LoanType = type, LoanAmount = 1000, Date = now
            };
            var schedule = _calculator.Calculate(1000m, loan, now);

            Console.WriteLine(loan);

            var pc = new LoanRepaymentScheduleCalculator(loan, now, 0);

            var ep = pc.NextEarlyPayment();

            Assert.That(ep, Is.EqualTo(500));
        }
Ejemplo n.º 3
0
        public void paying_late()
        {
            var now = Parse("2012-10-27 00:00:00.000");

            var type = new HalfWayLoanType();
            var loan = new Loan()
            {
                LoanType = type, LoanAmount = 1000, Date = now
            };

            _calculator.Calculate(1000m, loan, now);

            Console.WriteLine(loan);

            MakePayment(loan, 658.71m, Parse("2013-01-16 14:35:25.000"));

            Assert.That(loan.Schedule[0].Status, Is.EqualTo(LoanScheduleStatus.Paid));
            Assert.That(loan.Schedule[1].Status, Is.EqualTo(LoanScheduleStatus.Paid));
            Assert.That(loan.Schedule[2].Status, Is.EqualTo(LoanScheduleStatus.StillToPay));
        }
Ejemplo n.º 4
0
        public void interest_only_payments_can_be_late()
        {
            var now = Parse("2012-10-27 00:00:00.000");

            var type = new HalfWayLoanType();
            var loan = new Loan()
            {
                LoanType = type, LoanAmount = 1000, Date = now
            };

            _calculator.Calculate(1000m, loan, now);

            var pc = new LoanRepaymentScheduleCalculator(loan, Parse("2013-01-16 00:00:00.000"), 0);
            var ep = pc.NextEarlyPayment();

            Console.WriteLine(loan);

            Assert.That(loan.Schedule[0].Status, Is.EqualTo(LoanScheduleStatus.Late));
            Assert.That(loan.Schedule[1].Status, Is.EqualTo(LoanScheduleStatus.Late));
            Assert.That(loan.Schedule[2].Status, Is.EqualTo(LoanScheduleStatus.StillToPay));
        }
Ejemplo n.º 5
0
        public void build_model_for_halfway_loan()
        {
            var now = new DateTime(2013, 01, 01);

            var type = new HalfWayLoanType();
            var loan = new Loan()
            {
                LoanType = type, LoanAmount = 1000, Date = now
            };
            var schedule = _calculator.Calculate(1000m, loan, now);

            Console.WriteLine(loan);

            var pc = new LoanRepaymentScheduleCalculator(loan, now, 0);

            var model = LoanModel.FromLoan(loan, pc);

            Console.WriteLine(loan);

            Assert.That(schedule[0].Interest, Is.EqualTo(60));
            Assert.That(schedule[1].Interest, Is.EqualTo(60));
        }