//cn
        public LineItemPricingInfo GetLineItemPricing(PackagingSummary packagingSummary, Guid outletId)
        {
            UnitPriceDiscount unitPriceDiscount = null;
            LineItemPricingInfo pricingInfo = new LineItemPricingInfo();
            unitPriceDiscount = GetUnitPrice(packagingSummary.Product.Id, outletId);

            decimal unitPrice = unitPriceDiscount.UnitPrice;
            decimal totalNetPrice = unitPrice * packagingSummary.Quantity;
            decimal vatValue = GetVAT(packagingSummary.Product.Id, outletId); //
            decimal totalVatAmount = vatValue * packagingSummary.Quantity;
            decimal totalPrice = totalNetPrice + totalVatAmount;

            pricingInfo.UnitPrice = unitPrice;
            pricingInfo.VatValue = vatValue;
            pricingInfo.TotalVatAmount = totalVatAmount;
            pricingInfo.TotalNetPrice = totalNetPrice;
            pricingInfo.TotalPrice = totalPrice;
            pricingInfo.ProductDiscount = unitPriceDiscount.Discount;
            pricingInfo.TotalProductDiscount = (unitPriceDiscount.Discount * packagingSummary.Quantity);

            return pricingInfo;
        }
 private void InsertSummary(List<PackagingSummary> proccesTemp, Product product, decimal quantity, bool isEditable, bool isAuto, bool isMix, Guid parentProductId)
 {
     PackagingSummary summary = null;
     if (isMix)
         summary = proccesTemp.FirstOrDefault(p => p.Product.Id == product.Id && p.IsAuto == isAuto);
     else
         summary = proccesTemp.FirstOrDefault(p => p.Product.Id == product.Id && p.IsAuto == isAuto && p.ParentProductId == parentProductId);
     if (summary == null)
     {
         summary = new PackagingSummary()
         {
             Product = product,
             Quantity = quantity,
             IsEditable = isEditable,
             IsAuto = isAuto,
         };
         if (!isMix)
             summary.ParentProductId = parentProductId;
         proccesTemp.Add(summary);
     }
     else
     {
         summary.Quantity += quantity;
     }
 }
        public LineItemPricingInfo GetPurchaseLineItemPricing(PackagingSummary packagingSummary)
        {
            LineItemPricingInfo pricingInfo = new LineItemPricingInfo();
            decimal UnitPrice = 0;
            decimal vatValue = 0;
            if (packagingSummary.Product is ConsolidatedProduct)
                try
                {
                    UnitPrice = packagingSummary.Product.ExFactoryPrice;
                }
                catch
                {
                    UnitPrice = 0m;
                }
            else
                try
                {
                    UnitPrice = packagingSummary.Product.ExFactoryPrice;
                }
                catch
                {
                    UnitPrice = 0m;
                }
            //if (packagingSummary.Product.VATClass != null && packagingSummary.Product is SaleProduct)
            //    vatValue = packagingSummary.Product.VATClass.CurrentRate;
            //else
            //    vatValue = 0;
            vatValue = 0;

            decimal totalNetPrice = UnitPrice * packagingSummary.Quantity;
            decimal totalVatAmount = vatValue * packagingSummary.Quantity;
            decimal totalPrice = totalNetPrice + totalVatAmount;

            pricingInfo.UnitPrice = UnitPrice;
            pricingInfo.VatValue = vatValue;
            pricingInfo.TotalVatAmount = totalVatAmount;
            pricingInfo.TotalNetPrice = totalNetPrice;
            pricingInfo.TotalPrice = totalPrice;
            pricingInfo.ProductDiscount =0;
            pricingInfo.TotalProductDiscount = 0;

            return pricingInfo;
        }