[ic] European taxation (again...)

Mike Heins mikeh@minivend.com
Tue, 12 Dec 2000 20:05:04 -0500

Quoting Rene Hertell (rene@hertell.com):
> Hi list!
> I have been browsing the mail-archives for a while and trying to find an
> clear and easy solution in solving the tax-problem that probably many of the
> European minivend-users bump into. As many of you know, the tax is based on
> product-categories.
> Does anyone have a simple solution (I'm a real amateur with this...) in how
> to solve this issue. It would be nice have a solution that would use the
> normal [salestax] tag. The prices are given in the productdb without tax.
> Here a small example: The db contains a field with the tax percentage. This
> field should then be used when calculating the basket.
> products.txt db
> name         price     tax
> toothbrush   10.00     0.22
> toothpaste   20.00     0.22
> a book       35.00     0.17
> Basket:
> Item         qty    price   tax   incl tax
> toothbrush   1      10.00  2.20      12.20
> toothpaste   1      20.00  4.40      24.40
> a book       1      35.00  7.70      42.70

There are several ways to do it. For Interchange 4.8 (and later 4.7.x)
I will have a UI to help do this.

The thing I like best is to create a new *shipping* method and
add tax with mv_handling. I will probably be using this method.

The quick and dirty way is to write a UserTag which does it
and then include that in salestax.asc.

UserTag  vat-calc  Order  table	field
UserTag  vat-calc  addAttr
UserTag  vat-calc  Routine <<EOR
sub {
	my ($table, $field, $opt) = @_;

	my $error = sub {
		my $msg = shift;
		return undef;

	my $tax = 0;
	foreach my $item (@$Vend::Items) {
		my $taxrate = tag_data($table, $field, $item->{code});
		$tax += ($taxrate * $item->{quantity});
	return $tax;

(If you put the above in your catalog.cfg instead of interchange.cfg, you will
have to make sure you have referenced the products table before you call it.)

Now this in salestax.asc:

    default	[vat-calc products tax]
    UK	[vat-calc products tax]
    FR	[vat-calc products tax]
    US	0

and this in catalog.cfg:

    SalesTax   country

should do it. You can also key it on category if you want, simply by 
creating a "tax" table and using:

	AutoModifier  products:category

Now use $item->{category} to key into the table for getting the tax
rate by percentage of price. (Obviously you will have to calculate the
price somehow, but that is not too difficult depending on your CommonAdjust

Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH  45056
phone +1.513.523.7621 fax 7501 <heins@akopia.com>

Unix version of an Outlook-style virus:
It works on the honor system. Please forward this message to everyone
you know, and delete a bunch of your files at random.