[interchange-cvs] interchange - heins modified lib/Vend/Util.pm
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Thu Jan 23 15:15:01 2003
User: heins
Date: 2003-01-23 20:14:14 GMT
Modified: lib/Vend Util.pm
Log:
* Automatically convert via PriceDivide if locale=xx_XX sent to
[currency ...], [salestax ...], [total-cost], etc.
Revision Changes Path
2.47 +14 -5 interchange/lib/Vend/Util.pm
rev 2.47, prev_rev 2.46
Index: Util.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Util.pm,v
retrieving revision 2.46
retrieving revision 2.47
diff -u -r2.46 -r2.47
--- Util.pm 21 Jan 2003 16:09:09 -0000 2.46
+++ Util.pm 23 Jan 2003 20:14:14 -0000 2.47
@@ -1,6 +1,6 @@
# Vend::Util - Interchange utility functions
#
-# $Id: Util.pm,v 2.46 2003/01/21 16:09:09 mheins Exp $
+# $Id: Util.pm,v 2.47 2003/01/23 20:14:14 mheins Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -85,7 +85,7 @@
use Safe;
use subs qw(logError logGlobal);
use vars qw($VERSION @EXPORT @EXPORT_OK);
-$VERSION = substr(q$Revision: 2.46 $, 10);
+$VERSION = substr(q$Revision: 2.47 $, 10);
BEGIN {
eval {
@@ -461,9 +461,17 @@
sub currency {
my($amount, $noformat, $convert, $opt) = @_;
$opt = {} unless $opt;
-
- $amount = $amount / $Vend::Cfg->{PriceDivide}
- if $convert and $Vend::Cfg->{PriceDivide} != 0;
+
+ my $pd = $Vend::Cfg->{PriceDivide};
+ if($opt->{locale}) {
+ $convert = 1;
+ $pd = $Vend::Cfg->{Locale_repository}{$opt->{locale}}{PriceDivide};
+ }
+
+ if($pd and $convert) {
+ $amount = $amount / $pd;
+ }
+
return $amount if $noformat;
my $loc;
my $sep;
@@ -471,6 +479,7 @@
my $fmt;
my $precede = '';
my $succede = '';
+
my $loc = $opt->{locale}
|| $::Scratch->{mv_currency_tmp}
|| $::Scratch->{mv_currency}