X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9d07c34f5b429bfc118629d74b376479c37a8383..34985df260c95fe165d2e7a762fd2bb13709acf4:/SL/WH.pm diff --git a/SL/WH.pm b/SL/WH.pm index a8c1ae3bf..8ff63f219 100644 --- a/SL/WH.pm +++ b/SL/WH.pm @@ -59,7 +59,7 @@ sub transfer { require SL::DB::Employee; require SL::DB::Inventory; - my $employee = SL::DB::Manager::Employee->find_by(login => $::form->{login}); + my $employee = SL::DB::Manager::Employee->find_by(login => $::myconfig{login}); my ($now) = selectrow_query($::form, $::form->get_standard_dbh, qq|SELECT current_date|); my @directions = (undef, qw(out in transfer)); @@ -137,9 +137,7 @@ sub transfer { )->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})); + $part->update_attributes(warehouse_id => $dst_wh->id, bin_id => $dst_bin->id); } } @@ -410,6 +408,7 @@ sub get_warehouse_journal { "trans_type" => "tt.description", "trans_id" => "i1.trans_id", "oe_id" => "COALESCE(i1.oe_id, i2.oe_id)", + "invoice_id" => "COALESCE(i1.invoice_id, i2.invoice_id)", "date" => "i1.itime::DATE", "itime" => "i1.itime", "employee" => "e.name", @@ -426,6 +425,8 @@ sub get_warehouse_journal { "warehouse_from" => "'$filter{na}'", }; + $form->{l_invoice_id} = $form->{l_oe_id} if $form->{l_oe_id}; + # build the select clauses. # take all the requested ones from the first hash and overwrite them from the out/in hashes if present. for my $i ('trans', 'out', 'in') { @@ -525,6 +526,18 @@ sub get_warehouse_journal { SELECT ap.id AS id, ap.invnumber AS number, 'purchase_invoice' AS type FROM ap WHERE ap.id = ? + + UNION + + SELECT ar.id AS id, ar.invnumber AS number, 'sales_invoice' AS type + FROM ar + WHERE ar.id = (SELECT trans_id FROM invoice WHERE id = ?) + + UNION + + SELECT ap.id AS id, ap.invnumber AS number, 'purchase_invoice' AS type + FROM ap + WHERE ap.id = (SELECT trans_id FROM invoice WHERE id = ?) SQL $h_oe_id = prepare_query($form, $dbh, $q_oe_id); } @@ -545,8 +558,9 @@ SQL next if (('<=' eq $f_qty_op) && ($qty > $f_qty)); } - if ($h_oe_id && $ref->{oe_id}) { - do_statement($form, $h_oe_id, $q_oe_id, ($ref->{oe_id}) x 4); + if ($h_oe_id && ($ref->{oe_id} || $ref->{invoice_id})) { + my $id = $ref->{oe_id} ? $ref->{oe_id} : $ref->{invoice_id}; + do_statement($form, $h_oe_id, $q_oe_id, ($id) x 6); $ref->{oe_id_info} = $h_oe_id->fetchrow_hashref() || {}; } @@ -962,7 +976,7 @@ $main::lxdebug->enter_sub(); 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}){ + if (($ref->{chargenumber} || $ref->{bestbefore}) && $ref->{sum} != 0){ $error=1; } }