[ic] A bug in Interpolate.pm?

David Guerrero david@boe.es
Mon, 18 Sep 2000 16:18:04 +0200


I was having problems with the [salestax] tag with Interchange 4.5.5. It
always returned 0. 

I am using the es_ES locale, with the following settings in catalog.cfg:

Locale           es_ES
Locale           es_ES mon_decimal_point ,
Locale           es_ES decimal_point ,
Locale           es_ES mon_thousands_sep .
Locale           es_ES thousands_sep .
Locale           es_ES currency_symbol " Pts"
Locale           es_ES int_currency_symbol " Pts"
Locale           es_ES frac_digits      0
Locale           es_ES p_cs_precedes    0

Salestax tax_code

I have the following contents in the salestax.asc file:

IVA	.05

I use "[perl] $Values->{tax_code} = 'IVA'; return; [/perl]" in my pages,
in order to set the correct value for the salestax tag.

The problem was that with that locale in use, the "*" operator in PERL,
didn't handle decimal operations right. It always discarded the decimal
part of the operators. You need to use the comma notation for the
decimal part. 

When I put 

IVA	,05

in the salestax.asc file, the [salestax] always returned 0, but this
time because of the regexp of the line 5262 of Interpolate.pm:

	if($tax =~ /^-?(?:\d+(?:\.\d*)?|\.\d+)$/) {

I've changed the regexp with:

	if($tax =~ /^-?(?:\d+(?:[\.\,]\d*)?|[\.\,]\d+)$/) {

and now it works.

I'm not sure that this is a reasonable fix for the problem, as probably
there will be more places in the code where this handling of Locale will
break things.

Mike, and Akopia people, what do you think about it?

Thanks, and congratulation for this excellent piece of software.

---------------< LINUX: The choice of a GNU generation >----------------
David Guerrero                                      E-mail: david@boe.es
Unidad Informatica                                    Telf: 91 384 16 72
B.O.E. (Boletin Oficial del Estado)         Ministerio de la Presidencia