Esempio n. 1
0
 internal Item(Product product, int quantity, DiscountRate discountRate)
     : this()
 {
     this.Product = product;
     this.Quantity = 1;
     this.DiscountRate = discountRate;
     Calculate();
 }
Esempio n. 2
0
 private void CalculateSharedDiscount()
 {
     if (!Summary.DiscountTotalAmount.IsZero())
     {
         var discountTotalRate = new DiscountRate(DiscountType.Percent, Summary.DiscountTotalAmount.Percent);
         var discountTotalAmount = discountTotalRate.Apply(Summary.SubTotal, 1);
         this.Summary = new Summary(Summary.TaxAmount, discountTotalAmount, Summary.ChargeAmount, Summary.SubTotal);
         foreach (Item item in Items)
         {
             item.ChangeDiscountTotal(Summary.SubTotal, discountTotalAmount);
         }
     }
 }
Esempio n. 3
0
 public void ChangeDiscountTotal(DiscountRate discountTotalRate)
 {
     var discountTotalAmount = discountTotalRate.Apply(Summary.SubTotal, 1);
     foreach (Item item in Items)
     {
         item.ChangeDiscountTotal(Summary.SubTotal, discountTotalAmount);
     }
     this.Summary = new Summary(Summary.TaxAmount, discountTotalAmount, Summary.ChargeAmount, Summary.SubTotal);
     CalculateCharge();
     CalculateTax();
 }
Esempio n. 4
0
 public void ChangeDiscount(Guid itemId, DiscountRate discountRate)
 {
     var item = GetItem(itemId);
     item.ChangeDiscount(discountRate);
     CalculateSummary();
 }
Esempio n. 5
0
 public Guid AddItem(Product product, DiscountRate discountRate)
 {
     Item item = GetItem(product);
     if (item.IsNull())
     {
         item = new Item(product, 1, discountRate);
         Items.Add(item);
     }
     else
         item.AddQuantity(1);
     CalculateSummary();
     return item.Id;
 }
Esempio n. 6
0
 internal void ChangeDiscount(DiscountRate discountRate)
 {
     this.DiscountRate = discountRate;
     Calculate();
 }