Exemple #1
0
        protected virtual AllowanceCharge GetAllowanceCharge(decimal amount, string discountCode, string currencyCode, bool shippingIndicator = false)
        {
            var allowance = OrderFactory.CreateAllowanceCharge();

            allowance.ChargeIndicator   = false;
            allowance.ShippingIndicator = shippingIndicator;
            allowance.SequenceNumeric   = 1M;
            allowance.BaseAmount        = OrderFactory.CreateAmount(0M, currencyCode);
            allowance.Amount            = OrderFactory.CreateAmount(amount, currencyCode);
            allowance.ID = discountCode;
            allowance.AllowanceChargeReasonCode = discountCode;
            allowance.AllowanceChargeReason     = discountCode;
            return(allowance);
        }
Exemple #2
0
        protected virtual ICollection <Sitecore.Ecommerce.OrderManagement.Orders.AllowanceCharge> GetAllowanceCharge(ActiveCommerce.Orders.Legacy.Order source)
        {
            Assert.ArgumentNotNull(source, "source");
            Assert.IsNotNull(source.Currency, "currency");

            // From SES Documentation: http://sdn.sitecore.net/upload/sdn5/products/sefe/ses22/order_manager_cookbook_22-usletter.pdf
            // Discounts:
            //   Details of any discounts or offers that the customer is entitled to.
            //   For each discount you must enter an adjustment reason description code and description in the reason code and description fields.
            //   You can find these codes and descriptions on the UN/EDIFACT website. http://www.unece.org/trade/untdid/d03a/tred/tred4465.htm
            // Charges:
            //   Details of any additional charges incurred by the customer.
            //   For each charge you must enter an adjustment reason description code and description in the reason code
            //   and description fields. You can find these codes and descriptions on the UN/EDIFACT website.
            //   UN/EDIFACT does not have a predefined code for freight, so instead SES automatically allocates
            //   the ZZZ Mutually defined code to customer orders that include freight (shipping).

            var allowances = new List <Sitecore.Ecommerce.OrderManagement.Orders.AllowanceCharge>();
            var totals     = source.Totals as ActiveCommerce.Prices.OrderTotals;

            var discounts = string.Join(", ", source.Discounts);

            // Discounts
            if (totals.SubtotalDiscount > 0)
            {
                allowances.Add(GetAllowanceCharge(totals.SubtotalDiscount, discounts, source.Currency.Code));
            }
            if (totals.ShippingDiscount > 0)
            {
                allowances.Add(GetAllowanceCharge(totals.ShippingDiscount, discounts, source.Currency.Code, true));
            }

            // Charges
            var shipping = OrderFactory.CreateAllowanceCharge();

            shipping.ChargeIndicator           = true;
            shipping.ShippingIndicator         = true;
            shipping.SequenceNumeric           = 1M;
            shipping.BaseAmount                = OrderFactory.CreateAmount(0M, source.Currency.Code);
            shipping.Amount                    = OrderFactory.CreateAmount(source.ShippingPrice, source.Currency.Code);
            shipping.AllowanceChargeReasonCode = "ZZZ";
            shipping.AllowanceChargeReason     = "Shipping";

            allowances.Add(shipping);

            return(allowances);
        }