public Cart CreateCart(TaxMode taxMode = TaxMode.Platform, bool withCustomer = true, bool withDefaultShippingCountry = true, bool withItemShippingAddress = false) { CartDraft cartDraft = this.GetCartDraft(withCustomer, withDefaultShippingCountry, withItemShippingAddress); cartDraft.TaxMode = taxMode; return(this.CreateCart(cartDraft)); }
public static CartDraft DefaultCartDraftWithTaxMode(CartDraft draft, TaxMode taxMode) { var cartDraft = DefaultCartDraft(draft); cartDraft.TaxMode = taxMode; return(cartDraft); }
public Cart CreateCartWithCustomLineItemWithSpecificTaxMode(TaxMode taxMode, bool withCustomer = true, bool withDefaultShippingCountry = true, bool withItemShippingAddress = false) { var customLineItemDraft = this.GetCustomLineItemDraft(); CartDraft cartDraft = this.GetCartDraft(withCustomer, withDefaultShippingCountry, withItemShippingAddress); cartDraft.CustomLineItems = new List <CustomLineItemDraft> { customLineItemDraft }; cartDraft.TaxMode = taxMode; Cart cart = this.CreateCart(cartDraft); return(cart); }
public Cart CreateCartWithLineItem(TaxMode taxMode = TaxMode.Platform, bool withCustomer = true, bool withDefaultShippingCountry = true, bool withItemShippingAddress = false) { Product product = this.CreateProduct(); LineItemDraft lineItemDraft = this.GetLineItemDraftBySku(product.MasterData.Current.MasterVariant.Sku, quantity: 6); CartDraft cartDraft = this.GetCartDraft(withCustomer, withDefaultShippingCountry, withItemShippingAddress); cartDraft.LineItems = new List <LineItemDraft> { lineItemDraft }; cartDraft.TaxMode = taxMode; Cart cart = this.CreateCart(cartDraft); return(cart); }
public Cart CreateCartWithLineItem(TaxMode taxMode = TaxMode.Platform, bool withCustomer = true, bool withDefaultShippingCountry = true, bool withItemShippingAddress = false, bool withShippingMethod = false, string customerEmail = null) { CartDraft cartDraft = this.GetCartDraft(withCustomer, withDefaultShippingCountry, withItemShippingAddress, withShippingMethod, customerEmail); var taxCategoryReference = withShippingMethod ? this.shippingMethodsFixture.GetShippingMethodTaxCategoryByKey(cartDraft.ShippingMethod.Key) : null; Product product = this.CreateProduct(taxCategoryReference: taxCategoryReference); LineItemDraft lineItemDraft = this.GetLineItemDraftBySku(product.MasterData.Current.MasterVariant.Sku, quantity: 6); cartDraft.LineItems = new List <LineItemDraft> { lineItemDraft }; cartDraft.TaxMode = taxMode; Cart cart = this.CreateCart(cartDraft); return(cart); }
private static Dictionary <string, decimal> CalculateTaxes(TaxMode taxMode, decimal total, List <string> appliedTaxes) { var result = new Dictionary <string, decimal>(); if (appliedTaxes != null && appliedTaxes.Count > 0) { decimal taxAmount = total; foreach (var taxCode in appliedTaxes) { if (taxMode == TaxMode.ForEach) { if (!taxCode.Equals(Purchase.VAT_NA) && !taxCode.Equals(Purchase.VAT_0)) { if (!TAX_RATES.ContainsKey(taxCode)) { throw new ArgumentException("invalid tax code :" + taxCode); } decimal taxRate = TAX_RATES[taxCode]; taxRate = RoundClassic(taxRate, S_DECIMALS); taxAmount = taxAmount - RoundClassic(total / (1 + taxRate), S_DECIMALS); } } result.Add(taxCode, result.ContainsKey(taxCode) ? (result[taxCode] + taxAmount) : taxAmount); } } else { result.Add(Purchase.VAT_NA, result.ContainsKey(Purchase.VAT_NA) ? (result[Purchase.VAT_NA] + total) : total); } if (result.Count == 0) { throw new ArgumentException("failed to calculate taxes"); } return(result); }
/// <summary> /// Constructor. /// </summary> /// <param name="taxMode">TaxMode</param> public ChangeTaxModeAction(TaxMode taxMode) { this.Action = "changeTaxMode"; this.TaxMode = taxMode; }