SampleRegionalTax

Use this component for calculating taxes in pipelines using the multiple shipment features of Commerce Server 2000.

Ee825351.note(en-US,CS.10).gif Note

  • The SampleRegionalTax component is not a complete solution to tax calculation. It is provided as an example of a tax component that takes full advantage of the multiple shipment features of Commerce Server 2000. Microsoft strongly recommends that you purchase a third-party tax component.

Intended use: Order Processing pipeline, Tax stage.

Configuration Values

None.

Values Read

The SampleRegionalTax component reads the following values from the indicated dictionaries.

Key Dictionary Description
shipments Order A SimpleList object of shipments.
item._cy_oadjust_adjustedprice Order The total cost of an item.
RegionalTaxCache Context A reference to a dictionary containing tax information.

In addition, the SampleRegionalTax component reads the following keys from the Addresses dictionary in the OrderForm object.

Key Description
addresses.country_code The ship to country/region for the address ID retrieved for the shipment.
addresses.region_code Optional. The ship to region for the address ID retrieved for the shipment.

Values Written

The SampleRegionalTax component writes the following values to the Order dictionary.

Key Description
item._cy_tax_total The total tax for the item.
item._cy_tax_included The total tax for the item included in the cost. You must set this key to zero (0).
shipment._cy_tax_total The total tax for the shipment.
shipment._cy_tax_included The total tax for the shipment included in the cost. You must set this key to zero (0).
_cy_tax_total The total tax for the order.
_cy_tax_included The total tax for the order included in the cost. You must set this key to zero (0).

Remarks

The SampleRegionalTax component computes tax for the Commerce Server 2000 shipping architecture that handles multiple shipments. For more information about how Commerce Server processes shipments, seeĀ Multiple-shipment Shipping Architecture.

For each shipment in the order, the component first gets the tax rate from the database using the CacheManager object and stores it in the SampleRegionalTaxCache component.

The SampleRegionalTax component then goes through each item in the shipment and calculates its tax based on the rate retrieved from the tax rate table. Rates are retrieved based on the country and region codes in the dictionary of addresses in the Order dictionary. For more information about the dictionary of addresses, seeĀ Multiple-shipment Shipping Architecture.

As it goes through the items and shipments in the order, the SampleRegionalTax component accumulates totals for the items, shipments, and, finally, for the entire order.

The tax rate data stored in the SampleRegionalTaxCache component is a snapshot of the RegionalTax database table. The RegionalTax table contains three columns.

Column Data Type Description
country_code String, 255 characters. The country code.
region_code String, 255 characters. The region code.
rate Float, 8 bytes. The tax rate.

You may include a wildcard entry (@) for a region code. This will match regions that would not otherwise match. If no entry is found in the RegionalTax table, the rate is zero (0).

Using a pipeline containing the SampleRegionalTax component is very similar to using a Content Selection pipeline. First, you configure the CacheManager object to use the SampleRegionalTaxCache loader in the Application_OnStart section of the Global.asa file. Then, in the Active Server Pages (ASP) page, you add an entry for the CacheManager object to the Context dictionary and invoke the pipeline.

Setup code in the Application_OnStart method:

    ' Create a Dictionary to hold configuration information.
    Set dConfig = CreateObject("Commerce.Dictionary")

    ' Add configuration information to the dictionary. SampleRegtionalTax
    ' only uses a connection string.
    dConfig("ConnectionString") = "DSN=adsamples;UID=sa;PWD="

    ' Create a CacheManager object.
    Set CacheManager = Server.CreateObject("Commerce.CacheManager")

    ' Set the ProgID of the Loader component for the
    ' "SampleRegionalTaxCache" cache.
    CacheManager.LoaderProgId("SampleRegionalTaxCache") = _
                    "Commerce.SampleRegionalTaxCache"

    ' Set the Loader component config Dictionary for the cache.
    Set CacheManager.LoaderConfig("SampleRegionalTaxCache") = dConfig

    '
    ' Other CacheManager configuration code would appear here.
    '

    ' Store a reference to the CacheManager in the Application object.
    Set Application("CacheManager") = CacheManager

Code to run the pipeline containing the SampleRegionalTax component:

    ' Place a reference to the CacheManager in the context dictionary.
    Set dContext = Server.CreateObject("Commerce.Dictionary")
    dContext.CacheManager = Application("CacheManager")

    '
    ' Set other values and create the Order dictionary (dOrder) here.
    '

    ' Load and execute the pipeline containing the tax component.
    Set pPooledPipe = Server.CreateObject("Commerce.PooledPipeline")
    pPooledPipe.LoadPipe("OrderAndTax.pcf")
    iErrVal = pPooledPipe.Execute(0, dOrder, dContext, 1)

See Also

Multiple-shipment Shipping Architecture

CacheManager Object

PooledPipeline Object

PooledTxPipeline Object


All rights reserved.