protected virtual OrderLine GetOrderLine(ActiveCommerce.Orders.Legacy.OrderLine cartLine, string currencyCode, string discountCode) { Assert.ArgumentNotNull(cartLine, "cartLine"); Assert.ArgumentNotNullOrEmpty(currencyCode, "currencyCode"); var orderLine = OrderFactory.CreateOrderLine(); var lineItem = OrderFactory.CreateLineItem(); var item = OrderFactory.CreateItem(); item.Code = cartLine.Product.Code; item.Sku = cartLine.Product.SKU; item.Name = cartLine.Product.Title; item.AdditionalInformation = cartLine.Details; item.Type = cartLine.Type; lineItem.Item = item; lineItem.Price = OrderFactory.CreatePrice(OrderFactory.CreateAmount(cartLine.Totals.PriceExVat, currencyCode), cartLine.Quantity); lineItem.TotalTaxAmount = OrderFactory.CreateAmount(cartLine.Totals.TotalVat, currencyCode); lineItem.LineExtensionAmount = OrderFactory.CreateAmount(cartLine.Totals.TotalPriceExVat, currencyCode); lineItem.Quantity = cartLine.Quantity; orderLine.LineItem = lineItem; if (cartLine.Totals.DiscountIncVat > 0) { orderLine.AllowanceCharge.Add(GetAllowanceCharge(cartLine.Totals.DiscountExVat, discountCode, currencyCode)); } return(orderLine); }
protected virtual TaxSubTotal GetTaxSubTotal(TaxLine taxLine, TaxJurisdiction taxJurisdiction, string currencyCode) { Assert.ArgumentNotNull(taxLine, "taxLine"); Assert.ArgumentNotNull(taxJurisdiction, "taxJurisdiction"); Assert.ArgumentNotNullOrEmpty(currencyCode, "currencyCode"); var total = OrderFactory.CreateTaxSubTotal(); total.TaxableAmount = OrderFactory.CreateAmount(taxLine.TaxedAmount, currencyCode); total.TaxAmount = OrderFactory.CreateAmount(taxJurisdiction.Tax, currencyCode); total.TransactionCurrencyTaxAmount = OrderFactory.CreateAmount(taxJurisdiction.Tax, currencyCode); var category = OrderFactory.CreateTaxCategory(); category.ID = taxLine.ProductCode; // This will be either the actual product code for product tax, "SHIPPING" for shipping tax, or "HANDLING" for handling tax category.Name = taxLine.Type; // This will be populated for VAT, blank for North America tax category.Percent = taxJurisdiction.Rate * 100; category.BaseUnitMeasure = OrderFactory.CreateMeasure(); category.PerUnitAmount = OrderFactory.CreateAmount(0M, currencyCode); var scheme = OrderFactory.CreateTaxScheme(); scheme.CurrencyCode = currencyCode; scheme.ID = taxJurisdiction.Name; scheme.Name = taxJurisdiction.Name; scheme.TaxTypeCode = taxJurisdiction.Type; category.TaxScheme = scheme; total.TaxCategory = category; return(total); }
protected virtual TaxTotal GetTaxTotal(ActiveCommerce.Orders.Legacy.Order source) { Assert.ArgumentNotNull(source, "source"); var taxTotal = OrderFactory.CreateTaxTotal(); var totals = source.Totals as ActiveCommerce.Prices.OrderTotals; Assert.IsNotNull(totals, "ShoppingCart.Totals is not correct type (ActiveCommerce.Prices.OrderTotals). Cannot get tax totals."); taxTotal.RoundingAmount = OrderFactory.CreateAmount(0M, source.Currency.Code); taxTotal.TaxAmount = OrderFactory.CreateAmount(totals.TaxTotals.Tax, source.Currency.Code); uint sequence = 0; foreach (var lineItem in totals.TaxTotals.LineItems) { foreach (var taxJurisdiction in lineItem.Jurisdictions) { var total = GetTaxSubTotal(lineItem, taxJurisdiction, source.Currency.Code); total.CalculationSequenceNumeric = sequence; taxTotal.TaxSubtotal.Add(total); sequence++; } } return(taxTotal); }
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); }
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); }
protected virtual MonetaryTotal GetAnticipatedMonetaryTotal(ActiveCommerce.Orders.Legacy.Order source) { Assert.ArgumentNotNull(source, "source"); Assert.IsNotNull(source.Currency, "currency"); var monetaryTotal = OrderFactory.CreateMonetaryTotal(); var totals = source.Totals; monetaryTotal.AllowanceTotalAmount = OrderFactory.CreateAmount(totals.DiscountExVat, source.Currency.Code); monetaryTotal.ChargeTotalAmount = OrderFactory.CreateAmount(source.ShippingPrice, source.Currency.Code); monetaryTotal.LineExtensionAmount = OrderFactory.CreateAmount(totals.PriceExVat, source.Currency.Code); monetaryTotal.PayableAmount = OrderFactory.CreateAmount(totals.TotalPriceIncVat, source.Currency.Code); monetaryTotal.PayableRoundingAmount = OrderFactory.CreateAmount(0M, source.Currency.Code); monetaryTotal.PrepaidAmount = OrderFactory.CreateAmount(0M, source.Currency.Code); monetaryTotal.TaxExclusiveAmount = OrderFactory.CreateAmount(totals.TotalVat, source.Currency.Code); monetaryTotal.TaxInclusiveAmount = OrderFactory.CreateAmount(totals.PriceExVat + totals.TotalVat, source.Currency.Code); return(monetaryTotal); }