[ic] usertag in salestax.asc
Carsten Jahnke
carstenjahnke at web.de
Wed Aug 4 06:04:41 EDT 2004
Hi,
I have to calculate taxrates on product basis. From a field in the
products table I get the taxrate that should be used.
I searched the list and found a posting by Mike where he explained how
to use a usertag in the salestax.asc file to use dynamic tax rates.
so I put
default [vatcalc products tax_category]
into the salestax.asc but if I do that and restart IC it just hangs when
I call the basket page. It then usses 100% CPU (maybe some infinite
loop?!) and I have to kill the interchange process :(
The usertag just returns a plain value like 0.16. When I put it directly
into salestax.asc it works fine. (e.g default 0.16)
Can someone help me with that?
Thanks in advance!
The original short message of Mike Heins from Tue, 12 Dec 2000:
---------------------------------------------------------------
...
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;
Log($msg);
return undef;
};
my $tax = 0;
foreach my $item (@$Vend::Items) {
my $taxrate = tag_data($table, $field, $item->{code});
$tax += ($taxrate * $item->{quantity});
}
return $tax;
}
EOR
(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.
...
--
Carsten Jahnke
email: carstenjahnke at web.de
More information about the interchange-users
mailing list