diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2008-07-22 23:27:50 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2008-07-22 23:27:50 +0000 |
commit | ecf56eca694d9606ffe56d3cab13a6614efc6aa4 (patch) | |
tree | 84fc7c9a763a97ef1c633a885b80456fc93559a0 /LedgerSMB.pm | |
parent | 12a0239ccda7e2bd68cae034e916c6a664c3c430 (diff) |
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
Diffstat (limited to 'LedgerSMB.pm')
-rwxr-xr-x | LedgerSMB.pm | 23 |
1 files changed, 14 insertions, 9 deletions
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 { |