Example #1
0
        public void CreateInvoice_CalculatesPreTaxTotal(int product1Count, int product2Count, int product3Count, int product4Count, double expectedTotal)
        {
            var markdown = MarkdownProvider.GetMarkdown(DateRange.Active, 0.10m);
            var special  = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Active, 2, 1, 50m);

            var product1 = new Product("product", Money.USDollar(1m), SellByType.Unit);
            var product2 = new Product("product with markdown", Money.USDollar(1m), SellByType.Unit)
            {
                Markdown = markdown
            };
            var product3 = new Product("product with special", Money.USDollar(1m), SellByType.Unit)
            {
                Special = special
            };
            var product4 = new Product("product with markdown and special", Money.USDollar(1m), SellByType.Unit)
            {
                Markdown = markdown, Special = special
            };

            PopulateOrder(product1, product1Count);
            PopulateOrder(product2, product2Count);
            PopulateOrder(product3, product3Count);
            PopulateOrder(product4, product4Count);

            _order.Invoice.PreTaxTotal.Amount.Should().Be((decimal)expectedTotal);
        }
Example #2
0
        public static IEnumerable <object[]> MarkdownsSpecialsAndExpectedLineItems()
        {
            var special  = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Active, 2, 1, 50m);
            var markdown = MarkdownProvider.GetMarkdown(DateRange.Active, 0.1m);

            yield return(new object[] { null, special, 3, 0, 0 });

            yield return(new object[] { markdown, special, 3, 0, 0 });

            yield return(new object[] { markdown, special, 5, 2, -0.2m });
        }
Example #3
0
        public void CreateLineItems_WithBetterMarkdown_CreatesZeroLineItems(double retailPrice, double markdown, int preDiscountItems, int discountedItems, double percentageOff, int scannedItemCount)
        {
            var product = new Product("test product", Money.USDollar(retailPrice), SellByType.Unit)
            {
                Markdown = MarkdownProvider.GetMarkdown(DateRange.Active, (decimal)markdown)
            };

            var special = CreateSpecial(preDiscountItems, discountedItems, (decimal)percentageOff, null);

            CreateLineItems(product, special, scannedItemCount);

            _lineItems.Count().Should().Be(0);
        }
        public void CreateLineItems_WithBetterMarkdown_CreatesZeroLineItems(double retailPrice, double markdown, int discountedItems, double groupSalePrice, int scannedItemCount)
        {
            var product = new Product("test product", Money.USDollar(retailPrice), SellByType.Unit)
            {
                Markdown = MarkdownProvider.GetMarkdown(DateRange.Active, (decimal)markdown)
            };

            var special = new BuyNForXAmountSpecial(_now.StartOfWeek(), _now.EndOfWeek(), discountedItems, Money.USDollar((decimal)groupSalePrice));

            CreateLineItems(product, special, scannedItemCount);

            _lineItems.Count().Should().Be(0);
        }
        public static ICollection <Product> GetOneOfEachProduct(decimal retailPriceAmount = 1m, decimal markdownAmount = 0.5m)
        {
            var retailPrice = Money.USDollar(retailPriceAmount);
            var markdown    = Money.USDollar(markdownAmount);

            /// <remarks>
            /// code:
            ///     E, W - eaches/weighted product
            ///     M - markdown
            ///     S - special
            ///     nM, nS - invalid (expired/future) markdown/special
            /// </remarks>
            return(new List <Product>
            {
                new Product("E", retailPrice, SellByType.Unit),
                new Product("E M", retailPrice, SellByType.Unit)
                {
                    Markdown = MarkdownProvider.GetMarkdown(DateRange.Active, markdownAmount)
                },
                new Product("E nM", retailPrice, SellByType.Unit)
                {
                    Markdown = MarkdownProvider.GetMarkdown(DateRange.Expired, markdownAmount)
                },
                new Product("E S", retailPrice, SellByType.Unit)
                {
                    Special = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Active)
                },
                new Product("E nS", retailPrice, SellByType.Unit)
                {
                    Special = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Expired)
                },
                new Product("W", retailPrice, SellByType.Weight),
                new Product("W M", retailPrice, SellByType.Weight)
                {
                    Markdown = MarkdownProvider.GetMarkdown(DateRange.Active, markdownAmount)
                },
                new Product("W nM", retailPrice, SellByType.Weight)
                {
                    Markdown = MarkdownProvider.GetMarkdown(DateRange.Expired, markdownAmount)
                },
                new Product("W S", retailPrice, SellByType.Weight)
                {
                    Special = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Active)
                },
                new Product("W nS", retailPrice, SellByType.Weight)
                {
                    Special = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Expired)
                }
            });
        }
Example #6
0
        public static IEnumerable <object[]> InvalidDiscountProducts()
        {
            var product = new Product("test product", Money.USDollar(1m), SellByType.Unit);

            yield return(new object[] { product });

            product.Markdown = MarkdownProvider.GetMarkdown(DateRange.Expired);
            yield return(new object[] { product });

            product.Special = SpecialProvider.GetBuyNGetMAtXPercentOffSpecial(DateRange.Expired);
            yield return(new object[] { product });

            product.Markdown = null;
            yield return(new object[] { product });
        }
Example #7
0
        public void CreateProductMarkdownLineItems_CreatesOneMarkdownLineItemPerScannedItem(int scannedItemCount)
        {
            var product = new Product("product with markdown", Money.USDollar(1m), SellByType.Unit)
            {
                Markdown = MarkdownProvider.GetMarkdown(DateRange.Active)
            };

            PopulateOrder(product, scannedItemCount);

            var lineItems = InvoiceFactory.CreateProductMarkdownLineItems(_order.ScannedItems).ToList();

            var lineItemScannedItemIds = lineItems.Select(x => ((MarkdownLineItem)x).ScannedItemId).ToList();

            lineItemScannedItemIds.Should().OnlyHaveUniqueItems();
            lineItemScannedItemIds.Should().BeEquivalentTo(_order.ScannedItems.Select(x => x.Id));
        }