/// <summary>You can use the <postal-area> tag to identify any country /// in the world, including the United States. You can also specify /// regions by postal codes. /// </summary> /// <param name="countryCode">This tag contains the two-letter /// <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1</a> /// country code for the postal area.</param> /// <param name="postalCodePattern">This tag identifies a postal code or /// a range of postal codes for the postal area. To specify a range of /// postal codes, use an asterisk as a wildcard operator in the tag's value. /// For example, you can specify that a shipping option is available for all /// postal codes beginning with "SW" by entering SW* as the /// <postal-code-pattern> value.</param> public void AddAllowedPostalArea(string countryCode, string postalCodePattern) { AutoGen.PostalArea area = new AutoGen.PostalArea(); area.countrycode = countryCode; if (postalCodePattern != null && postalCodePattern.Length > 0) { area.postalcodepattern = postalCodePattern; } AddNewAllowedArea(area); }
/// <summary> /// Adds the country tax rule. /// This method adds a tax rule associated with a particular state. /// </summary> /// <param name="countryCode">Required. This tag contains the /// two-letter /// <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1</a> /// country code for the postal area.</param> /// <param name="postalCodePattern">Optional. This tag identifies a postal /// code or a range of postal codes for the postal area. To specify a /// range of postal codes, use an asterisk as a wildcard operator in the /// tag's value. For example, you can specify that a shipping option is /// available for all postal codes beginning with "SW" by entering SW* /// as the <postal-code-pattern> value.</param> /// <param name="TaxRate">The tax rate associated with a tax rule. Tax /// rates are expressed as decimal values. For example, a value of 0.0825 /// specifies a tax rate of 8.25%.</param> public void AddPostalAreaTaxRule(string countryCode, string postalCodePattern, double TaxRate) { if (string.IsNullOrEmpty(countryCode)) { throw new ArgumentException("countryCode", "CountryCode is required."); } countryCode = countryCode.ToUpper(); if (postalCodePattern == string.Empty) { postalCodePattern = null; } //verify we don't have a duplicate foreach (AutoGen.AlternateTaxRule tr in _taxRules) { AutoGen.PostalArea pa = tr.taxarea.Item as AutoGen.PostalArea; if (pa != null) { if (pa.countrycode == countryCode) { if (pa.postalcodepattern == postalCodePattern) { throw new ApplicationException("Duplicate Postal Pattern"); } } } } AutoGen.AlternateTaxRule rule = new AutoGen.AlternateTaxRule(); rule.rateSpecified = true; rule.rate = TaxRate; rule.taxarea = new AutoGen.AlternateTaxRuleTaxarea(); AutoGen.PostalArea ThisArea = new AutoGen.PostalArea(); rule.taxarea.Item = ThisArea; ThisArea.countrycode = countryCode; if (postalCodePattern != null && postalCodePattern != string.Empty) { ThisArea.postalcodepattern = postalCodePattern; } _taxRules.Add(rule); }
/// <summary> /// Adds the country tax rule. /// This method adds a tax rule associated with a particular state. /// </summary> /// <param name="countryCode">Required. This tag contains the /// two-letter /// <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1</a> /// country code for the postal area.</param> /// <param name="postalCodePattern">Optional. This tag identifies a postal /// code or a range of postal codes for the postal area. To specify a /// range of postal codes, use an asterisk as a wildcard operator in the /// tag's value. For example, you can specify that a shipping option is /// available for all postal codes beginning with "SW" by entering SW* /// as the <postal-code-pattern> value.</param> /// <param name="TaxRate">The tax rate associated with a tax rule. Tax /// rates are expressed as decimal values. For example, a value of 0.0825 /// specifies a tax rate of 8.25%.</param> /// <param name="ShippingTaxed"> /// If this parameter has a value of <b>true</b>, then shipping costs will /// be taxed for items that use the associated tax rule. /// </param> public void AddPostalAreaTaxRule(string countryCode, string postalCodePattern, double TaxRate, bool ShippingTaxed) { AutoGen.DefaultTaxRule Rule = new AutoGen.DefaultTaxRule(); Rule.rateSpecified = true; Rule.rate = TaxRate; Rule.shippingtaxedSpecified = true; Rule.shippingtaxed = ShippingTaxed; Rule.taxarea = new AutoGen.DefaultTaxRuleTaxarea(); AutoGen.PostalArea ThisArea = new AutoGen.PostalArea(); Rule.taxarea.Item = ThisArea; ThisArea.countrycode = countryCode; if (postalCodePattern != null && postalCodePattern != string.Empty) { ThisArea.postalcodepattern = postalCodePattern; } AddNewTaxRule(Rule); }
/// <summary> /// Adds the country tax rule. /// This method adds a tax rule associated with a particular state. /// </summary> /// <param name="countryCode">Required. This tag contains the /// two-letter /// <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1</a> /// country code for the postal area.</param> /// <param name="postalCodePattern">Optional. This tag identifies a postal /// code or a range of postal codes for the postal area. To specify a /// range of postal codes, use an asterisk as a wildcard operator in the /// tag's value. For example, you can specify that a shipping option is /// available for all postal codes beginning with "SW" by entering SW* /// as the <postal-code-pattern> value.</param> /// <param name="TaxRate">The tax rate associated with a tax rule. Tax /// rates are expressed as decimal values. For example, a value of 0.0825 /// specifies a tax rate of 8.25%.</param> public void AddPostalAreaTaxRule(string countryCode, string postalCodePattern, double TaxRate) { if (string.IsNullOrEmpty(countryCode)) throw new ArgumentException("countryCode", "CountryCode is required."); countryCode = countryCode.ToUpper(); if (postalCodePattern == string.Empty) postalCodePattern = null; //verify we don't have a duplicate foreach (AutoGen.AlternateTaxRule tr in _taxRules) { AutoGen.PostalArea pa = tr.taxarea.Item as AutoGen.PostalArea; if (pa != null) { if (pa.countrycode == countryCode) { if (pa.postalcodepattern == postalCodePattern) { throw new ApplicationException("Duplicate Postal Pattern"); } } } } AutoGen.AlternateTaxRule rule = new AutoGen.AlternateTaxRule(); rule.rateSpecified = true; rule.rate = TaxRate; rule.taxarea = new AutoGen.AlternateTaxRuleTaxarea(); AutoGen.PostalArea ThisArea = new AutoGen.PostalArea(); rule.taxarea.Item = ThisArea; ThisArea.countrycode = countryCode; if (postalCodePattern != null && postalCodePattern != string.Empty) { ThisArea.postalcodepattern = postalCodePattern; } _taxRules.Add(rule); }