} 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',
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)');
$main::lxdebug->enter_sub(2);
my ($self, $myconfig, $amount, $places, $dash) = @_;
+ $dash ||= '';
if ($amount eq "") {
$amount = 0;
$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);
$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" ) :
$qty /= $part->unit_obj->factor || 1 if $part->unit;
}
+ $params{chargenumber} ||= '';
+
if ($direction & 1) {
SL::DB::Inventory->new(
%params,
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';
-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',
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",
-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)'