]> wagnertech.de Git - mfinanz.git/commitdiff
Bug bei der Umrechnung von Einheiten beim Einlagern behoben.
authorThomas Heck <theck@linet-services.de>
Tue, 11 Sep 2012 15:09:52 +0000 (17:09 +0200)
committerThomas Heck <theck@linet-services.de>
Tue, 11 Sep 2012 15:09:52 +0000 (17:09 +0200)
fixt #1983

SL/WH.pm
t/wh/transfer.t

index 9a0635603af2a34e21b1d476d2083f8d96fb81ca..28e836e485cd22b3a7018b93182b004025c2678f 100644 (file)
--- 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} ||= '';
index 94767529c8e61907bab3b44c6e74fac6097df9d7..8d88fb1787355a579d04ea5b505965e4c45a31fb 100644 (file)
@@ -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;