Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5891326b

Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt

  • ID 5891326b4712cbcc30a6fe6c6f61016c28158121
  • Vorgänger aec44e98
  • Nachfolger 70210440

DispositionManager: Tests angepasst

Unterschiede anzeigen:

t/controllers/disposition_manager/disposition_manager.t
1 1
use strict;
2
use Test::More tests => 9;
2
use Test::More tests => 16;
3 3

  
4 4
use lib 't';
5 5
use Support::TestSetup;
......
8 8
use SL::DB::Inventory;
9 9
use SL::DB::MakeModel;
10 10
use SL::DB::PurchaseBasketItem;
11
use SL::DB::Order;
11 12
use SL::Controller::DispositionManager;
12 13
use DateTime;
13 14
use Data::Dumper;
......
40 41
  description  => 'Testpart 2 norop',
41 42
  rop          => 60,
42 43
  order_qty    => 2,
44
  makemodels   => [ _create_makemodel_for_vendor(vendor => $vendor) ],
43 45
)->save;
44 46
set_stock(part => $part2, bin_id => $bin->id, qty => 80);
45 47

  
......
84 86
my $purchase_basket_items = SL::DB::Manager::PurchaseBasketItem->get_all;
85 87
$::form = Support::TestSetup->create_new_form;
86 88
$::form->{ids}        = [ map { $_->id       } @{ $purchase_basket_items } ];
89
$::form->{basket_ids} = [ map { $_->id       } @{ $purchase_basket_items } ];
87 90
$::form->{vendor_ids} = [ map { $vendor->id  } @{ $purchase_basket_items } ];
88 91

  
89 92
open($outputFH, '>', \$output) or die;
90 93
$oldFH = select $outputFH;
91
$controller->action_transfer_to_purchase_order;
94
my $ret = $controller->action_transfer_to_purchase_order;
92 95
select $oldFH;
93 96
close $outputFH;
97
is($ret, 1, "action_transfer_to_purchase_order ok");
98

  
99
my @basket_item_ids = map { $_->id } @{ $purchase_basket_items } ;
100
my $purchase_order = SL::DB::Order->create_from_purchase_basket(
101
  \@basket_item_ids, [], $vendor->id
102
);
103
$purchase_order->save;
94 104

  
95 105
is(SL::DB::Manager::Order->get_all_count( where => [ SL::DB::Manager::Order->type_filter('purchase_order') ] ), 1, "1 purchase order created ok");
96 106
is(SL::DB::Manager::PurchaseBasketItem->get_all_count(), 0, "purchase basket empty after purchase order was created");
97 107

  
98
my $purchase_order = SL::DB::Manager::Order->get_first();
99

  
100 108
is( scalar @{$purchase_order->items}, 5, "Purchase order has 5 item ok");
101
# print "PART\n";
102
# print Dumper($part1);
103 109
my $first_item = $purchase_order->items_sorted->[0];
104
# print "FIRST\n";
105
# print Dumper($first_item);
106 110
is( $first_item->parts_id, $part1->id, "Purchase order: first item is part1");
107 111
is( $first_item->qty, '20.00000', "Purchase order: first item has qty 20");
108 112
cmp_ok( $purchase_order->netamount, '==', 240, "Purchase order: netamount ok");
109 113
is( $first_item->active_price_source, 'makemodel/' . $part1->makemodels->[0]->id, "Purchase order: first item has correct active_price_source" . $first_item->part->partnumber);
110 114

  
115

  
116
my @vendor_item_ids = ( $part1->id, $part2->id );
117

  
118
my $purchase_order2 = SL::DB::Order->create_from_purchase_basket(
119
  [], \@vendor_item_ids, $vendor->id
120
);
121

  
122
is( scalar @{$purchase_order2->items}, 2, "Purchase order 2 has 2 item ok");
123
my $item_1 = $purchase_order2->items_sorted->[0];
124
is( $item_1->parts_id, $part1->id, "Purchase order 2: first item is part1");
125
my $item_2 = $purchase_order2->items_sorted->[1];
126
is( $item_2->parts_id, $part2->id, "Purchase order 2: secound item is part2");
127
is( $item_1->qty, '1.00000', "Purchase order 2: first item has qty 1");
128
is( $item_2->qty, '2.00000', "Purchase order 2: secound item has qty 2");
129
is( $item_1->active_price_source, 'makemodel/' . $part1->makemodels->[0]->id, "Purchase order 2: first item has correct active_price_source" . $first_item->part->partnumber);
130

  
111 131
clear_up();
112 132
done_testing();
113 133

  

Auch abrufbar als: Unified diff