From ecf56eca694d9606ffe56d3cab13a6614efc6aa4 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Tue, 22 Jul 2008 23:27:50 +0000 Subject: Added format option to LedgerSMB::format_amount Added batch information options for check template Added batch default_date field Corrected issues with payment batches not preserving post dates when adding vouchers to existing batch. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2219 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB.pm | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'LedgerSMB.pm') diff --git a/LedgerSMB.pm b/LedgerSMB.pm index 67055b4f..9239cd50 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -370,11 +370,16 @@ sub format_amount { # Based on SQL-Ledger's Form::format_amount my $self = shift @_; - my %args = @_; + my %args = (ref($_[0]) eq 'HASH')? %{$_[0]}: @_; my $myconfig = $args{user} || $self->{_user}; my $amount = $args{amount}; my $places = $args{precision}; my $dash = $args{neg_format}; + my $format = $args{format}; + + if (!defined $format){ + $format = $myconfig->{numberformat} + } my $negative; if ($amount) { @@ -397,7 +402,7 @@ sub format_amount { if ($amount) { - if ( $myconfig->{numberformat} ) { + if ( $format ) { my ( $whole, $dec ) = split /\./, "$amount"; $amount = join '', reverse split //, $whole; @@ -407,35 +412,35 @@ sub format_amount { $dec = substr( $dec, 0, $places ); } - if ( $myconfig->{numberformat} eq '1,000.00' ) { + if ( $format eq '1,000.00' ) { $amount =~ s/\d{3,}?/$&,/g; $amount =~ s/,$//; $amount = join '', reverse split //, $amount; $amount .= "\.$dec" if ( $dec ne "" ); } - elsif ( $myconfig->{numberformat} eq '1 000.00' ) { + elsif ( $format eq '1 000.00' ) { $amount =~ s/\d{3,}?/$& /g; $amount =~ s/\s$//; $amount = join '', reverse split //, $amount; $amount .= "\.$dec" if ( $dec ne "" ); } - elsif ( $myconfig->{numberformat} eq "1'000.00" ) { + elsif ( $format eq "1'000.00" ) { $amount =~ s/\d{3,}?/$&'/g; $amount =~ s/'$//; $amount = join '', reverse split //, $amount; $amount .= "\.$dec" if ( $dec ne "" ); } - elsif ( $myconfig->{numberformat} eq '1.000,00' ) { + elsif ( $format eq '1.000,00' ) { $amount =~ s/\d{3,}?/$&./g; $amount =~ s/\.$//; $amount = join '', reverse split //, $amount; $amount .= ",$dec" if ( $dec ne "" ); } - elsif ( $myconfig->{numberformat} eq '1000,00' ) { + elsif ( $format eq '1000,00' ) { $amount = "$whole"; $amount .= ",$dec" if ( $dec ne "" ); } - elsif ( $myconfig->{numberformat} eq '1000.00' ) { + elsif ( $format eq '1000.00' ) { $amount = "$whole"; $amount .= ".$dec" if ( $dec ne "" ); } @@ -456,7 +461,7 @@ sub format_amount { if ( $dash eq "0" && $places ) { - if ( $myconfig->{numberformat} =~ /0,00$/ ) { + if ( $format =~ /0,00$/ ) { $amount = "0" . "," . "0" x $places; } else { -- cgit v1.2.3