Exemple #1
0
            private static CalculateQuantityFromPriceServiceResponse CalculateQuantityFromPrice(CalculateQuantityFromPriceServiceRequest request)
            {
                decimal quantity = 0;

                if (request.BarcodePrice > 0)
                {
                    if (request.DefaultProductPrice != request.BarcodePrice && request.DefaultProductPrice != decimal.Zero)
                    {
                        quantity = request.BarcodePrice / request.DefaultProductPrice;

                        var roundingRequest = new GetRoundQuantityServiceRequest(quantity, request.UnitOfMeasure);
                        var response        = request.RequestContext.Execute <GetRoundQuantityServiceResponse>(roundingRequest);

                        quantity = response.RoundedValue;
                    }
                }

                return(new CalculateQuantityFromPriceServiceResponse(quantity));
            }
Exemple #2
0
            private static ProcessMaskSegmentsServiceResponse ProcessMaskSegments(ProcessMaskSegmentsServiceRequest serviceRequest)
            {
                GetBarcodeMaskSegmentDataRequest getBarcodeMaskSegmentDataRequest = new GetBarcodeMaskSegmentDataRequest(serviceRequest.BarcodeMask.MaskId, QueryResultSettings.AllRecords);
                IEnumerable <BarcodeMaskSegment> barCodeMaskSegments = serviceRequest.RequestContext.Runtime.Execute <EntityDataServiceResponse <BarcodeMaskSegment> >(getBarcodeMaskSegmentDataRequest, serviceRequest.RequestContext).PagedEntityCollection.Results;

                int position = serviceRequest.BarcodeMask.Prefix.Length;

                Barcode barcodeInfo = serviceRequest.Barcode;

                foreach (BarcodeMaskSegment segment in barCodeMaskSegments)
                {
                    var segmentType = (BarcodeSegmentType)segment.MaskType;

                    switch (segmentType)
                    {
                    case BarcodeSegmentType.Item:
                    {
                        LoadItemInfo(serviceRequest, barcodeInfo, position, segment);
                        break;
                    }

                    case BarcodeSegmentType.AnyNumber:
                    case BarcodeSegmentType.CheckDigit:     // Check Digit is not implemented yet functionality in RetailServer.
                    {
                        break;
                    }

                    case BarcodeSegmentType.Price:
                    {
                        LoadPriceInfo(serviceRequest, barcodeInfo, position, segment);

                        if (barcodeInfo.BarcodePrice != null && barcodeInfo.ItemBarcode.ItemId != null)
                        {
                            ProductPrice productPrice        = GetItemPrice(serviceRequest.RequestContext, barcodeInfo.ItemBarcode.ItemId, barcodeInfo.ItemBarcode.InventoryDimensionId, barcodeInfo.ItemBarcode.UnitId, string.Empty);
                            decimal      defaultProductPrice = productPrice.AdjustedPrice;

                            var calculateQuantityRequest = new CalculateQuantityFromPriceServiceRequest(barcodeInfo.BarcodePrice.Value, defaultProductPrice, barcodeInfo.ItemBarcode.UnitId);
                            CalculateQuantityFromPriceServiceResponse calculateQuantityResponse = serviceRequest.RequestContext.Execute <CalculateQuantityFromPriceServiceResponse>(calculateQuantityRequest);

                            barcodeInfo.BarcodeQuantity = calculateQuantityResponse.BarcodeQuantity;
                        }

                        break;
                    }

                    case BarcodeSegmentType.Quantity:
                    {
                        LoadQuantityInfo(serviceRequest, barcodeInfo, position, segment);
                        break;
                    }

                    case BarcodeSegmentType.DiscountCode:
                    {
                        barcodeInfo.DiscountCode = serviceRequest.Barcode.BarcodeId.Substring(position, segment.Length).TrimStart('0');
                        break;
                    }

                    case BarcodeSegmentType.GiftCard:
                    {
                        barcodeInfo.GiftCardNumber = serviceRequest.BarcodeMask.Prefix + serviceRequest.Barcode.BarcodeId.Substring(position, segment.Length);
                        break;
                    }

                    case BarcodeSegmentType.LoyaltyCard:
                    {
                        barcodeInfo.LoyaltyCardNumber = serviceRequest.BarcodeMask.Prefix + serviceRequest.Barcode.BarcodeId.Substring(position, segment.Length);
                        break;
                    }

                    case BarcodeSegmentType.SizeDigit:
                    case BarcodeSegmentType.ColorDigit:
                    case BarcodeSegmentType.StyleDigit:
                    {
                        // Not used.
                        break;
                    }

                    case BarcodeSegmentType.EANLicenseCode:
                    {
                        barcodeInfo.EANLicenseId = serviceRequest.Barcode.BarcodeId.Substring(position, segment.Length);
                        break;
                    }

                    case BarcodeSegmentType.Employee:
                    {
                        barcodeInfo.EmployeeId = serviceRequest.Barcode.BarcodeId.Substring(position, segment.Length);
                        break;
                    }

                    case BarcodeSegmentType.Salesperson:
                    {
                        barcodeInfo.SalespersonId = serviceRequest.Barcode.BarcodeId.Substring(position, segment.Length);
                        break;
                    }

                    case BarcodeSegmentType.Customer:
                    {
                        barcodeInfo.CustomerId = serviceRequest.Barcode.BarcodeId.Substring(position, segment.Length);
                        break;
                    }

                    case BarcodeSegmentType.DataEntry:
                    {
                        barcodeInfo.DataEntry = serviceRequest.Barcode.BarcodeId.Substring(position, segment.Length);
                        break;
                    }

                    default:
                    {
                        break;
                    }
                    }

                    position = position + segment.Length;
                }

                return(new ProcessMaskSegmentsServiceResponse(barcodeInfo));
            }