Пример #1
0
 public ShoppingCart(Guid sessionId, string userName, Currency currency, TaxRate taxRate, ChargeRate chargeRate)
 {
     this.Id = Guid.NewGuid();
     this.SessionId = sessionId;
     this.UserName = userName;
     this.Items = new List<Item>();
     this.ItemsRemoved = new List<ItemRemoved>();
     this.Date = DateTime.Now;
     this.Currency = currency;
     this.TransactionNumber = string.Empty;
     this.Note = string.Empty;
     this.Payment = new Payment(PaymentTypes.Cash, 0d, 0d);
     var chargeAmount = chargeRate.Apply(0d);
     var taxAmount = taxRate.Apply(0d);
     var discountAmount = DiscountRate.None.Apply(0d, 0);
     this.Summary = new Summary(taxAmount, discountAmount, chargeAmount, 0d);
 }
Пример #2
0
 private void CalculateTax()
 {
     if (Summary.TaxAmount.Percent > 0)
     {
         var taxRate = new TaxRate(Summary.TaxAmount.Code, Summary.TaxAmount.Name, Summary.TaxAmount.Percent);
         var taxAmount = taxRate.Apply(Summary.SubTotal - Summary.DiscountTotalAmount + Summary.ChargeAmount);
         this.Summary = new Summary(taxAmount, Summary.DiscountTotalAmount, Summary.ChargeAmount, Summary.SubTotal);
     }
 }