Canadian tax configuration
This sample demonstrates how to load the Canadian taxes into a WebSphere Commerce database and test the taxes in the store using a modified JSP page. This is a sample scenario you can follow the instructions and modify the rates to match the current tax rates and settings. For more information about changing the tax rates, see Update the WebSphere Commerce tax configuration to match the current tax rate.
- Publish the consumer direct sample store.
- Download the zip file containing all the code related to this article and extract it to a temporary directory.
In this tutorial you complete the following steps:
- Add a JSP file to the consumer direct sample store
- Run the idresgen utility on the tax.xml file
- Run the massload utility on the resolved tax.xml file
- Complete a shopping flow for various jurisdictions following a tax matrix
Calculation Rule AssignmentsThe calculation codes (in the CALCODE table) have been broken up to represent the different Canadian tax categories: GST, PST, HST, and QST. The significance of breaking up tax categories into isolated calculation codes resolves complications resulting from having to deal with multiple tax categories (GST, PST, HST and QST). This breakup can be applied to any jurisdiction tax system such as the American tax system where levels are distinguished by COUNTRY, TERRITORY, STATE, CITY, LOCAL, SECONDARY STATE, SECONDARY LOCAL, and so on. Each jurisdiction level may have their own isolated tax rate or exemption. The ship-to address that qualifies for a particular order item resolves to a distinct set of jurisdiction levels. For the example illustrated in this paper, all Canadian tax rules have been defined by distinguished jurisdiction level values. Four calculation codes created, each having a CALCODE.GROUPBY value of 8 to allow for OrderItems with different shipping addresses to be grouped separately. Each calculation code is then associated with four tax categories. At a more fine-grained level, several calculation rules are assigned for PST. The split for PST is...
- Calculation rule for PST rate for Prince Edward Island jurisdiction
- Calculation rule for PST rate for Ontario jurisdiction
- Calculation rule for PST rate for Manitoba jurisdiction
- Calculation rule for PST rate for Saskatchewan jurisdiction
- Calculation rule for PST rate for British Columbia jurisdiction
The PST split allows for the calculation framework to represent the same Tax Category with different tax rates. See the testing matrix later in this document for a detailed breakdown.
Procedure
- Copy the JSP files from the zip file to the consumer direct sample store directory.
- workspace_dir\Stores\directory
- Update the MultiAddressCheckout.jsp and SingleAddressCheckout.jsp files to show Canadian taxes:
<% orderTax = orderBean.getTaxes(); Hashtable orderTaxExample = orderTax.getCategorizedAmountsAndNames(); String nameTx, valueTx; if (orderTaxExample!=null) { for (Enumeration eTx=orderTaxExample.keys(); eTx.hasMoreElements();) { nameTx = (String)eTx.nextElement(); MonetaryAmount amtTx = (MonetaryAmount)orderTaxExample.get(nameTx); if (amtTx!=null) { if (amtTx.getValue().compareTo(new BigDecimal("0.0"))!=0) { FormattedMonetaryAmountDataBean amtDBTx = new FormattedMonetaryAmountDataBean(new MonetaryAmount(amtTx.getValue(), amtTx.getCurrency()),orderTax.getStoreAccessBean(),orderTax.getLangId()); %> <tr> <td align="right" colspan="5"> <font class="price"><b><%=nameTx%> </b></font></td> <td align="right" valign="top"> <font class="price"><%=amtDBTx.toString()%> </font> </td> </tr><% } } } } %>
- Save and close the files.
- Open the tax.xml file.
- Replace all references to @storeent_id_1 to the STOREENT_ID value from the database to update.
- Replace all references to @ffmcenter_id_1 to the FFMCENTER_ID value from the database to update.
- Replace the wcs.dtd path with the path of the Commerce Server wcs.dtd file. For example:
<!DOCTYPE import SYSTEM "E:\WebSphere\Commerce\schema\xml\wcs.dtd">
- Change directory to the extracted zip directory and locate the env.bat file.
- Update the env.bat file to match the environment:
- DBNAME
- Name of the database.
- DBUSER
- Database user name for the database.
- DBPWD
- Password associated with the user name for the database.
- RESGENFILE
- The path of the output resolved file.
- INPUTFILE
- The path of the input file tax.xml.
- processType
- Set to processType=server.
- TOOLKITDIR
- The target WebSphere Commerce toolkit installation directory.
- WCSHOME
- The path to the WebSphereCommerce Server.
- PATH
- The PATH to add the WCSHOME parameter.
- Run the appropriate command:
- Run the batch file Step1-idresgen.bat.
- idresgen -dbname %DBNAME% -dbuser %DBUSER% -dbpwd %DBPWD% -infile %INFILE% -outfile %OUTFILE% -method mixed -schemaname %DBUSER%
- idresgen -dbname %DBNAME% -dbuser %DBUSER% -dbpwd %DBPWD% -infile %INFILE% -outfile %OUTFILE% -method mixed -schemaname %DBUSER% -customizer %CUSTOMIZEFILE%
- Run the appropriate command:
- Run the batch file Step2-massload.bat.
- massload -dbname %DBNAME% -dbuser %DBUSER% -dbpwd %DBPWD% -infile %RESGENFILE% -method sqlimport -commitcount 20 -schemaname %DBUSER%
- In the env.bat file, set CUSTOMIZEFILE=WC_INSTALL\properties\OracleConnectionCustomizer.properties
- massload -dbname %DBNAME% -dbuser %DBUSER% -dbpwd %DBPWD% -infile %RESGENFILE% -method sqlimport -commitcount 20 -schemaname %DBUSER%
- After the data is loaded, test a shopping flow against the following Canadian tax matrix:
Province Name of Relevant Statute General Rate of Tax Display Base for PST Incl. GST Newfoundland HST 15% (GST incl.) HST only Nova Scotia HST 15% (GST incl.) HST only New Brunswick HST 15% (GST incl.) HST only Prince Edward Island Revenue Tax Act 10% GST and PST Yes (PST charged on GST) Ontario Retail Sales Tax Act 8% GST and PST No Manitoba Retail Sales Tax Act 7% GST and PST No Saskatchewan Education and Health Tax Act 7% GST and PST No British Columbia Social Service Tax Act 7% GST and PST No Quebec QST - please see QST Manual 7.5% (tax on GST as well, so therefore closer to 8.03%) GST and VAT Yes (VAT on GST) Alberta No PST GST only Yukon No PST GST only N.W.T. No PST GST only
Related concepts
Overview of the mass load utilities