diff options
-rwxr-xr-x | LedgerSMB.pm | 39 | ||||
-rw-r--r-- | LedgerSMB/Form.pm | 67 | ||||
-rw-r--r-- | LedgerSMB/Locale.pm | 6 | ||||
-rw-r--r-- | t/10-form.t | 4 |
4 files changed, 46 insertions, 70 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm index bff40829..3581dfe7 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -301,35 +301,30 @@ sub format_amount { $amount =~ s/,$//; $amount = join '', reverse split //, $amount; $amount .= "\.$dec" if ( $dec ne "" ); - } - - if ( $myconfig->{numberformat} eq '1 000.00' ) { + } + elsif ( $myconfig->{numberformat} eq '1 000.00' ) { $amount =~ s/\d{3,}?/$& /g; $amount =~ s/\s$//; $amount = join '', reverse split //, $amount; $amount .= "\.$dec" if ( $dec ne "" ); - } - - if ( $myconfig->{numberformat} eq "1'000.00" ) { + } + elsif ( $myconfig->{numberformat} eq "1'000.00" ) { $amount =~ s/\d{3,}?/$&'/g; $amount =~ s/'$//; $amount = join '', reverse split //, $amount; $amount .= "\.$dec" if ( $dec ne "" ); - } - - if ( $myconfig->{numberformat} eq '1.000,00' ) { + } + elsif ( $myconfig->{numberformat} eq '1.000,00' ) { $amount =~ s/\d{3,}?/$&./g; $amount =~ s/\.$//; $amount = join '', reverse split //, $amount; $amount .= ",$dec" if ( $dec ne "" ); - } - - if ( $myconfig->{numberformat} eq '1000,00' ) { + } + elsif ( $myconfig->{numberformat} eq '1000,00' ) { $amount = "$whole"; $amount .= ",$dec" if ( $dec ne "" ); - } - - if ( $myconfig->{numberformat} eq '1000.00' ) { + } + elsif ( $myconfig->{numberformat} eq '1000.00' ) { $amount = "$whole"; $amount .= ".$dec" if ( $dec ne "" ); } @@ -390,11 +385,10 @@ sub parse_amount { $amount =~ s/\.//g; $amount =~ s/,/./; } - if ( $numberformat eq '1 000.00' ) { + elsif ( $numberformat eq '1 000.00' ) { $amount =~ s/\s//g; } - - if ( $numberformat eq "1'000.00" ) { + elsif ( $numberformat eq "1'000.00" ) { $amount =~ s/'//g; } @@ -402,7 +396,7 @@ sub parse_amount { if ( $amount =~ s/\((\d*\.?\d*)\)/$1/ ) { $amount = $1 * -1; } - if ( $amount =~ s/(\d*\.?\d*)\s?DR/$1/ ) { + elsif ( $amount =~ s/(\d*\.?\d*)\s?DR/$1/ ) { $amount = $1 * -1; } $amount =~ s/\s?CR//; @@ -486,12 +480,10 @@ sub date_to_number { if ( $myconfig->{dateformat} =~ /^yy/ ) { ( $yy, $mm, $dd ) = split /\D/, $date; } - - if ( $myconfig->{dateformat} =~ /^mm/ ) { + elsif ( $myconfig->{dateformat} =~ /^mm/ ) { ( $mm, $dd, $yy ) = split /\D/, $date; } - - if ( $myconfig->{dateformat} =~ /^dd/ ) { + elsif ( $myconfig->{dateformat} =~ /^dd/ ) { ( $dd, $mm, $yy ) = split /\D/, $date; } @@ -581,7 +573,6 @@ sub merge { if ( !scalar @keys ) { @keys = keys %{$src}; } - #for my $arg ( keys %$src ) { for my $arg ( @keys ) { my $dst_arg; if ($index) { diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index 81a9efe1..e441d474 100644 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -452,35 +452,30 @@ sub format_amount { $amount =~ s/,$//; $amount = join '', reverse split //, $amount; $amount .= "\.$dec" if ( $dec ne "" ); - } - - if ( $myconfig->{numberformat} eq '1 000.00' ) { + } + elsif ( $myconfig->{numberformat} eq '1 000.00' ) { $amount =~ s/\d{3,}?/$& /g; $amount =~ s/\s$//; $amount = join '', reverse split //, $amount; $amount .= "\.$dec" if ( $dec ne "" ); - } - - if ( $myconfig->{numberformat} eq "1'000.00" ) { + } + elsif ( $myconfig->{numberformat} eq "1'000.00" ) { $amount =~ s/\d{3,}?/$&'/g; $amount =~ s/'$//; $amount = join '', reverse split //, $amount; $amount .= "\.$dec" if ( $dec ne "" ); - } - - if ( $myconfig->{numberformat} eq '1.000,00' ) { + } + elsif ( $myconfig->{numberformat} eq '1.000,00' ) { $amount =~ s/\d{3,}?/$&./g; $amount =~ s/\.$//; $amount = join '', reverse split //, $amount; $amount .= ",$dec" if ( $dec ne "" ); - } - - if ( $myconfig->{numberformat} eq '1000,00' ) { + } + elsif ( $myconfig->{numberformat} eq '1000,00' ) { $amount = "$whole"; $amount .= ",$dec" if ( $dec ne "" ); - } - - if ( $myconfig->{numberformat} eq '1000.00' ) { + } + elsif ( $myconfig->{numberformat} eq '1000.00' ) { $amount = "$whole"; $amount .= ".$dec" if ( $dec ne "" ); } @@ -538,11 +533,10 @@ sub parse_amount { $amount =~ s/\.//g; $amount =~ s/,/./; } - if ( $numberformat eq '1 000.00' ) { + elsif ( $numberformat eq '1 000.00' ) { $amount =~ s/\s//g; } - - if ( $numberformat eq "1'000.00" ) { + elsif ( $numberformat eq "1'000.00" ) { $amount =~ s/'//g; } @@ -550,7 +544,7 @@ sub parse_amount { if ( $amount =~ s/\((\d*\.?\d*)\)/$1/ ) { $amount = $1 * -1; } - if ( $amount =~ s/(\d*\.?\d*)\s?DR/$1/ ) { + elsif ( $amount =~ s/(\d*\.?\d*)\s?DR/$1/ ) { $amount = $1 * -1; } $amount =~ s/\s?CR//; @@ -1348,12 +1342,10 @@ sub datetonum { if ( $myconfig->{dateformat} =~ /^yy/ ) { ( $yy, $mm, $dd ) = split /\D/, $date; } - - if ( $myconfig->{dateformat} =~ /^mm/ ) { + elsif ( $myconfig->{dateformat} =~ /^mm/ ) { ( $mm, $dd, $yy ) = split /\D/, $date; } - - if ( $myconfig->{dateformat} =~ /^dd/ ) { + elsif ( $myconfig->{dateformat} =~ /^dd/ ) { ( $dd, $mm, $yy ) = split /\D/, $date; } @@ -1389,12 +1381,10 @@ sub add_date { if ( $myconfig->{dateformat} =~ /^yy/ ) { ( $yy, $mm, $dd ) = split /\D/, $date; } - - if ( $myconfig->{dateformat} =~ /^mm/ ) { + elsif ( $myconfig->{dateformat} =~ /^mm/ ) { ( $mm, $dd, $yy ) = split /\D/, $date; } - - if ( $myconfig->{dateformat} =~ /^dd/ ) { + elsif ( $myconfig->{dateformat} =~ /^dd/ ) { ( $dd, $mm, $yy ) = split /\D/, $date; } @@ -1408,12 +1398,10 @@ sub add_date { if ( $unit eq 'days' ) { $diff = $repeat * 86400; } - - if ( $unit eq 'weeks' ) { + elsif ( $unit eq 'weeks' ) { $diff = $repeat * 604800; } - - if ( $unit eq 'months' ) { + elsif ( $unit eq 'months' ) { $diff = $mm + $repeat; my $whole = int( $diff / 12 ); @@ -1424,8 +1412,7 @@ sub add_date { $yy-- if $mm == 12; $diff = 0; } - - if ( $unit eq 'years' ) { + elsif ( $unit eq 'years' ) { $yy += $repeat; } @@ -1443,12 +1430,10 @@ sub add_date { if ( $myconfig->{dateformat} =~ /^yy/ ) { $date = "$yy$spc$mm$spc$dd"; } - - if ( $myconfig->{dateformat} =~ /^mm/ ) { + elsif ( $myconfig->{dateformat} =~ /^mm/ ) { $date = "$mm$spc$dd$spc$yy"; } - - if ( $myconfig->{dateformat} =~ /^dd/ ) { + elsif ( $myconfig->{dateformat} =~ /^dd/ ) { $date = "$dd$spc$mm$spc$yy"; } @@ -3054,13 +3039,13 @@ sub split_date { my ( $self, $dateformat, $date ) = @_; - my @d = localtime; my $mm; my $dd; my $yy; my $rv; if ( !$date ) { + my @d = localtime; $dd = $d[3]; $mm = ++$d[4]; $yy = substr( $d[5], -2 ); @@ -3089,8 +3074,7 @@ sub split_date { $rv = "$yy$mm$dd"; } } - - if ( $dateformat =~ /^mm/ ) { + elsif ( $dateformat =~ /^mm/ ) { if ($date) { @@ -3111,8 +3095,7 @@ sub split_date { $rv = "$mm$dd$yy"; } } - - if ( $dateformat =~ /^dd/ ) { + elsif ( $dateformat =~ /^dd/ ) { if ($date) { diff --git a/LedgerSMB/Locale.pm b/LedgerSMB/Locale.pm index 8e1d2e9f..7ef8563e 100644 --- a/LedgerSMB/Locale.pm +++ b/LedgerSMB/Locale.pm @@ -113,12 +113,10 @@ sub date { if ( $myconfig->{dateformat} =~ /^yy/ ) { ( $yy, $mm, $dd ) = split /\D/, $date; } - - if ( $myconfig->{dateformat} =~ /^mm/ ) { + elsif ( $myconfig->{dateformat} =~ /^mm/ ) { ( $mm, $dd, $yy ) = split /\D/, $date; } - - if ( $myconfig->{dateformat} =~ /^dd/ ) { + elsif ( $myconfig->{dateformat} =~ /^dd/ ) { ( $dd, $mm, $yy ) = split /\D/, $date; } diff --git a/t/10-form.t b/t/10-form.t index 68b5e264..6c170a80 100644 --- a/t/10-form.t +++ b/t/10-form.t @@ -411,3 +411,7 @@ is($form->sort_order($aryref, {name => 0, projectnumber => 3, startdate => 1}), $form = new Form; @r = trap{$form->print_button({'pear' => {'key' => 'P', 'value' => 'Pears'}}, 'pear')}; is($trap->stdout, "<button class=\"submit\" type=\"submit\" name=\"action\" value=\"pear\" accesskey=\"P\" title=\"Pears [Alt-P]\">Pears</button>\n", 'print_button'); + +## $form->like checks +$form = new Form; +is($form->like('hello world'), '%hello world%', 'like'); |