Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorSven Schöling <s.schoeling@linet-services.de>
Mon, 16 Jan 2012 17:42:25 +0000 (18:42 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Mon, 16 Jan 2012 17:42:25 +0000 (18:42 +0100)
SL/DB.pm
SL/DB/Invoice.pm
SL/Form.pm
SL/WH.pm
t/helper/attr.t
t/helper/csv.t
t/test.sh

index 5542861..861fe6a 100644 (file)
--- 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',
index 91ee14c..14c11fa 100644 (file)
@@ -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)');
index 2647a2b..70a559d 100644 (file)
@@ -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" )                              :
index f760f5e..eb37626 100644 (file)
--- 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,
index ef49d8e..3fc0607 100644 (file)
@@ -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';
index a78a6a9..4e7ef12 100644 (file)
@@ -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",
index 521fa0c..761f902 100755 (executable)
--- 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)'