Example #1
0
        public ReturnMessage <Discounts_VM> GetDiscountByType(int Type)
        {
            var GetDiscount = new ReturnMessage <Discounts_VM>();

            try
            {
                if (Type > 0)
                {
                    GetDiscount = getDiscount.GetDiscountByType(Type);
                }

                else
                {
                    GetDiscount.ResponseCode        = "01";
                    GetDiscount.ResponseDescription = "Valid ID is required";
                    GetDiscount.Body = null;
                }
            }
            catch (Exception ex)
            {
                logger.Debug(ex, "Error retrieving Customer records");

                GetDiscount.ResponseCode        = "96";
                GetDiscount.ResponseDescription = "Unable to retreive Customer records";
            }
            return(GetDiscount);
        }
Example #2
0
        public InvoiceAmount ComputePrice(TotalBill order)
        {
            var invoiceAmount = new InvoiceAmount();
            var content       = (int)System.Enum.Parse(typeof(User_Type), order.UserType);


            var GetDiscount = getDiscountType.GetDiscountByType(content);

            order.DiscountPercentage = GetDiscount.Body.DiscountPercentage;
            decimal nonDiscounted = order.orders.Sum(p => p.Price);

            #region
            //OLD IMPLEMENTATION

            //decimal baseDiscount = _discountPoliciesMethods.BaseDiscount(order);
            //decimal[] discounts = new[] {

            //    _discountPoliciesMethods.CustomeTypeDiscount(order),

            //    _discountPoliciesMethods.CustomerLoyaltyDiscount(order),

            //};
            //decimal bestDiscount = discounts.Max(discount => discount);

            //var totalDiscount = bestDiscount + baseDiscount;

            #endregion
            var totalDiscount2 = discountMethodProcessor.GetTotalDiscount(order);
            var total          = nonDiscounted - totalDiscount2;
            invoiceAmount.InvoicePrice       = total.ToString();
            invoiceAmount.DiscountCalculated = totalDiscount2.ToString();

            invoiceAmount.UndiscountedPrice = nonDiscounted.ToString();
            logger.Information($"Invoice to be paid  => {JsonConvert.SerializeObject(invoiceAmount)}");

            return(invoiceAmount);
        }