X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FWH.pm;h=3087dfff4ade3b06f213b3776af03a8fedcf67a0;hb=35d63a9fdee45777535d7ec815bfbc76c5c1bdc9;hp=f760f5e9b36ad7fb9b4abc465fb9141394bb2f90;hpb=565b41f3b09495c750cb4a6402f446ea63cef4cd;p=kivitendo-erp.git diff --git a/SL/WH.pm b/SL/WH.pm index f760f5e9b..3087dfff4 100644 --- a/SL/WH.pm +++ b/SL/WH.pm @@ -111,10 +111,11 @@ 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} ||= ''; + if ($direction & 1) { SL::DB::Inventory->new( %params, @@ -131,7 +132,13 @@ sub transfer { bin => $dst_bin->id, qty => $qty, )->save; - } + # Standardlagerplatz in Stammdaten gleich mitverschieben + if (defined($transfer->{change_default_bin})){ + my $part = SL::DB::Part->new(id => conv_i($transfer->{parts_id}))->load; + $part->update_attributes(warehouse_id => conv_i($transfer->{dst_warehouse_id})); + $part->update_attributes(bin_id => conv_i($transfer->{dst_bin_id})); + } + } push @trans_ids, $trans_id; } @@ -624,6 +631,9 @@ sub get_warehouse_report { push @filter_ary, "i.itime <= ?"; push @filter_vars, $filter{date}; } + if (!$filter{include_invalid_warehouses}){ + push @filter_ary, "NOT (w.invalid)"; + } # prepare qty comparison for later filtering my ($f_qty_op, $f_qty, $f_qty_base_unit); @@ -904,7 +914,50 @@ $main::lxdebug->enter_sub(); return $part_description; } +# +# Eingabe: Teilenummer, Lagerplatz_Id (bin_id) +# Ausgabe: Die maximale Anzahl der Teile in diesem Lagerplatz +# Bzw. Fehler, falls Chargen oder bestbefore +# bei eingelagerten Teilen definiert sind. +# +sub get_max_qty_parts_bin { +$main::lxdebug->enter_sub(); + + my $self = shift; + my %params = @_; + + Common::check_params(\%params, qw(parts_id bin_id)); #die brauchen wir + + my $myconfig = \%main::myconfig; + my $form = $main::form; + my $dbh = $params{dbh} || $form->get_standard_dbh(); + + my $query = qq| SELECT SUM(qty), chargenumber, bestbefore FROM inventory where parts_id = ? + AND bin_id = ? GROUP BY chargenumber, bestbefore|; + + my $sth_QTY = prepare_execute_query($form, $dbh, $query, ,$params{parts_id}, $params{bin_id}); #info: aufruf an DBUtils.pm + + my $max_qty_parts = 0; #Initialisierung mit 0 + # falls derselbe artikel mehrmals eingelagert ist + # chargennummer, muss entsprechend händisch agiert werden + my $i = 0; + my $error; + while (my $ref = $sth_QTY->fetchrow_hashref()) { # wir laufen über alle Haltbarkeiten und Chargen(s.a. SQL-Query oben) + $max_qty_parts += $ref->{sum}; + $i++; + if ($ref->{chargenumber} || $ref->{bestbefore}){ + $error=1; + } + } + #if ($i < 1){ + # $error = 2; + #} + + $main::lxdebug->leave_sub(); + + return ($max_qty_parts, $error); +} 1; @@ -1018,6 +1071,8 @@ An expiration date. Note that this is not by default used by C =head1 BUGS +None yet. + =head1 AUTHOR =cut