From d04df1651c1dacc20d309b12a764545129ab10c5 Mon Sep 17 00:00:00 2001 From: Thomas Heck Date: Tue, 11 Sep 2012 17:09:52 +0200 Subject: [PATCH] Bug bei der Umrechnung von Einheiten beim Einlagern behoben. fixt #1983 --- SL/WH.pm | 3 +-- t/wh/transfer.t | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/SL/WH.pm b/SL/WH.pm index 9a0635603..28e836e48 100644 --- a/SL/WH.pm +++ b/SL/WH.pm @@ -111,8 +111,7 @@ sub transfer { ); if ($unit) { - $qty *= $unit->factor || 1; - $qty /= $part->unit_obj->factor || 1 if $part->unit; + $qty = $unit->convert_to($qty, $part->unit_obj); } $params{chargenumber} ||= ''; diff --git a/t/wh/transfer.t b/t/wh/transfer.t index 94767529c..8d88fb178 100644 --- a/t/wh/transfer.t +++ b/t/wh/transfer.t @@ -8,10 +8,16 @@ use_ok 'SL::DB::Part'; use_ok 'SL::DB::Warehouse'; use_ok 'SL::WH'; +use_ok('SL::DB::Inventory'); + + 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); +my $part = SL::DB::Part->new(unit => 'mg', description => 'TestObject'); +$part->save(); + +is(ref($part), 'SL::DB::Part', 'loading a part to test with id ' . $part->id); + my $wh = SL::DB::Manager::Warehouse->get_first; is(ref $wh, 'SL::DB::Warehouse', 'loading a warehouse to test with id ' . $wh->id); @@ -71,6 +77,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 +158,10 @@ test { shift->{qty}, shift->{qty}, 'warehouse reduced interface' } { }; +SL::DB::Manager::Inventory->delete_objects(where => [parts_id => $part->id]); + +$part->delete(); + done_testing; 1; -- 2.20.1