kivitendo/t/helper/attr.t @ 59626ee2
59626ee2 | Bernd Bleßmann | use Test::More tests => 44;
|
||
c616c909 | Sven Schöling | |||
6b378ca7 | Sven Schöling | use lib 't';
|
||
c616c909 | Sven Schöling | use DateTime;
|
||
6b378ca7 | Sven Schöling | use_ok 'Support::TestSetup';
|
||
c616c909 | Sven Schöling | use_ok 'SL::DB::Part';
|
||
use_ok 'SL::DB::Order';
|
||||
78034f24 | Sven Schöling | use_ok 'SL::DB::Invoice';
|
||
c616c909 | Sven Schöling | |||
6b378ca7 | Sven Schöling | Support::TestSetup::login();
|
||
c616c909 | Sven Schöling | |||
0d4dc351 | Sven Schöling | {
|
||
c616c909 | Sven Schöling | $::myconfig{numberformat} = '1.000,00';
|
||
$::myconfig{dateformat} = 'dd.mm.yyyy';
|
||||
0d4dc351 | Sven Schöling | }
|
||
c616c909 | Sven Schöling | |||
my $p = new_ok 'SL::DB::Part';
|
||||
is($p->sellprice_as_number('2,30'), '2,30');
|
||||
is($p->sellprice, 2.30);
|
||||
is($p->sellprice_as_number, '2,30');
|
||||
is($p->sellprice_as_number('2,3442'), '2,3442');
|
||||
is($p->sellprice, 2.3442);
|
||||
is($p->sellprice_as_number, '2,3442');
|
||||
59626ee2 | Bernd Bleßmann | is($p->listprice_as_null_number('2,30'), '2,30');
|
||
is($p->listprice, 2.30);
|
||||
is($p->listprice_as_null_number, '2,30');
|
||||
is($p->listprice_as_null_number('2,3442'), '2,3442');
|
||||
is($p->listprice, 2.3442);
|
||||
is($p->listprice_as_null_number, '2,3442');
|
||||
is($p->listprice_as_null_number(''), '');
|
||||
is($p->listprice, undef);
|
||||
is($p->listprice_as_null_number, '');
|
||||
is($p->listprice_as_null_number('0'), '0,00');
|
||||
is($p->listprice, 0);
|
||||
is($p->listprice_as_null_number, '0,00');
|
||||
c616c909 | Sven Schöling | |||
my $o = new_ok 'SL::DB::Order';
|
||||
is($o->reqdate_as_date('11.12.2007'), '11.12.2007');
|
||||
is($o->reqdate->year, 2007);
|
||||
is($o->reqdate->month, 12);
|
||||
is($o->reqdate->day, 11);
|
||||
is($o->reqdate_as_date, '11.12.2007');
|
||||
$o->reqdate(DateTime->new(year => 2010, month => 4, day => 12));
|
||||
is($o->reqdate_as_date, '12.04.2010');
|
||||
525c820d | Sven Schöling | is($o->marge_percent_as_percent('40'), '40,00');
|
||
c616c909 | Sven Schöling | is($o->marge_percent, 0.40);
|
||
525c820d | Sven Schöling | is($o->marge_percent_as_percent, '40,00');
|
||
3782216a | Moritz Bunkus | is($o->marge_percent_as_percent('22,4'), '22,40');
|
||
c616c909 | Sven Schöling | is($o->marge_percent, 0.224);
|
||
525c820d | Sven Schöling | is($o->marge_percent_as_percent, '22,40');
|
||
c616c909 | Sven Schöling | is($o->marge_percent(0.231), 0.231);
|
||
525c820d | Sven Schöling | is($o->marge_percent_as_percent, '23,10');
|
||
78034f24 | Sven Schöling | |||
# overloaded attr: invoice taxamount
|
||||
my $i = new_ok 'SL::DB::Invoice';
|
||||
is($i->taxamount_as_number, '0,00');
|
||||
$i->amount(12);
|
||||
$i->netamount(10.34);
|
||||
is($i->taxamount_as_number, '1,66');
|
||||
8944e415 | Sven Schöling | $o->closed(1);
|
||
is $o->closed_as_bool_yn, 'Ja', 'bool 1';
|
||||
$o->closed(0);
|
||||
is $o->closed_as_bool_yn, 'Nein', 'bool 2';
|
||||
# undef test: this only works for columns without default, rose will set
|
||||
# defaults according to the database
|
||||
$i->taxincluded(undef);
|
||||
is $i->taxincluded_as_bool_yn, '', 'bool 3';
|