To create tax assets for your store using an XML file:
- Create an XML file that follows the wcs.dtd file. The DTD file is located in the following directory:
- WC_installdir/schema/xml
WCDE_installdir/schema/xml/
- Define the jurisdictions and jurisdiction groups to which you are shipping goods and services. Assign your tax jurisdictions to tax jurisdiction groups according to their applicable tax category calculation rules.
- Using the following example as your guide, define a jurisdiction group in your XML file in the JURSTGROUP table:
<jurstgroup jurstgroup_id="@jurstgroup_id_2" description="Tax Jurstiction Group 1" subclass="2" storeent_id="@storeent_id_1" code="World"/>
- Using the following example as your guide, define a jurisdiction in your XML file in the JURST table.
<jurst jurst_id="@jurst_id_2" storeent_id="@storeent_id_1" code="World" subclass="2"/>
- Using the following example as your guide, associate the jurisdiction you created in step b with the jurisdiction group you defined in step a, by adding information to the JURSTGPREL table.
<jurstgprel jurst_id="@jurst_id_2" jurstgroup_id="@jurstgroup_id_1" subclass="2"/>
- Repeat steps a through c for all jurisdictions and jurisdiction groups your store supports.
- Using the following example as your guide, define a jurisdiction group in your XML file in the JURSTGROUP table:
- Define the tax categories your store will use.
- Using the following example as your guide, define a tax category in your XML file for the TAXCGRY table:
<taxcgry taxcgry_id="@taxcgry_id_1" taxtype_id="-3" storeent_id="@storeent_id_1" name="Sales Tax" displayseq="0" displayusage="0"/>
- Repeat step a for each tax category used in your store.
- Using the following example as your guide, add the tax category description information in your XML file for the TAXCGRYDS table. If you are creating a multiregion or multicountry store, you should include this information in a locale-specific XML file.
<taxcgryds taxcgry_id="@taxcgry_id_1" description="Sales Tax" language_id="&en_US"/>
- Repeat step c for each tax category used in your store.
- Using the following example as your guide, define a tax category in your XML file for the TAXCGRY table:
- Define the calculation codes to be used by your store.
- Using the following examples as your guide, define the calculation code in your XML file for the CALCODE table.
<calcode calcode_id="@calcode_id_3" code="Tax Code 1" calusage_id="-3" storeent_id="@storeent_id_1" groupby="0" published="1" sequence="0" calmethod_id="-43" calmethod_id_app="-44" calmethod_id_qfy="-42" displaylevel="0" flags="0" precedence="0" />
- Using the following example as your guide, add the calculation code description information in your XML file for the CALCODEDSC table. If you are creating a multiregion or multicountry store, you should include this information in a locale-specific XML file.
<calcodedsc calcode_id="@calcode_id_3" description="Vitamins language_id="&en_US" longdescription= "In Ontario vitamins are taxed federally, but not provincially." />
- Repeat steps a and b for each calculation code used in your store.
- Using the following examples as your guide, define the calculation code in your XML file for the CALCODE table.
- Define the calculation rules for your store.
- Using the following example as your guide, set up the calculation rule in your XML file for the CALRULE table:
<calrule calrule_id="@calrule_id_10" calcode_id="@calcode_id_3" startdate="1900-01-01 00:00:00.000000" taxcgry_id="@taxcgry_id_1" enddate="2100-01-01 00:00:00.000000" flags="1" identifier="1" combination="2" calmethod_id="-47" calmethod_id_qfy="-46" />
- Repeat step a for each calculation rule used in your store. Note that each calculation code may have several calculation rules, one for each applicable tax category. For example, calcode_id="@calcode_id_1" may be associated with several calrule_ids.
- Using the following example as your guide, set up the calculation rule in your XML file for the CALRULE table:
- Define calculation scales for your store.
A calculation scale is the set of ranges that will apply to the calculation. These ranges create a scale.
- Using the following example as your guide, set up the calculation scale in your XML file for the CALSCALE table:
<calscale calscale_id="@calscale_id_19" code="Sales Tax 1" storeent_id="@storeent_id_1" calusage_id="-3" setccurr="USD" calmethod_id="-53" />
- Repeat step a for each calculation scale used in your store.
- Using the following example as your guide, add the calculation scale description information in your XML file for the CALSCALEDS table. If you are creating a multiregion or multicountry store, you should include this information in a locale-specific XML file.
<calscaleds calscale_id="@calscale_id_19" description="Sales Tax 5% " language_id="&en_US" />
- Repeat step c for each calculation scale used in your store.
- Using the following example as your guide, set up the calculation scale in your XML file for the CALSCALE table:
- Define calculation ranges for the calculation scales.
- Using the following example as your guide, set up the calculation range in your XML file for the CALRANGE table.
<calrange calrange_id="@calrange_id_37" calscale_id="@calscale_id_19" calmethod_id="-59" rangestart="0.00000" cumulative="0" />
- Repeat step a for each calculation range associated with the calculation scale used in your store. In the example above there is only one range, since all amounts are taxed at the same rate.
- Using the following example as your guide, set up the calculation range in your XML file for the CALRANGE table.
- Define the calculation lookup values for the calculation scales. The calculation lookup values are the values associated with the calculation scale. For example, a calculation scale includes the following ranges and associated tax rates for Ontario provincial sales tax on meals served in a restaurant:
- $0.00 - $3.99 taxed at the rate of 0.00%
- $4.00 and up taxed at the rate of 8.00%
The lookup values are 0.00 and 8.00.
- Using the following examples as your guide, set up the calculation lookup in your XML file for the CALRLOOKUP table.
<calrlookup calrlookup_id="@calrlookup_id_37" calrange_id="@calrange_id_37" value="5.00" />
- Repeat steps a and b for each lookup value associated with the calculation scale used in your store. In this example, there is only one CALRLOOKUP value, since CALRLOOKUP.SETCCURR is NULL, and there is only one CALRANGE, since the tax rate is the same for all amounts.
- Associate the calculation rule and calculation scale.
- Using the following examples as your guide, associate the calculate scale with the calculation rule in your XML file for the CRULESCALE table.
<crulescale calrule_id="@calrule_id_10" calscale_id="@calscale_id_19" />
- Repeat step a for each calculation scale and rule association. In example used above, there is only one calculation scale for each calculation rule.
Note: If the tax rate varies depending on the amount purchased, you will need to create scales with non-zero rangestart values. Then, you will need to create a calculation scale for each supported currency (setting CALSCALE.SETCCURR to the appropriate currency) for which you have not established a conversion rate (refer to the CURCONVERT table) and associate them all with the calculation rule for that particular tax category. For example, there is no Ontario provincial sales tax on meals under $4.00. If your store supported selling meals in US dollars, you would need to either establish a conversion from US dollars to Canadian dollars, or create a separate tax calculation scale with an appropriate rangestart value, perhaps $6.00 USD, and associate it with the same tax calculation rule. Only the appropriate calculation scale would be used, according to the currency of the order.
- Using the following examples as your guide, associate the calculate scale with the calculation rule in your XML file for the CRULESCALE table.