]> wagnertech.de Git - mfinanz.git/commitdiff
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 55428615ff2bcef8483914622349ac90ddb944ee..861fe6a52835bf8882e4e1185d6c4617c79878c0 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 91ee14c8584f404f23e50535c98d2b041a2a94cb..14c11fa7d6b5c48e6d606d80be41ff497f4294f5 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 2647a2bcaadf3cacd05c1d987f9da1bbbceb01d7..70a559d3537e1abcea2ed9425caa01ac4f291e7f 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 f760f5e9b36ad7fb9b4abc465fb9141394bb2f90..eb376268222ebeb56c02a5a1821d1dfe7a97fa7f 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 ef49d8e74fa073d60a92918ef1b00bf82b308b59..3fc0607d56fd91c1c2d20df3ca05361d40328e29 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 a78a6a96048b4d50a517d88317fb4abb4af136c7..4e7ef121c5d4a0bbbdac270da509e9b84f2732ef 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 521fa0cd7259569330db7efb8078a6e70bca106d..761f9021f76b868b0861f398ece37c7ddb8c8765 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)'