[ic] Calculating saletax for individual items

Mike Heins interchange-users@icdevgroup.org
Mon May 5 08:36:01 2003


Quoting Andy Mayer (andy@andymayer.net):
> On Fri, 2003-05-02 at 23:10, Jamie Neil wrote:
> > I wanted to do the same thing, but found no built in mechanism for
> > displaying prices with tax. So I wrote a usertag.
> 
> *code snipped*
> 
> Many thanks for the usertag. That will certainly help me. I am basically
> trying to build a B2C system, where users assume that prices displayed
> are including tax, but when they checkout they need to know how much
> they have spent on tax.
> 
> But I was wondering if, rather than call your usertag from the flypage
> and all results pages (and all UI components that display the price),
> would it would be more efficient to store the price in the products
> table *with* tax already added, and then modify the checkout page to
> show what portion of the prices are tax (ie. just like amazon.co.uk).

There are a number of possibilities for this.

One is to set up a "display" locale that is in use when browsing. Then
when checkout occurs, you could enter the "compute" locale. Each would
have a different setting for CommonAdjust and SalesTax.

Locale display <<EOP
{
	CommonAdjust	=> ':price, [add-tax]',
	SalesTax        => '',
}
EOP

Locale compute <<EOP
{
	CommonAdjust	=> ':price',
	SalesTax        => 'multi',
}
EOP

You would want to modify the [add-tax] to figure out its base items
from the $item variable set while in chained pricing if it is passed
no amount and category.

Then at the top of your checkout display and in your checkout profile,
you do:

	[setlocale locale=display]

>From that point on, prices will be displayed without tax and tax will
be computed.

There are many other possiblities -- [profile ...], creating your own
pricing display primitives with [item-tag ...] and UserTag and using
that, having two price fields in the products database, etc. All in all
I think locale will work better here.

A competent consultant could implement this fairly quickly, I think.
I have done it myself a couple of times in different ways.

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

"Laughter is inner jogging." -- Norman Cousins