Beispiel #1
0
 public PartData CalculateLineTotals(PartData line)
 {
     var curline = line;
     var extendedPrice = curline.UnitPrice * curline.Quantity;
     var totalDiscount = extendedPrice * curline.DiscountPercent;
     extendedPrice = extendedPrice - totalDiscount;
     curline.UpfrontAmount = extendedPrice * (curline.UpfrontPercent);
     curline.FinancedAmount = extendedPrice - curline.UpfrontAmount;
     return curline;
 }
Beispiel #2
0
 public PartData LoadLineData(PartData line)
 {
     var curline = line;
     var part = _partsRepo.GetPartByName(line.PartName);
     if (curline.UnitPrice == 0) curline.UnitPrice = part.UnitPrice;
     if (curline.UpfrontPercent == 0) curline.UpfrontPercent = part.UpfrontPercent;
     curline.DiscountPercent = curline.DiscountPercent / 100;
     return curline;
 }
Beispiel #3
0
 public void Should_be_able_to_load_missing_part_data()
 {
     var line = new PartData {PartName = "Basic Microcontroller"};
     line = DefaultContext.FinanceTask.LoadLineData(line);
     Assert.AreEqual(.1M,line.UpfrontPercent);
     Assert.AreEqual(125M,line.UnitPrice);
 }
Beispiel #4
0
 public void Should_calculate_amount_down_after_discount()
 {
     var line = new PartData { DiscountPercent = .25M, Quantity = 1, UnitPrice = 100, UpfrontPercent = .1M};
     var expectedBalance = 67.5M;
     var expectedDue = 7.5M;
     line = DefaultContext.FinanceTask.CalculateLineTotals(line);
     Assert.AreEqual(expectedBalance, line.FinancedAmount);
     Assert.AreEqual(expectedDue, line.UpfrontAmount);
 }
Beispiel #5
0
 public void Should_be_able_to_calculate_extended_costs()
 {
     var line = new PartData { DiscountPercent = .25M, Quantity = 2, UnitPrice = 100 };
     var expectedBalance = 150M;
     line = DefaultContext.FinanceTask.CalculateLineTotals(line);
     Assert.AreEqual(expectedBalance, line.FinancedAmount);
 }