Tutorial: Catching shopper address alternatives in the calculation framework

The calculation framework uses a shopper's address to provide order calculations for tax and shipping costs. If a shopper does not provide the correct city or state or country as input text, you can use the default implementation to catch any address differences.

Before you begin

  • Download the Jurs Mapping Text example which contains the alternative address entries for the jurisdiction mapping.
  • Download the zip file containing all the code related to this tutorial.

About this task

In the default implementation of WebSphere Commerce, the checkout billing and shipping pages prompt the shopper for input, using text entry fields. The instances where the state/province, city, or country is not input as expected result in spurious order calculations for tax and shipping costs. To compensate for faulty shopper input, we can load the jurisdiction mapping to allow for those alternative address inputs.

There can be multiple mapped jurisdiction representations to the same calculation rule. Therefore, the calculation rules can be independently defined apart from the multiple jurisdiction references. The alternative address inputs can then be defined for a single rule by mapping to several jurisdiction references.

The following section explains how to set up a Canadian tax implementation. It also includes excerpts that you can use to provide alternative jurisdiction mapping to prepare for calculating based on shopping input.

Note: The tax rate described in the tutorial is for sample only. For more information about changing the tax rates, see Updating the WebSphere Commerce tax configuration to match the current tax rate.
In this tutorial you will learn how to complete the following tasks:
  • Open the tax.xml file and add extra alternative jurisdiction mappings
  • Run idresgen utility on the tax.xml file
  • Run Massload on the resolved tax.xml file
  • Test some data using the above tax matrix

Procedure

  1. Extract the JursMapping.zip file into a temporary directory.
  2. Open the env.bat file for editing and update it to match your WebSphere Commerce Server environment, by filling in the following:
    DBNAME
    The database user of the WebSphere Commerce Server
    DBUSER
    The database user of the WebSphere Commerce Server
    DBPWD
    The database password of the WebSphere Commerce Server
    processType
    The target type:
    • WebSphere Commerce DeveloperApache Derbytoolkit
    • SolarisLinuxWindowsAIXserver
    TOOLKITDIR
    The target toolkit installation directory for WebSphere Commerce. For example:
    set TOOLKITDIR=WC_installdir
    WCSHOME
    The path to the WebSphere Commerce Server. For example:
    set WCSHOME=WC_installdir
    PATH
    Update the PATH to add the WCSHOME parameter. For example:
    set PATH=.;%WCSHOME%\bin;%PATH%
  3. Save and close the file.
  4. Update the XML for Ontario and Canada:
    1. Open the tax.xml and JursMapping.txt files for editing.
    2. Copying the entries from the JursMapping.txt file into the tax.xml file after the following entries:
      <jurst jurst_id="@jurst_id_20004" country="Canada"
      storeent_id="@storeent_id_1" 
              code="20004" subclass="2" state="Ontario" stateabbr="ON"
      countryabbr="CA" markfordelete="0"/> 
      <jurstgroup jurstgroup_id="@jurstgroup_id_20001"
      description="PST jurisdiction group ON" 
              subclass="2" storeent_id="@storeent_id_1" code="PST Group
      ON" markfordelete="0"/> 
      <jurstgprel jurst_id="@jurst_id_20004"
      jurstgroup_id="@jurstgroup_id_20001" subclass="2"/> 
      <jurstgprel jurst_id="@jurst_id_20004"
      jurstgroup_id="@jurstgroup_id_50000" subclass="2"/> 
      Note: The JursMapping.txt file contains provides examples to catch customer data alternative entries for the following variations:
      • Canada
      • CANADA
      • CA
      • Can
      • Ontario
      • ONTARIO
      • ontario
      • ON
      • ONT
      • Ont
    3. Close the JursMapping.txt file.
  5. In the tax.xml file and replace all references to @storeent_id_1 with the STOREENT_ID value from the database you want to update. For example:
    storeent_id="10001"
  6. In the tax.xml file, replace all references to @ffmcenter_id_1 with the FFMCENTER_ID value from the database you want to update. For example:
    ffmcenter_id="10001"
  7. In the tax.xml file, replace the wcs.dtd path with the path of your Commerce Server wcs.dtd file. For example:
    
    <!DOCTYPE import SYSTEM "WCDE_installdir\workspace\WC\xml\schema\dtd\wcs.dtd">
    
  8. Save and close the tax.xml file.
  9. Run the appropriate command:
    • Apache DerbyRun the batch file "Step1-idresgen.bat"
    • DB2idresgen -dbname name -dbuser user -dbpwd password-infile %INFILE% -outfile %OUTFILE% -method mixed -schemaname user
    • Oracleidresgen -dbname name -dbuser user -dbpwd password -infile %INFILE% -outfile %OUTFILE% -method mixed -schemaname user -customizer %CUSTOMIZEFILE%
  10. Run the appropriate command:
    • Apache DerbyRun the batch file "Step2-massload.bat".
    • DB2massload -dbname name -dbuser user -dbpwd password -infile taxResGen.xml -method sqlimport -commitcount 20 -schemaname user
    • Oracle
      • In the env.bat file, set CUSTOMIZEFILE=WC_installdir\properties\OracleConnectionCustomizer.properties
      • massload -dbname name -dbuser user -dbpwd password -infile taxResGen.xml -method sqlimport -commitcount 20 -schemaname user
  11. Place an order in your storefront using the Canada and Ontario data alternatives to test them. Ensure the tax rates match 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
    ONTARIO Retail Sales Tax Act 8% GST and PST No
    ON Retail Sales Tax Act 8% GST and PST No
    ontario Retail Sales Tax Act 8% GST and PST No
    ONT Retail Sales Tax Act 8% GST and PST No
    Ont 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 6% GST and PST No
    British Columbia Social Service Tax Act 7% GST and PST No
    Quebec QST - 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