Develop > Persistence layer > Data assets > Create tax assets
Create tax assets using an XML file
To create tax assets for the store using an XML file:
Procedure
- Create an XML file that follows the wcs.dtd file. The DTD file is located...
- WC_INSTALL/schema/xml
- workspace_dir/wc/xml/sar/
- Define the jurisdictions and jurisdiction groups to which you are shipping goods and services. Assign the tax jurisdictions to tax jurisdiction groups according to their applicable tax category calculation rules.
- Use the following example as the guide, define a jurisdiction group in the XML file in the JURSTGROUP table:
<jurstgroup jurstgroup_id="@jurstgroup_id_2" description="Tax Jurisdiction Group 1" subclass="2" storeent_id="@storeent_id_1" code="World"/>
- Use the following example as the guide, define a jurisdiction in the XML file in the JURST table.
<jurst jurst_id="@jurst_id_2" storeent_id="@storeent_id_1" code="World" subclass="2"/>
- Use the following example as the 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 the store supports.
- Define the tax categories the store will use.
- Use the following example as the guide, define a tax category in the 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 the store.
- Use the following example as the guide, add the tax category description information in the 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 the store.
- Define the calculation codes to be used by the store.
- Use the following examples as the guide, define the calculation code in the 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" />
- Use the following example as the guide, add the calculation code description information in the 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 the store.
- Define the calculation rules for the store.
- Use the following example as the guide, set up the calculation rule in the 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.
- Define calculation scales for the store.
A calculation scale is the set of ranges that will apply to the calculation. These ranges create a scale.
- Use the following example as the guide, set up the calculation scale in the 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.
- Use the following example as the guide, add the calculation scale description information in the 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.
- Define calculation ranges for the calculation scales.
- Use the following example as the guide, set up the calculation range in the 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 the store. In the example above there is only one range, since all amounts are taxed at the same rate.
- 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.
- Use the following examples as the guide, set up the calculation lookup in the 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 the 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.
- Use the following examples as the guide, associate the calculate scale with the calculation rule in the 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.
If the tax rate varies depending on the amount purchased, we will need to create scales with non-zero rangestart values. Then, we 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.
Related concepts
Related tasks
Related reference
Database asset groups dependencies