Wiedervorlage: alte Masken: Abfangen, wenn z.B. Betreff nicht vorbelegt
[kivitendo-erp.git] / t / part / assortment.t
1 use strict;
2 use Test::More;
3
4 use lib 't';
5 use Support::TestSetup;
6 use Carp;
7 use Test::Exception;
8 use SL::DB::Part;
9 use SL::Dev::Part qw(new_assortment);
10
11 Support::TestSetup::login();
12
13 clear_up();
14
15 my $assortment = new_assortment( assnumber       => 'aso1',
16                                  description     => "Assortment 1",
17                                  number_of_parts => 10,
18                                                  )->save;
19
20 is( SL::DB::Manager::Part->get_all_count(), 11,  "total number of parts created is 11");
21
22 $assortment = SL::DB::Manager::Part->find_by( partnumber => 'aso1' ) or die "Can't find assortment with partnumber aso1";
23
24 is($assortment->part_type,                  'assortment', 'assortment has correct part_type');
25 is(scalar @{$assortment->assortment_items},  10,          'assortment has 10 parts');
26 is($assortment->items_sellprice_sum,        100,          'assortment sellprice sum ok');
27 is($assortment->items_lastcost_sum,          50,          'assortment lastcost sum ok');
28
29 my $assortment_item = $assortment->assortment_items->[0];
30 is( $assortment_item->assortment->partnumber, 'aso1', "assortment_item links back to correct assortment");
31
32 clear_up();
33 done_testing;
34
35 sub clear_up {
36   SL::DB::Manager::AssortmentItem->delete_all(all => 1);
37   SL::DB::Manager::Part->delete_all(          all => 1);
38 };
39
40
41 1;