Revision 63410aa6
Von Sven Schöling vor mehr als 7 Jahren hinzugefügt
t/part/stock.t | ||
---|---|---|
6 | 6 |
use Carp; |
7 | 7 |
use Test::Exception; |
8 | 8 |
use SL::DB::Part; |
9 |
use SL::Dev::Part; |
|
10 |
use SL::Dev::Inventory; |
|
9 |
use SL::Dev::Part qw(new_part);
|
|
10 |
use SL::Dev::Inventory qw(create_warehouse_and_bins set_stock transfer_stock);
|
|
11 | 11 |
|
12 | 12 |
Support::TestSetup::login(); |
13 | 13 |
|
14 | 14 |
clear_up(); |
15 | 15 |
|
16 |
my ($wh1, $bin1_1) = SL::Dev::Inventory::create_warehouse_and_bins(
|
|
16 |
my ($wh1, $bin1_1) = create_warehouse_and_bins( |
|
17 | 17 |
warehouse_description => 'Testlager', |
18 | 18 |
bin_description => 'Testlagerplatz', |
19 | 19 |
number_of_bins => 2, |
20 | 20 |
); |
21 | 21 |
my $bin1_2 = $wh1->bins->[1]; |
22 |
my ($wh2, $bin2_1) = SL::Dev::Inventory::create_warehouse_and_bins(
|
|
22 |
my ($wh2, $bin2_1) = create_warehouse_and_bins( |
|
23 | 23 |
warehouse_description => 'Testlager 2', |
24 | 24 |
bin_description => 'Testlagerplatz 2', |
25 | 25 |
number_of_bins => 2, |
... | ... | |
28 | 28 |
my $today = DateTime->today; |
29 | 29 |
my $yesterday = $today->clone->add(days => -1); |
30 | 30 |
|
31 |
my $part = SL::Dev::Part::create_part->save;
|
|
32 |
SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_1->id, qty => 7, shippingdate => $yesterday);
|
|
33 |
SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_1->id, qty => 5);
|
|
34 |
SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_1->id, abs_qty => 8); # apply -4 to get qty 8 in bin1_1
|
|
35 |
SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin1_2->id, qty => 9);
|
|
36 |
|
|
37 |
SL::Dev::Inventory::set_stock(part => $part, bin_id => $bin2_1->id, abs_qty => 10);
|
|
38 |
SL::Dev::Inventory::transfer_stock(part => $part,
|
|
39 |
from_bin => $wh2->bins->[0],
|
|
40 |
to_bin => $wh2->bins->[1],
|
|
41 |
qty => 2,
|
|
42 |
);
|
|
31 |
my $part = new_part()->save;
|
|
32 |
set_stock(part => $part, bin_id => $bin1_1->id, qty => 7, shippingdate => $yesterday); |
|
33 |
set_stock(part => $part, bin_id => $bin1_1->id, qty => 5); |
|
34 |
set_stock(part => $part, bin_id => $bin1_1->id, abs_qty => 8); # apply -4 to get qty 8 in bin1_1 |
|
35 |
set_stock(part => $part, bin_id => $bin1_2->id, qty => 9); |
|
36 |
|
|
37 |
set_stock(part => $part, bin_id => $bin2_1->id, abs_qty => 10); |
|
38 |
transfer_stock(part => $part, |
|
39 |
from_bin => $wh2->bins->[0], |
|
40 |
to_bin => $wh2->bins->[1], |
|
41 |
qty => 2, |
|
42 |
); |
|
43 | 43 |
|
44 | 44 |
is( SL::DB::Manager::Part->get_all_count(), 1, "total number of parts created is 1"); |
45 | 45 |
is( $part->get_stock == 27 , 1 , "total stock of part is 27"); |
Auch abrufbar als: Unified diff
Tests: SL::Dev Änderungen übernommen