Revision e043078d
Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt
t/part/assortment.t | ||
---|---|---|
19 | 19 |
my $assortment = SL::DB::Manager::Part->find_by( partnumber => 'as1' ); |
20 | 20 |
|
21 | 21 |
is($assortment->part_type, 'assortment', 'assortment has correct part_type'); |
22 |
is(scalar @{$assortment->assortment_items}, 2, 'assortment has two parts');
|
|
23 |
is($assortment->assortment_sellprice_sum, 19.98, 'assortment sellprice sum ok');
|
|
24 |
is($assortment->assortment_lastcost_sum, 13.32, 'assortment lastcost sum ok');
|
|
22 |
is(scalar @{$assortment->assortment_items}, 2, 'assortment has two parts');
|
|
23 |
is($assortment->items_sellprice_sum, 19.98, 'assortment sellprice sum ok');
|
|
24 |
is($assortment->items_lastcost_sum, 13.32, 'assortment lastcost sum ok');
|
|
25 | 25 |
|
26 | 26 |
my $assortment_item = $assortment->assortment_items->[0]; |
27 | 27 |
is( $assortment_item->assortment->partnumber, 'as1', "assortment_item links back to correct assortment"); |
... | ... | |
32 | 32 |
sub reset_state { |
33 | 33 |
my %params = @_; |
34 | 34 |
|
35 |
my ($part1, $part2, $unit); |
|
36 |
|
|
37 | 35 |
# SL::DB::Manager::AssortmentItem->delete_all(all => 1); |
38 | 36 |
# SL::DB::Manager::Part->delete_all(all => 1); |
39 | 37 |
my ($part1, $part2, $unit, $assortment_part, $assortment_1, $assortment_2); |
40 | 38 |
|
41 |
my $unit = SL::DB::Manager::Unit->find_by(name => 'Stck') || die "Can't find unit 'Stck'";
|
|
39 |
$unit = SL::DB::Manager::Unit->find_by(name => 'Stck') || die "Can't find unit 'Stck'"; |
|
42 | 40 |
$part1 = SL::DB::Part->new_part( partnumber => '7777', |
43 | 41 |
description => "assortment part 1", |
44 | 42 |
unit => $unit->name, |
... | ... | |
50 | 48 |
$part2->description( "assortment part 2" ); |
51 | 49 |
$part2->save; |
52 | 50 |
|
53 |
my $assortment_part = SL::DB::Part->new_assortment( partnumber => 'as1',
|
|
54 |
description => 'assortment',
|
|
55 |
sellprice => '0',
|
|
56 |
unit => $unit->name);
|
|
57 |
my $assortment_1 = SL::DB::AssortmentItem->new( parts_id => $part1->id, qty => 3, unit => $part1->unit, position => 1);
|
|
58 |
my $assortment_2 = SL::DB::AssortmentItem->new( parts_id => $part2->id, qty => 3, unit => $part2->unit, position => 2);
|
|
51 |
$assortment_part = SL::DB::Part->new_assortment( partnumber => 'as1', |
|
52 |
description => 'assortment', |
|
53 |
sellprice => '0', |
|
54 |
unit => $unit->name); |
|
55 |
$assortment_1 = SL::DB::AssortmentItem->new( parts_id => $part1->id, qty => 3, unit => $part1->unit, position => 1); |
|
56 |
$assortment_2 = SL::DB::AssortmentItem->new( parts_id => $part2->id, qty => 3, unit => $part2->unit, position => 2); |
|
59 | 57 |
$assortment_part->add_assortment_items($assortment_1, $assortment_2); |
60 | 58 |
$assortment_part->save or die "Couldn't save assortment"; |
61 | 59 |
|
Auch abrufbar als: Unified diff
t/part/assortment.t