X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=t%2Fwh%2Ftransfer.t;h=b85cd68ce0d5fcb9911b1071ab0b55d244010a1c;hb=24d1656ebd75cc1125b15b1c9727cae0fb4417d1;hp=94767529c8e61907bab3b44c6e74fac6097df9d7;hpb=e502a43953cea946526bdb4bfcdc7f5ad4d2e3c8;p=kivitendo-erp.git diff --git a/t/wh/transfer.t b/t/wh/transfer.t index 94767529c..b85cd68ce 100644 --- a/t/wh/transfer.t +++ b/t/wh/transfer.t @@ -3,23 +3,45 @@ use Test::More; use lib 't'; +use SL::Dev::Part qw(new_part); + use_ok 'Support::TestSetup'; +use_ok 'SL::DB::Bin'; use_ok 'SL::DB::Part'; use_ok 'SL::DB::Warehouse'; use_ok 'SL::WH'; +use_ok('SL::DB::Inventory'); + +use constant NAME => 'UnitTestObject'; + Support::TestSetup::login(); -my $part = SL::DB::Manager::Part->get_first; -is(ref $part, 'SL::DB::Part', 'loading a part to test with id ' . $part->id); +# Clean up: remove test objects for part, warehouse, bin +my $part = SL::DB::Manager::Part->get_first(partnumber => NAME(), description => NAME()); +if ($part) { + SL::DB::Manager::Inventory->delete_all(where => [ parts_id => $part->id ]); + $part->delete; +} + +SL::DB::Manager::Bin ->delete_all(where => [ or => [ description => NAME() . "1", description => NAME() . "2" ] ]); +SL::DB::Manager::Warehouse->delete_all(where => [ description => NAME() ]); + +# Create test data +$part = new_part(unit => 'mg', description => NAME(), partnumber => NAME())->save(); -my $wh = SL::DB::Manager::Warehouse->get_first; +is(ref($part), 'SL::DB::Part', 'loading a part to test with id ' . $part->id); + +my $wh = SL::DB::Warehouse->new(description => NAME(), invalid => 0); +$wh->save; is(ref $wh, 'SL::DB::Warehouse', 'loading a warehouse to test with id ' . $wh->id); -my $bin1 = $wh->bins->[0]; +my $bin1 = SL::DB::Bin->new(description => NAME() . "1", warehouse_id => $wh->id); +$bin1->save; is(ref $bin1, 'SL::DB::Bin', 'getting first bin to test with id ' . $bin1->id); -my $bin2 = $wh->bins->[1]; +my $bin2 = SL::DB::Bin->new(description => NAME() . "2", warehouse_id => $wh->id); +$bin2->save; is(ref $bin2, 'SL::DB::Bin', 'getting another bin to test with id ' . $bin2->id); my $report = sub { @@ -71,6 +93,20 @@ test { shift->{qty}, shift->{qty} - 4, 'and back' } { chargenumber => '', }; +################################################# + +test {shift->{qty}, shift->{qty} + 4000000000, 'transfer one way with unit'} { + transfer_type => 'transfer', + parts_id => $part->id, + src_warehouse_id => $wh->id, + dst_warehouse_id => $wh->id, + src_bin_id => $bin1->id, + dst_bin_id => $bin2->id, + qty => 4, + unit => 't', + chargenumber => '', +}; + ############################################## use_ok 'SL::DB::TransferType'; @@ -138,6 +174,13 @@ test { shift->{qty}, shift->{qty}, 'warehouse reduced interface' } { }; +SL::DB::Manager::Inventory->delete_objects(where => [parts_id => $part->id]); + +$bin1->delete; +$bin2->delete; +$wh->delete; +$part->delete; + done_testing; 1;