예제 #1
0
 /// <summary>
 /// This method adds a tax rule associated with a particular state.
 /// </summary>
 /// <param name="StateCode">This parameter contains a two-letter U.S. state
 /// code associated with a tax rule.</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 AddStateTaxRule(string StateCode, double TaxRate)
 {
     AutoGen.AlternateTaxRule rule = new AutoGen.AlternateTaxRule();
     rule.rateSpecified = true;
     rule.rate          = TaxRate;
     rule.taxarea       = new AutoGen.AlternateTaxRuleTaxarea();
     AutoGen.USStateArea Area = new AutoGen.USStateArea();
     rule.taxarea.Item = Area;
     Area.state        = StateCode;
     _taxRules.Add(rule);
 }
예제 #2
0
 /// <summary>
 /// Adds the country tax rule.
 /// This method adds a tax rule associated with a particular state.
 /// </summary>
 /// <param name="Area">The area.</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>
 /// <example>
 /// <code>
 ///   // We assume Req is a CheckoutShoppingCartRequest object.
 ///   // Charge the 50 states 8% tax.
 ///   Req.AddCountryTaxRule(AutoGen.USAreas.FULL_50_STATES, 0.08);
 ///   // Charge the 48 continental states 5% tax.
 ///   Req.AddCountryTaxRule(AutoGen.USAreas.CONTINENTAL_48, 0.05);
 ///   // Charge all states (incl territories) 9% tax.
 ///   Req.AddCountryTaxRule(AutoGen.USAreas.ALL, 0.09);
 /// </code>
 /// </example>
 public void AddCountryTaxRule(AutoGen.USAreas Area, double TaxRate)
 {
     AutoGen.AlternateTaxRule rule = new AutoGen.AlternateTaxRule();
     rule.rateSpecified = true;
     rule.rate          = TaxRate;
     rule.taxarea       = new AutoGen.AlternateTaxRuleTaxarea();
     AutoGen.USCountryArea ThisArea = new AutoGen.USCountryArea();
     rule.taxarea.Item    = ThisArea;
     ThisArea.countryarea = Area;
     _taxRules.Add(rule);
 }
예제 #3
0
 /// <summary>
 /// This method adds a tax rule associated with a zip code pattern.
 /// </summary>
 /// <param name="ZipPattern">The zip pattern.</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 AddZipTaxRule(string ZipPattern, double TaxRate)
 {
     if (!CheckoutShoppingCartRequest.IsValidZipPattern(ZipPattern))
     {
         throw new ApplicationException(
                   CheckoutShoppingCartRequest.ZIP_CODE_PATTERN_EXCEPTION
                   );
     }
     AutoGen.AlternateTaxRule rule = new AutoGen.AlternateTaxRule();
     rule.rateSpecified = true;
     rule.rate          = TaxRate;
     rule.taxarea       = new AutoGen.AlternateTaxRuleTaxarea();
     AutoGen.USZipArea Area = new AutoGen.USZipArea();
     rule.taxarea.Item = Area;
     Area.zippattern   = ZipPattern;
     _taxRules.Add(rule);
 }
예제 #4
0
        /// <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 &lt;postal-code-pattern&gt; 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);
        }
