예제 #1
0
        public PaymentSchedule GeneratePaymentSchedule(PaymentData order)
        {
            var sched = new PaymentSchedule();
            sched.CreditBalance = order.CreditAmount;
            sched.GiftCardBalance = order.GiftCardAmount;
            sched.UpfrontDue = order.UpfrontTotal;

            //Default in case rate is 0%
            var payment = (double)order.FinancedTotal / order.Terms;

            if (order.APR > 0)
            {
                var rate = (double)order.APR / 1200;
                payment = rate * (double)order.FinancedTotal / (1 - Math.Pow((1 + rate), (order.Terms * -1)));
            }

            var roundPayment = Math.Round(payment, 2);
            //Always round up!
            if (roundPayment < payment) roundPayment += .01;

            sched.MonthlyPayment = (Decimal)roundPayment;
            var totalDue = payment * order.Terms;
            var totalPayments = sched.MonthlyPayment * order.Terms;
            var finalAdjustment = (decimal)totalDue - totalPayments;
            sched.FinalPayment = sched.MonthlyPayment + Math.Round(finalAdjustment, 2);
            return sched;
        }
예제 #2
0
 public void BeforeScenario()
 {
     var order = new PaymentData();
     var schedule = new PaymentSchedule();
     ScenarioContext.Current.Set(order);
     ScenarioContext.Current.Set(schedule);
     ScenarioContext.Current.Set(_payTasks);
 }
예제 #3
0
        public void BeforeLargeOrderScenario()
        {
            var order = new PaymentData();
            var schedule = new PaymentSchedule();

            var parts = new List<PartData>
                {
                    new PartData {PartName = "Flexible whisker sensors", UnitPrice = 100M, UpfrontPercent = 0M, DiscountPercent = .1M, Quantity = 100},
                    new PartData {PartName = "Assorted Gears and Bearings", UnitPrice = 50M, UpfrontPercent = 0M, DiscountPercent = 0M, Quantity = 100},
                    new PartData {PartName = "Mountable Halogen Floodlights", UnitPrice = 100M, UpfrontPercent = .1M, DiscountPercent = .05M, Quantity = 50}
                };
            order.Parts = parts.ToArray();
            ScenarioContext.Current.Set(order);
            ScenarioContext.Current.Set(schedule);
            ScenarioContext.Current.Set(_payTasks);
        }
예제 #4
0
 public void WhenIRequestAPaymentSchedule()
 {
     var tasks = new FinanceTasks(null);
     _schedule = tasks.GeneratePaymentSchedule(_payment);
 }