Exemple #1
0
        private void CalculateSpendToDiscount(decimal discountableTotal, OfferVoucher voucher)
        {
            decimal spendToOfferValid = voucher.offerThreshold - discountableTotal + 0.01m;

            Console.WriteLine("You have not reached the spend threshold for voucher " + voucher.offerCode
                              + ". Spend Another £" + spendToOfferValid + " to receive £" + voucher.offerValue + " discount from your basket total.");
            Console.WriteLine("Total: £" + basketPrice);
        }
Exemple #2
0
 public void Checkout(List <GiftVoucher> giftVouchers, OfferVoucher offerVoucher)
 {
     basketPrice = CalculateBasketPrice();
     OfferVoucherCalculation(offerVoucher);
     if (giftVouchers.Count > 0)
     {
         GiftVoucherCalculation(giftVouchers);
     }
 }
Exemple #3
0
        private void OfferVoucherCalculation(OfferVoucher offerVoucher)
        {
            decimal discountablePrice = GetDiscountableProductsPrice();

            if (offerVoucher.offerType.Equals(OfferType.Basket))
            {
                if (discountablePrice >= offerVoucher.offerThreshold)
                {
                    basketPrice = basketPrice - offerVoucher.offerValue;
                    outcomeText = "1 x £" + offerVoucher.offerValue + " off baskets over "
                                  + "£" + offerVoucher.offerThreshold + " Offer Voucher "
                                  + offerVoucher.offerCode + " applied";
                    Console.WriteLine(outcomeText);
                }
                else
                {
                    CalculateSpendToDiscount(discountablePrice, offerVoucher);
                }
            }
            else
            {
                if (basketPrice >= offerVoucher.offerThreshold)
                {
                    decimal discountedPrice = basketPrice;

                    for (int i = 0; i < basketContents.Count; i++)
                    {
                        if (basketContents[i].productCategory.categoryName.Equals(offerVoucher.offerCategory.categoryName))
                        {
                            discountedPrice = basketPrice - basketContents[i].basePrice;
                            outcomeText     = "1 x £" + offerVoucher.offerValue + " off baskets over "
                                              + "£" + offerVoucher.offerThreshold + " Offer Voucher "
                                              + offerVoucher.offerCode + " applied";
                            Console.WriteLine(outcomeText);
                            Console.WriteLine("Total: £" + discountedPrice);
                            break;
                        }
                    }
                    if (discountedPrice.Equals(basketPrice))
                    {
                        outcomeText = "There are no products in your basket applicable to voucher Voucher " + offerVoucher.offerCode;
                        Console.WriteLine(outcomeText);
                    }
                    else
                    {
                        basketPrice = discountedPrice;
                    }
                }
            }
        }