From: Sven Schöling Date: Mon, 16 Jan 2012 17:42:25 +0000 (+0100) Subject: Merge branch 'master' of vc.linet-services.de:public/lx-office-erp X-Git-Tag: release-2.7.0beta1~49 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/commitdiff_plain/e0ad5757c7f9551f808b55c114ff8892f09689f4?hp=dda4cde1bf8901c87c6bbd27192f6296af2400ff Merge branch 'master' of vc.linet-services.de:public/lx-office-erp --- diff --git a/SL/DB.pm b/SL/DB.pm index 55428615f..861fe6a52 100644 --- a/SL/DB.pm +++ b/SL/DB.pm @@ -67,7 +67,8 @@ sub _register_db { } else { my $european_dates = 0; if ($::myconfig{dateformat}) { - $european_dates = 1 if $_dateformats{ $::myconfig{dateformat} } =~ m/european/i; + $european_dates = 1 if $_dateformats{ $::myconfig{dateformat} } + && $_dateformats{ $::myconfig{dateformat} } =~ m/european/i; } %connect_settings = ( driver => $::myconfig{dbdriver} || 'Pg', diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 91ee14c85..14c11fa7d 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -93,7 +93,7 @@ sub taxamount { my $self = shift; die 'not a setter method' if @_; - return $self->amount - $self->netamount; + return ($self->amount || 0) - ($self->netamount || 0); } __PACKAGE__->meta->make_attr_helpers(taxamount => 'numeric(15,5)'); diff --git a/SL/Form.pm b/SL/Form.pm index 2647a2bca..70a559d35 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -852,6 +852,7 @@ sub format_amount { $main::lxdebug->enter_sub(2); my ($self, $myconfig, $amount, $places, $dash) = @_; + $dash ||= ''; if ($amount eq "") { $amount = 0; @@ -868,9 +869,10 @@ sub format_amount { $amount *= 1; $places *= -1; - my ($actual_places) = ($amount =~ /\.(\d+)/); - $actual_places = length($actual_places); - $places = $actual_places > $places ? $actual_places : $places; + if ($amount =~ /\.(\d+)/) { + my $actual_places = length $1; + $places = $actual_places if $actual_places > $places; + } } } $amount = $self->round_amount($amount, $places); @@ -882,7 +884,7 @@ sub format_amount { $p[0] =~ s/\B(?=(...)*$)/$d[1]/g if $d[1]; # add 1,000 delimiters $amount = $p[0]; - $amount .= $d[0].$p[1].(0 x ($places - length $p[1])) if ($places || $p[1] ne ''); + $amount .= $d[0].($p[1]||'').(0 x ($places - length ($p[1]||''))) if ($places || $p[1] ne ''); $amount = do { ($dash =~ /-/) ? ($neg ? "($amount)" : "$amount" ) : diff --git a/SL/WH.pm b/SL/WH.pm index f760f5e9b..eb3762682 100644 --- a/SL/WH.pm +++ b/SL/WH.pm @@ -115,6 +115,8 @@ sub transfer { $qty /= $part->unit_obj->factor || 1 if $part->unit; } + $params{chargenumber} ||= ''; + if ($direction & 1) { SL::DB::Inventory->new( %params, diff --git a/t/helper/attr.t b/t/helper/attr.t index ef49d8e74..3fc0607d5 100644 --- a/t/helper/attr.t +++ b/t/helper/attr.t @@ -1,21 +1,19 @@ use Test::More tests => 29; +use lib 't'; + use DateTime; +use_ok 'Support::TestSetup'; use_ok 'SL::DB::Part'; use_ok 'SL::DB::Order'; use_ok 'SL::DB::Invoice'; -use_ok 'SL::Dispatcher'; +Support::TestSetup::login(); { -$::dispatcher = SL::Dispatcher->new; -$::dispatcher->pre_startup_setup; -no warnings 'once'; -$::form = Form->new; $::myconfig{numberformat} = '1.000,00'; $::myconfig{dateformat} = 'dd.mm.yyyy'; -$::locale = Locale->new('de'); } my $p = new_ok 'SL::DB::Part'; diff --git a/t/helper/csv.t b/t/helper/csv.t index a78a6a960..4e7ef121c 100644 --- a/t/helper/csv.t +++ b/t/helper/csv.t @@ -1,12 +1,16 @@ -use Test::More tests => 39; -use SL::Dispatcher; +use Test::More tests => 40; + +use lib 't'; + use Data::Dumper; use utf8; +use_ok 'Support::TestSetup'; use_ok 'SL::Helper::Csv'; -my $csv; -$csv = SL::Helper::Csv->new( +Support::TestSetup::login(); + +my $csv = SL::Helper::Csv->new( file => \"Kaffee\n", header => [ 'description' ], class => 'SL::DB::Part', @@ -17,20 +21,11 @@ isa_ok $csv->_io, 'IO::File'; isa_ok $csv->parse, 'SL::Helper::Csv', 'parsing returns self'; is_deeply $csv->get_data, [ { description => 'Kaffee' } ], 'simple case works'; - is $csv->get_objects->[0]->description, 'Kaffee', 'get_object works'; #### -{ -no warnings 'once'; -$::dispatcher = SL::Dispatcher->new; -$::dispatcher->pre_startup_setup(); -} - -$::form = Form->new; $::myconfig{numberformat} = '1.000,00'; $::myconfig{dateformat} = 'dd.mm.yyyy'; -$::locale = Locale->new('de'); $csv = SL::Helper::Csv->new( file => \"Kaffee;0.12;12,2;1,5234\n", diff --git a/t/test.sh b/t/test.sh index 521fa0cd7..761f9021f 100755 --- a/t/test.sh +++ b/t/test.sh @@ -1 +1 @@ -find t | grep "\.t$" | grep -v '^t/old' | HARNESS_OPTIONS=j:c xargs perl -Imodules/fallback -MTest::Harness -e 'BEGIN { unshift @INC, "modules/override" } runtests(@ARGV)' +find t | grep "\.t$" | grep -v '^t/old' | HARNESS_OPTIONS=j:c xargs perl -Imodules/override -MTest::Harness -e 'BEGIN { push @INC, "modules/fallback" } runtests(@ARGV)'