6 use_ok 'Support::TestSetup';
8 use_ok 'SL::DB::Warehouse';
11 Support::TestSetup::login();
13 my $part = SL::DB::Manager::Part->get_first;
14 is(ref $part, 'SL::DB::Part', 'loading a part to test with id ' . $part->id);
16 my $wh = SL::DB::Manager::Warehouse->get_first;
17 is(ref $wh, 'SL::DB::Warehouse', 'loading a warehouse to test with id ' . $wh->id);
19 my $bin1 = $wh->bins->[0];
20 is(ref $bin1, 'SL::DB::Bin', 'getting first bin to test with id ' . $bin1->id);
22 my $bin2 = $wh->bins->[1];
23 is(ref $bin2, 'SL::DB::Bin', 'getting another bin to test with id ' . $bin2->id);
26 $::form->{l_warehouseid} = 'Y';
27 $::form->{l_binid} = 'Y';
28 my ($result) = WH->get_warehouse_report(
29 warehouse_id => $wh->id,
39 my ($arg_sub, @transfers) = @_;
40 my $before = $report->();
42 WH->transfer(@transfers);
44 my $after = $report->();
45 my @args = $arg_sub->($before, $after);
47 is $args[0], $args[1], $args[2];
50 test { shift->{qty}, shift->{qty} + 4, 'transfer one way' } {
51 transfer_type => 'transfer',
52 parts_id => $part->id,
53 src_warehouse_id => $wh->id,
54 dst_warehouse_id => $wh->id,
55 src_bin_id => $bin1->id,
56 dst_bin_id => $bin2->id,
61 #################################################
63 test { shift->{qty}, shift->{qty} - 4, 'and back' } {
64 transfer_type => 'transfer',
65 parts_id => $part->id,
66 src_warehouse_id => $wh->id,
67 dst_warehouse_id => $wh->id,
68 src_bin_id => $bin2->id,
69 dst_bin_id => $bin1->id,
74 ##############################################
76 use_ok 'SL::DB::TransferType';
78 # object interface test
80 test { shift->{qty}, shift->{qty} + 6.2, 'object transfer one way' } {
81 transfer_type => SL::DB::Manager::TransferType->find_by(description => 'transfer'),
89 #############################################
91 test { shift->{qty}, shift->{qty} - 6.2, 'full object transfer back' } {
92 transfer_type => SL::DB::Manager::TransferType->find_by(description => 'transfer'),
102 #############################################
104 test { shift->{qty}, shift->{qty}, 'back and forth in one transaction' } {
105 transfer_type => SL::DB::Manager::TransferType->find_by(description => 'transfer'),
108 src_warehouse => $wh,
110 dst_warehouse => $wh,
114 transfer_type => SL::DB::Manager::TransferType->find_by(description => 'transfer'),
117 src_warehouse => $wh,
119 dst_warehouse => $wh,
123 #############################################
125 test { shift->{qty}, shift->{qty}, 'warehouse reduced interface' } {
126 transfer_type => SL::DB::Manager::TransferType->find_by(description => 'transfer'),
133 transfer_type => SL::DB::Manager::TransferType->find_by(description => 'transfer'),