1 use Test::More tests => 32;
7 use_ok 'Support::TestSetup';
9 use_ok 'SL::DB::Order';
10 use_ok 'SL::DB::Invoice';
12 Support::TestSetup::login();
15 $::myconfig{numberformat} = '1.000,00';
16 $::myconfig{dateformat} = 'dd.mm.yyyy';
19 my $p = new_ok 'SL::DB::Part';
20 is($p->sellprice_as_number('2,30'), '2,30');
21 is($p->sellprice, 2.30);
22 is($p->sellprice_as_number, '2,30');
23 is($p->sellprice_as_number('2,3442'), '2,3442');
24 is($p->sellprice, 2.3442);
25 is($p->sellprice_as_number, '2,3442');
27 my $o = new_ok 'SL::DB::Order';
28 is($o->reqdate_as_date('11.12.2007'), '11.12.2007');
29 is($o->reqdate->year, 2007);
30 is($o->reqdate->month, 12);
31 is($o->reqdate->day, 11);
32 is($o->reqdate_as_date, '11.12.2007');
33 $o->reqdate(DateTime->new(year => 2010, month => 4, day => 12));
34 is($o->reqdate_as_date, '12.04.2010');
36 is($o->marge_percent_as_percent('40'), '40,00');
37 is($o->marge_percent, 0.40);
38 is($o->marge_percent_as_percent, '40,00');
39 is($o->marge_percent_as_percent('22,4'), '22,40');
40 is($o->marge_percent, 0.224);
41 is($o->marge_percent_as_percent, '22,40');
42 is($o->marge_percent(0.231), 0.231);
43 is($o->marge_percent_as_percent, '23,10');
45 # overloaded attr: invoice taxamount
46 my $i = new_ok 'SL::DB::Invoice';
48 is($i->taxamount_as_number, '0,00');
51 is($i->taxamount_as_number, '1,66');
54 is $o->closed_as_bool_yn, 'Ja', 'bool 1';
56 is $o->closed_as_bool_yn, 'Nein', 'bool 2';
58 # undef test: this only works for columns without default, rose will set
59 # defaults according to the database
60 $i->taxincluded(undef);
61 is $i->taxincluded_as_bool_yn, '', 'bool 3';