Пример #1
0
            /// <summary>
            /// Calculates price and discount independently for each item.
            /// </summary>
            /// <param name="request">The pricing request.</param>
            /// <returns>The response object.</returns>
            private static GetPriceServiceResponse CalculateIndependentPriceAndDiscount(GetIndependentPriceDiscountServiceRequest request)
            {
                PricingDataServiceManager pricingDataManager = new PricingDataServiceManager(request.RequestContext);
                DateTimeOffset            today = request.RequestContext.GetNowInChannelTimeZone();
                Customer customer = Discount.GetCustomer(request.RequestContext, request.Transaction.CustomerId);

                PE.PriceContext priceContext = PE.PriceContextHelper.CreatePriceContext(
                    request.RequestContext,
                    pricingDataManager,
                    request.Transaction,
                    new ChannelCurrencyOperations(request.RequestContext),
                    today,
                    request.Transaction.CustomerId,
                    customer != null ? customer.PriceGroup : string.Empty,
                    customer != null ? customer.LineDiscountGroup : string.Empty,
                    customer != null ? customer.MultilineDiscountGroup : string.Empty,
                    customer != null ? customer.TotalDiscountGroup : string.Empty,
                    request.Transaction.IsTaxIncludedInPrice,
                    PricingCalculationMode.Independent,
                    DiscountCalculationMode.CalculateOffer,
                    request.CalculateForNewSalesLinesOnly,
                    request.NewSalesLineIdSet);

                PE.PricingEngine.CalculatePricesForSalesLines(request.Transaction.PriceCalculableSalesLines, priceContext, pricingDataManager);

                PE.PricingEngine.CalculateDiscountsForLines(pricingDataManager, request.Transaction, true, priceContext);

                return(new GetPriceServiceResponse(request.Transaction));
            }
Пример #2
0
            /// <summary>
            /// Get independent prices.
            /// </summary>
            /// <param name="context">The context.</param>
            /// <param name="transaction">The transaction.</param>
            public void GetIndependentPrices(RequestContext context, SalesTransaction transaction)
            {
                PricingDataServiceManager pricingDataManager = new PricingDataServiceManager(context);
                DateTimeOffset            today = context.GetNowInChannelTimeZone();
                string customerPriceGroup       = GetCustomerPriceGroup(context, transaction.CustomerId);

                PE.PriceContext priceContext = PE.PriceContextHelper.CreatePriceContext(context, pricingDataManager, transaction, this.priceParameters, new ChannelCurrencyOperations(context), today, transaction.CustomerId, customerPriceGroup, transaction.IsTaxIncludedInPrice, PricingCalculationMode.Independent, DiscountCalculationMode.None);
                PE.PricingEngine.CalculatePricesForSalesLines(transaction.PriceCalculableSalesLines, priceContext, pricingDataManager);
            }
Пример #3
0
            /// <summary>
            /// Puts prices on the given sales lines according to the PriceContext.
            /// </summary>
            /// <param name="pricingRequest">The request context.</param>
            /// <returns>Response containing updated lines and original context.</returns>
            public static GetPricesServiceResponse GetLinePrices(GetPricesServiceRequest pricingRequest)
            {
                PE.IPricingDataAccessor pricingDataManager = new PricingDataServiceManager(pricingRequest.RequestContext);

                PE.PriceContext priceContext = PE.PriceContextHelper.CreatePriceContext(
                    pricingRequest.RequestContext,
                    pricingDataManager,
                    new ChannelCurrencyOperations(pricingRequest.RequestContext),
                    PE.PriceContextHelper.GetItemIds(pricingRequest.SalesLines),
                    PE.PriceContextHelper.GetCatalogIds(pricingRequest.SalesLines),
                    pricingRequest.AffiliationLoyaltyTiers,
                    pricingRequest.ActiveDate,
                    pricingRequest.CustomerAccount,
                    pricingRequest.CustomerPriceGroup,
                    pricingRequest.PriceCalculationMode,
                    DiscountCalculationMode.None);

                PE.PricingEngine.CalculatePricesForSalesLines(pricingRequest.SalesLines, priceContext, pricingDataManager);

                return(new GetPricesServiceResponse(pricingRequest.SalesLines.AsPagedResult(), priceContext.CurrencyCode));
            }