예제 #5
0
        /// <summary>
        /// Adds the world tax rule.
        /// This method adds a tax rule associated with a particular state.
        /// </summary>
        /// <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 AddWorldAreaTaxRule(double TaxRate)
        {
            foreach (AutoGen.AlternateTaxRule tr in _taxRules)
            {
                if (tr.taxarea.Item.GetType() == typeof(AutoGen.WorldArea))
                {
                    throw new ApplicationException(
                              "Only one world tax area may exist.");
                }
            }

            AutoGen.AlternateTaxRule rule = new AutoGen.AlternateTaxRule();
            rule.rateSpecified = true;
            rule.rate          = TaxRate;
            rule.taxarea       = new AutoGen.AlternateTaxRuleTaxarea();
            AutoGen.WorldArea ThisArea = new AutoGen.WorldArea();
            rule.taxarea.Item = ThisArea;
            _taxRules.Add(rule);
        }
 /// <summary>
 /// This method adds a tax rule associated with a zip code pattern.
 /// </summary>
 /// <param name="ZipPattern">The zip pattern.</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 AddZipTaxRule(string ZipPattern, double TaxRate)
 {
     if (!CheckoutShoppingCartRequest.IsValidZipPattern(ZipPattern)) {
     throw new ApplicationException(
       CheckoutShoppingCartRequest.ZIP_CODE_PATTERN_EXCEPTION
       );
       }
       AutoGen.AlternateTaxRule rule = new AutoGen.AlternateTaxRule();
       rule.rateSpecified = true;
       rule.rate = TaxRate;
       rule.taxarea = new AutoGen.AlternateTaxRuleTaxarea();
       AutoGen.USZipArea Area = new AutoGen.USZipArea();
       rule.taxarea.Item = Area;
       Area.zippattern = ZipPattern;
       _taxRules.Add(rule);
 }
        /// <summary>
        /// Adds the world tax rule.
        /// This method adds a tax rule associated with a particular state.
        /// </summary>
        /// <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 AddWorldAreaTaxRule(double TaxRate)
        {
            foreach (AutoGen.AlternateTaxRule tr in _taxRules) {
            if (tr.taxarea.Item.GetType() == typeof(AutoGen.WorldArea)) {
              throw new ApplicationException(
            "Only one world tax area may exist.");
            }
              }

              AutoGen.AlternateTaxRule rule = new AutoGen.AlternateTaxRule();
              rule.rateSpecified = true;
              rule.rate = TaxRate;
              rule.taxarea = new AutoGen.AlternateTaxRuleTaxarea();
              AutoGen.WorldArea ThisArea = new AutoGen.WorldArea();
              rule.taxarea.Item = ThisArea;
              _taxRules.Add(rule);
        }
 /// <summary>
 /// This method adds a tax rule associated with a particular state.
 /// </summary>
 /// <param name="StateCode">This parameter contains a two-letter U.S. state 
 /// code associated with a tax rule.</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 AddStateTaxRule(string StateCode, double TaxRate)
 {
     AutoGen.AlternateTaxRule rule = new AutoGen.AlternateTaxRule();
       rule.rateSpecified = true;
       rule.rate = TaxRate;
       rule.taxarea = new AutoGen.AlternateTaxRuleTaxarea();
       AutoGen.USStateArea Area = new AutoGen.USStateArea();
       rule.taxarea.Item = Area;
       Area.state = StateCode;
       _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 &lt;postal-code-pattern&gt; 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="Area">The area.</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>
 /// <example>
 /// <code>
 ///   // We assume Req is a CheckoutShoppingCartRequest object.
 ///   // Charge the 50 states 8% tax.
 ///   Req.AddCountryTaxRule(AutoGen.USAreas.FULL_50_STATES, 0.08);
 ///   // Charge the 48 continental states 5% tax.
 ///   Req.AddCountryTaxRule(AutoGen.USAreas.CONTINENTAL_48, 0.05);
 ///   // Charge all states (incl territories) 9% tax.
 ///   Req.AddCountryTaxRule(AutoGen.USAreas.ALL, 0.09);
 /// </code>
 /// </example>
 public void AddCountryTaxRule(AutoGen.USAreas Area, double TaxRate)
 {
     AutoGen.AlternateTaxRule rule = new AutoGen.AlternateTaxRule();
       rule.rateSpecified = true;
       rule.rate = TaxRate;
       rule.taxarea = new AutoGen.AlternateTaxRuleTaxarea();
       AutoGen.USCountryArea ThisArea = new AutoGen.USCountryArea();
       rule.taxarea.Item = ThisArea;
       ThisArea.countryarea = Area;
       _taxRules.Add(rule);
 }