当前位置: 首页>>代码示例>>C#>>正文


C# Ticket.AddTicketDiscount方法代码示例

本文整理汇总了C#中Samba.Domain.Models.Tickets.Ticket.AddTicketDiscount方法的典型用法代码示例。如果您正苦于以下问题:C# Ticket.AddTicketDiscount方法的具体用法?C# Ticket.AddTicketDiscount怎么用?C# Ticket.AddTicketDiscount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Samba.Domain.Models.Tickets.Ticket的用法示例。


在下文中一共展示了Ticket.AddTicketDiscount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanAddTicketDiscounts

        public void CanAddTicketDiscounts()
        {
            var mi = new MenuItem("Elma");
            mi.AddPortion("Test", 10, "TL");
            var mi2 = new MenuItem("Armut");
            mi2.AddPortion("Test", 15, "TL");

            var ticket = new Ticket();
            ticket.AddTicketItem(0, mi, "Test");
            ticket.AddTicketItem(0, mi2, "Test");

            Assert.IsTrue(ticket.GetSum() == 25);

            ticket.AddTicketDiscount(DiscountType.Percent, 10, 0);
            Assert.IsTrue(ticket.GetSum() == 22.5m);

            ticket.AddTicketDiscount(DiscountType.Percent, 20, 0);

            Assert.IsTrue(ticket.GetSum() == 20.0m);

            ticket.AddTicketDiscount(DiscountType.Amount, 10, 0);
            Assert.IsTrue(ticket.GetSum() == 10);

            Assert.IsTrue(ticket.GetDiscountAndRoundingTotal() == 15);

            ticket.AddTicketDiscount(DiscountType.Amount, 5, 0);

            Assert.IsTrue(ticket.GetSum() == 15);
            Assert.IsTrue(ticket.GetDiscountAndRoundingTotal() == 10);

            ticket.AddTicketDiscount(DiscountType.Percent, 0, 0);
            ticket.AddTicketDiscount(DiscountType.Amount, 0, 0);

            Assert.IsTrue(ticket.GetSum() == 25);
            Assert.IsTrue(ticket.GetDiscountAndRoundingTotal() == 0);
            Assert.IsTrue(ticket.Discounts.Count == 0);

            ticket.AddTicketDiscount(DiscountType.Percent, 50, 0);
            Assert.IsTrue(ticket.GetSum() == 12.5m);
            Assert.IsTrue(ticket.Discounts.Count == 1);

            ticket.AddTicketDiscount(DiscountType.Percent, 0, 0);
            Assert.IsTrue(ticket.Discounts.Count == 0);
            Assert.IsTrue(ticket.GetSum() == 25);

            ticket.TicketItems[0].Gifted = true;
            Assert.IsTrue(ticket.GetSum() == 15);

            ticket.AddTicketDiscount(DiscountType.Percent, 10, 0);
            Assert.IsTrue(ticket.GetSum() == 13.5m);
            Assert.IsTrue(ticket.GetDiscountAndRoundingTotal() == 1.5m);

            ticket.TicketItems[0].Voided = true;
            Assert.IsTrue(ticket.GetSum() == 13.5m);

            ticket.AddTicketDiscount(DiscountType.Percent, 10, 0);
            Assert.AreEqual(13.5m, ticket.GetSum());
            Assert.AreEqual(1.5m, ticket.GetDiscountAndRoundingTotal());

            ticket.AddTicketDiscount(DiscountType.Amount, 0.5m, 0);
            Assert.AreEqual(13m, ticket.GetSum());

            ticket.Discounts.Clear();
            Assert.AreEqual(15m, ticket.GetSum());
            var t = new VatTemplate { Rate = 10 };

            var mix = new MenuItem("TestItem2") { VatTemplate = t };
            mix.AddPortion("Adet", 10, "TL");
            ticket.AddTicketItem(0, mix, "Adet");

            Assert.AreEqual(26m, ticket.GetSum());

            ticket.AddTicketDiscount(DiscountType.Percent, 10, 0);
            Assert.AreEqual(23.4m, ticket.GetSum());
            ticket.AddTicketDiscount(DiscountType.Amount, 0.4m, 0);
            Assert.AreEqual(23m, ticket.GetSum());
        }
开发者ID:hpbaotho,项目名称:sambapos,代码行数:77,代码来源:TicketTest.cs


注:本文中的Samba.Domain.Models.Tickets.Ticket.AddTicketDiscount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。