private void AddLineItem(PackagingSummary item)
        {
            LineItemPricingInfo pricingInfo;
            DiscountType discountType = 0;
            OrderLineItemType orderLineItemType = 0;
            decimal unitPrice;
            decimal vatValue;
            decimal totalNet;
            decimal totalVatAmount;
            decimal totalPrice;
            decimal productDiscount;
            decimal totalProductDiscount;
                pricingInfo = GetLineItemPricing(item, SelectedOutlet.Id);
                unitPrice = pricingInfo.UnitPrice;
                vatValue = pricingInfo.VatValue;
                totalNet = pricingInfo.TotalNetPrice;
                totalVatAmount = pricingInfo.TotalVatAmount;
                totalPrice = pricingInfo.TotalPrice;
                productDiscount = pricingInfo.ProductDiscount;
                totalProductDiscount = pricingInfo.TotalProductDiscount;

            using (StructureMap.IContainer cont = NestedContainer)
            {
                if (Using<IDiscountProWorkflow>(cont).IsProductFreeOfCharge(item.Product.Id))
                {
                    unitPrice = 0m;
                    vatValue = 0m;
                    totalNet = 0m;
                    totalVatAmount = 0m;
                    totalPrice = 0m;
                    totalProductDiscount = 0m;
                    discountType = DiscountType.FreeOfChargeDiscount;
                    orderLineItemType = OrderLineItemType.Discount;
                }
            }


            if (ReceiveReturnable)
                pricingInfo.UnitPrice = -pricingInfo.UnitPrice;

            AddLineItem(item.Product.Id, item.Product.Description, unitPrice, vatValue, totalVatAmount,
                        item.Quantity, totalPrice, false, IsEditable, Guid.Empty, item.Product.Id, orderLineItemType,
                        discountType, productDiscount, item.Product.GetType().ToString().Split('.').Last());

            List<OrderLineItemBase> lineItems = LineItems.Select(n => n as OrderLineItemBase).ToList();
            LineItems.Clear();
            _productPackagingSummaryService.OrderLineItems(lineItems)
                                           .Select(n => n as EditPOSSaleLineItem)
                                           .ToList()
                                           .ForEach(LineItems.Add);
        }
        public void ReceiveReturnableLineItem(List<ProductAddSummary> productsummariies, bool IsNew)
        {
            using (StructureMap.IContainer cont = NestedContainer)
            {
                var receivables = GetReturnableIn();
                foreach (ProductAddSummary product in productsummariies)
                {
                    if (!receivables.Any(n => n.Key == product.ProductId))
                        continue;
                    var receivableItem = receivables.FirstOrDefault(n => n.Key == product.ProductId);

                    var receivableQty = receivableItem.Value;

                    if (receivableItem.Value >= product.Quantity)
                        receivableQty = product.Quantity;

                    if (receivableItem.Value < product.Quantity)
                        receivableQty = receivableItem.Value;

                    if (receivableQty == 0)
                        return;

                    PackagingSummary ps = new PackagingSummary
                                              {
                                                  Product = Using<IProductRepository>(cont).GetById(product.ProductId),
                                                  Quantity = receivableQty,
                                              };
                    if (IsNew)
                        AddLineItem(ps);
                    else
                        UpdateReturnableLineItem(ps);
                }

                RefreshList();
            }
        }
        private void AddOrUpdateLineItem(PackagingSummary packagingSummary)
        {
            using (var container = NestedContainer)
            {
                IDiscountProWorkflow _discountProService = Using<IDiscountProWorkflow>(container);

                LineItemPricingInfo pricingInfo = _discountProService.GetLineItemPricing(packagingSummary, OutletId);

                //if item in LineItems update it else insert
                ApproveSalesmanOrderItem li =
                    LineItems.FirstOrDefault(
                        n =>
                        n.ProductId == packagingSummary.Product.Id && n.OrderLineItemType != OrderLineItemType.Discount);

                if (li != null)
                {
                    UpdateLineItem(li.SequenceNo, packagingSummary.Quantity, pricingInfo.TotalVatAmount,
                                   pricingInfo.TotalPrice, pricingInfo.ProductDiscount, pricingInfo.TotalProductDiscount);
                }
                else
                {
                    AddLineItem(packagingSummary.Product.Id, packagingSummary.Product.Description, pricingInfo.UnitPrice,
                                pricingInfo.VatValue, pricingInfo.TotalVatAmount,
                                packagingSummary.Quantity, pricingInfo.TotalPrice, IsEditable,
                                packagingSummary.Product.GetType().ToString().Split('.').Last(),
                                Guid.Empty, pricingInfo.ProductDiscount, 0, 0);
                }
            }
        }
        public void UpdateReturnableLineItem(PackagingSummary item)
        {
            using (StructureMap.IContainer cont = NestedContainer)
            {
                LineItemPricingInfo pi = GetLineItemPricing(item, SelectedOutlet.Id);
                decimal totalVatAmount = pi.TotalVatAmount;
                decimal totalPrice = pi.TotalPrice;
                decimal totalProductDiscount = pi.TotalProductDiscount;

                EditPOSSaleLineItem li = LineItems.First(n => n.ProductId == item.Product.Id && n.TotalPrice < 0);
                li.Qty = item.Quantity;
                li.VatAmount = -totalVatAmount;
                li.TotalPrice = -totalPrice;
                li.ProductDiscount = -totalProductDiscount;
                CalcTotals();
                //AddOrderLineItem(li);
            }
        }
예제 #5
0
        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;
            }

        }