X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FWH.pm;h=97f0a755371c469355b77f45976ac3bb6e0bf75b;hb=0bf92081282bc1cad1d7cec16e55f13ca584ff11;hp=22f4a4195b209217bd5ae687ebd64ab102ed445f;hpb=1b15807093421ca00493a447048b960f2f512152;p=kivitendo-erp.git diff --git a/SL/WH.pm b/SL/WH.pm index 22f4a4195..97f0a7553 100644 --- a/SL/WH.pm +++ b/SL/WH.pm @@ -37,6 +37,7 @@ package WH; use SL::AM; use SL::DBUtils; use SL::Form; +use SL::Util qw(trim); use SL::DB::Unit; use SL::DB::Assembly; @@ -137,9 +138,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); } } @@ -331,32 +330,32 @@ sub get_warehouse_journal { if ($filter{partnumber}) { push @filter_ary, "p.partnumber ILIKE ?"; - push @filter_vars, '%' . $filter{partnumber} . '%'; + push @filter_vars, like($filter{partnumber}); } if ($filter{description}) { push @filter_ary, "(p.description ILIKE ?)"; - push @filter_vars, '%' . $filter{description} . '%'; + push @filter_vars, like($filter{description}); } if ($filter{chargenumber}) { push @filter_ary, "i1.chargenumber ILIKE ?"; - push @filter_vars, '%' . $filter{chargenumber} . '%'; + push @filter_vars, like($filter{chargenumber}); } - if ($form->{bestbefore}) { + if (trim($form->{bestbefore})) { push @filter_ary, "?::DATE = i1.bestbefore::DATE"; - push @filter_vars, $form->{bestbefore}; + push @filter_vars, trim($form->{bestbefore}); } - if ($form->{fromdate}) { - push @filter_ary, "?::DATE <= i1.itime::DATE"; - push @filter_vars, $form->{fromdate}; + if (trim($form->{fromdate})) { + push @filter_ary, "? <= i1.shippingdate"; + push @filter_vars, trim($form->{fromdate}); } - if ($form->{todate}) { - push @filter_ary, "?::DATE >= i1.itime::DATE"; - push @filter_vars, $form->{todate}; + if (trim($form->{todate})) { + push @filter_ary, "? >= i1.shippingdate"; + push @filter_vars, trim($form->{todate}); } if ($form->{l_employee}) { @@ -385,8 +384,8 @@ sub get_warehouse_journal { my $sort_order = $form->{order}; $sort_col = $filter{sort} unless $sort_col; - $sort_order = ($sort_col = 'itime') unless $sort_col; - $sort_col = 'itime' if $sort_col eq 'date'; + $sort_order = ($sort_col = 'shippingdate') unless $sort_col; + $sort_col = 'shippingdate' if $sort_col eq 'date'; $sort_order = $filter{order} unless $sort_order; my $sort_spec = "${sort_col} " . ($sort_order ? " DESC" : " ASC"); @@ -411,8 +410,9 @@ sub get_warehouse_journal { "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", + "date" => "i1.shippingdate", "itime" => "i1.itime", + "shippingdate" => "i1.shippingdate", "employee" => "e.name", "projectnumber" => "COALESCE(pr.projectnumber, '$filter{na}')", }; @@ -433,13 +433,14 @@ sub get_warehouse_journal { # 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') { $select{$i} = join ', ', map { +/^l_/; ($select_tokens{$i}{"$'"} || $select_tokens{'trans'}{"$'"}) . " AS r_$'" } - ( grep( { !/qty$/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form), qw(l_parts_id l_qty l_partunit l_itime) ); + ( grep( { !/qty$/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form), qw(l_parts_id l_qty l_partunit l_shippingdate) ); } my $group_clause = join ", ", map { +/^l_/; "r_$'" } - ( grep( { !/qty$/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form), qw(l_parts_id l_partunit l_itime) ); + ( grep( { !/qty$/ and /^l_/ and $form->{$_} eq 'Y' } keys %$form), qw(l_parts_id l_partunit l_shippingdate) ); $where_clause = defined($where_clause) ? $where_clause : ''; + my $query = qq|SELECT DISTINCT $select{trans} FROM inventory i1 @@ -631,12 +632,12 @@ sub get_warehouse_report { if ($filter{partnumber}) { push @filter_ary, "p.partnumber ILIKE ?"; - push @filter_vars, '%' . $filter{partnumber} . '%'; + push @filter_vars, like($filter{partnumber}); } if ($filter{description}) { push @filter_ary, "p.description ILIKE ?"; - push @filter_vars, '%' . $filter{description} . '%'; + push @filter_vars, like($filter{description}); } if ($filter{partsid}) { @@ -646,22 +647,22 @@ sub get_warehouse_report { if ($filter{chargenumber}) { push @filter_ary, "i.chargenumber ILIKE ?"; - push @filter_vars, '%' . $filter{chargenumber} . '%'; + push @filter_vars, like($filter{chargenumber}); } - if ($form->{bestbefore}) { + if (trim($form->{bestbefore})) { push @filter_ary, "?::DATE = i.bestbefore::DATE"; - push @filter_vars, $form->{bestbefore}; + push @filter_vars, trim($form->{bestbefore}); } if ($filter{ean}) { push @filter_ary, "p.ean ILIKE ?"; - push @filter_vars, '%' . $filter{ean} . '%'; + push @filter_vars, like($filter{ean}); } - if ($filter{date}) { - push @filter_ary, "i.itime <= ?"; - push @filter_vars, $filter{date}; + if (trim($filter{date})) { + push @filter_ary, "i.shippingdate <= ?"; + push @filter_vars, trim($filter{date}); } if (!$filter{include_invalid_warehouses}){ push @filter_ary, "NOT (w.invalid)"; @@ -978,14 +979,10 @@ $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}){ - $error=1; + if (($ref->{chargenumber} || $ref->{bestbefore}) && $ref->{sum} != 0){ + $error = 1; } } - #if ($i < 1){ - # $error = 2; - #} - $main::lxdebug->leave_sub(); return ($max_qty_parts, $error); @@ -1006,7 +1003,7 @@ SL::WH - Warehouse backend =head1 DESCRIPTION -Backend for lx-office warehousing functions. +Backend for kivitendo warehousing functions. =head1 FUNCTIONS @@ -1020,7 +1017,7 @@ is called like this: qty => 12.45, transfer_type => 'transfer', src_warehouse_id => 12, - stc_bin_id => 23, + src_bin_id => 23, dst_warehouse_id => 25, dst_bin_id => 167, });