public decimal GetAllDiscountsInPercent() { if (MoneyDiscount > 0) { return(((Price - PriceWithDiscount) / Price) * 100); } return(PercentDiscount.GetValueOrDefault()); }
public override string ToString() { return("Code: " + Code + ", Name: " + Name + ", Cache: $" + Cache.ToString("F2", CultureInfo.InvariantCulture) + ", PercentDiscount: " + PercentDiscount.ToString("F2", CultureInfo.InvariantCulture)); }
public override string ToString() { return("Product: " + product.Description + ", Price: " + product.Price.ToString("F2", CultureInfo.InvariantCulture) + ", Amount: " + Amount + ", Discount:" + PercentDiscount.ToString("F2", CultureInfo.InvariantCulture) + ", SubTotal: " + SubTotal().ToString("F2", CultureInfo.InvariantCulture)); }
public void CanMakeTenPercentDiscountOnPepsi() { // arrange var pepsiTenPercentOff = new PercentDiscount { PercentOff = 10m, Product = Pepsi }; _order.AddDiscount(pepsiTenPercentOff); _order.ApplyDiscounts(); // act var total = _order.CalculateTotal(); // assert Assert.Equal(0.9m, total); }
public void UnableToApplySameDiscountsTwice() { // arrange var pepsiTenPercentOff = new PercentDiscount { PercentOff = 10m, Product = Pepsi }; _order.AddDiscount(pepsiTenPercentOff); // act _order.ApplyDiscounts(); _order.ApplyDiscounts(); // assert var total = _order.CalculateTotal(); Assert.Equal(0.9m, total); }
public async Task <CreateDiscoutPercentCommandResponse> Handle(CreateDiscountPercentCommand command) { await _percentDiscountDomainService.CheckPercentDiscountDate(command.FromDate.ConvertToDate(), command.ToDate.ConvertToDate()); var userInfo = new UserInfo(command.UserInfoCommand.UserId, command.UserInfoCommand.FirstName, command.UserInfoCommand.LastName); var discount = new PercentDiscount(Guid.NewGuid(), command.Description, userInfo, command.FromDate.ConvertToDate(), command.ToDate.ConvertToDate(), command.Title, command.Percent, command.MaxOrderCount, command.MaxProductCount, command.FromTime, command.ToTime) { ProductDiscounts = new List <ProductDiscount>(), Sells = new List <DiscountSell>() }; _percentRepository.Add(discount); return(new CreateDiscoutPercentCommandResponse()); }
public void DoDiscountCategoryPriceTest(double price, int discountValue, Category discountCategory, Category productCategory) { var product = new Product() { BasePrice = price, ResultPrice = price, Type = productCategory }; var discount = new PercentDiscount() { DiscountValue = discountValue, CategoryOfProduct = discountCategory }; discount.DoDiscount(product); if (discount.CategoryOfProduct == product.Type || discount.CategoryOfProduct == Category.All) { Assert.That(() => product.ResultPrice, Is.EqualTo(price * (1 - (discountValue * 0.01)))); } }
static void Main() { Form1 view = new Form1(); List <item> items = item.all(); CashierController controller = new CashierController(view, items); controller.Cashier.ClearDiscounts(); PercentComboDiscount comboDiscount = new PercentComboDiscount(); comboDiscount.Ids = new int[] { 0, 2, 3 }; comboDiscount.Quantities = new int[] { 2, 1, 1 }; comboDiscount.Percent = 40; //40% controller.Cashier.AddDiscount(comboDiscount); PriceComboDiscount comboDiscount1 = new PriceComboDiscount(); comboDiscount1.Ids = new int[] { 0, 2 }; comboDiscount1.Quantities = new int[] { 1, 1 }; comboDiscount1.Price = 5000; //VND controller.Cashier.AddDiscount(comboDiscount1); PercentDiscount discount = new PercentDiscount(); discount.ItemId = 3; discount.Percent = 10; //10% //controller.Cashier.AddDiscount(discount); PriceDiscount discount1 = new PriceDiscount(); discount1.ItemId = 2; discount1.Price = 4000; //VND //controller.Cashier.AddDiscount(discount1); controller.LoadView(); view.ShowDialog(); }
private void randomButton_Click(object sender, EventArgs e) { switch (Project.Rnd.Next(2)) { case 0: var percentDiscount = new PercentDiscount() { CategoryOfProduct = (Category)Project.Rnd.Next(4), DiscountValue = Project.Rnd.Next(101) }; iDiscountBindingSource.Add(percentDiscount); WriteDiscountInfo(percentDiscount, iDiscountBindingSource.Count - 1); break; case 1: var certificateDiscount = new CertificateDiscount() { CategoryOfProduct = (Category)Project.Rnd.Next(4), DiscountValue = Project.Rnd.Next(100000) }; iDiscountBindingSource.Add(certificateDiscount); WriteDiscountInfo(certificateDiscount, iDiscountBindingSource.Count - 1); break; } discountListDataGridView.Update(); }
public double ValueTest(double value) { var discount = new PercentDiscount(value); return(discount.Value()); }
public double PercentTest(double value) { var discount = new PercentDiscount(value); return(discount.Percent); }
public void PercentCalculateTestThrows(double price, double value) { var discount = new PercentDiscount(value); Assert.That(() => discount.Calculate(price), Throws.TypeOf <ArgumentException>()); }
public void PercentCalculateTest(double price, double value, double result) { var discount = new PercentDiscount(value); Assert.That(() => discount.Calculate(price), Is.EqualTo(result)); }
public string DescriptionTest(double value) { var discount = new PercentDiscount(value); return(discount.Description); }
public void NegativeDiscountValueTest(int value) { var discount = new PercentDiscount(); Assert.That(() => discount.DiscountValue = value, Throws.Exception.TypeOf <ArgumentOutOfRangeException>()); }
public void PositiveDiscountValueTest(int value) { var discount = new PercentDiscount(); Assert.That(() => discount.DiscountValue = value, Is.EqualTo(value)); }
public static IPercentDiscountDto ToDiscountDto(this PercentDiscount src) { return(AutoMapper.Mapper.Map <IPercentDiscountDto>(src)); }