Revision 17409513
Von Moritz Bunkus vor etwa 15 Jahren hinzugefügt
SL/WH.pm | ||
---|---|---|
158 | 158 |
|
159 | 159 |
# Hier wird das prepared Statement für die Schleife über alle Lagerplätze vorbereitet |
160 | 160 |
my $transferPartSQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, comment, employee_id, qty, trans_id, trans_type_id) |
161 |
VALUES (?, ?, ?, ?, ?,(SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
|
|
161 |
VALUES (?, ?, ?, ?, ?,(SELECT id FROM employee WHERE login = ?), ?, nextval('id'), |
|
162 | 162 |
(SELECT id FROM transfer_type WHERE direction = 'out' AND description = 'used'))|; |
163 | 163 |
my $sthTransferPartSQL = prepare_query($form, $dbh, $transferPartSQL); |
164 | 164 |
|
165 | 165 |
my $kannNichtFertigen =""; # der return-string für die fehlermeldung inkl. welche waren zum fertigen noch fehlen |
166 | 166 |
|
167 |
while (my $hash_ref = $sth_part_qty_assembly->fetchrow_hashref()) { # Schleife für $query=select parts_id,qty from assembly
|
|
167 |
while (my $hash_ref = $sth_part_qty_assembly->fetchrow_hashref()) { # Schleife für $query=select parts_id,qty from assembly |
|
168 | 168 |
|
169 | 169 |
my $partsQTY = $hash_ref->{qty} * $params{qty}; # benötigte teile * anzahl erzeugnisse |
170 | 170 |
my $currentPart_ID = $hash_ref->{parts_id}; |
... | ... | |
215 | 215 |
return $kannNichtFertigen; |
216 | 216 |
} |
217 | 217 |
|
218 |
# soweit alles gut. Jetzt noch die wirkliche Lagerbewegung für das Erzeugnis ausführen ...
|
|
218 |
# soweit alles gut. Jetzt noch die wirkliche Lagerbewegung für das Erzeugnis ausführen ... |
|
219 | 219 |
my $transferAssemblySQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, comment, employee_id, qty, trans_id, trans_type_id) |
220 |
VALUES (?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
|
|
220 |
VALUES (?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), |
|
221 | 221 |
(SELECT id FROM transfer_type WHERE direction = 'in' AND description = 'stock'))|; |
222 | 222 |
my $sthTransferAssemblySQL = prepare_query($form, $dbh, $transferAssemblySQL); |
223 | 223 |
do_statement($form, $sthTransferAssemblySQL, $transferAssemblySQL, $params{assembly_id}, $params{dst_warehouse_id}, $params{dst_bin_id}, $params{chargenumber}, $params{comment}, $params{login}, $params{qty}); |
... | ... | |
328 | 328 |
"comment" => "i1.comment", |
329 | 329 |
"trans_type" => "tt.description", |
330 | 330 |
"trans_id" => "i1.trans_id", |
331 |
"oe_id" => "COALESCE(i1.oe_id, i2.oe_id)", |
|
331 | 332 |
"date" => "i1.itime::DATE", |
332 | 333 |
"itime" => "i1.itime", |
333 | 334 |
"employee" => "e.name", |
... | ... | |
407 | 408 |
|
408 | 409 |
my $sth = prepare_execute_query($form, $dbh, $query, @filter_vars, @filter_vars, @filter_vars); |
409 | 410 |
|
411 |
my ($h_oe_id, $q_oe_id); |
|
412 |
if ($form->{l_oe_id}) { |
|
413 |
$q_oe_id = <<SQL; |
|
414 |
SELECT oe.id AS id, |
|
415 |
CASE WHEN oe.quotation THEN oe.quonumber ELSE oe.ordnumber END AS number, |
|
416 |
CASE |
|
417 |
WHEN oe.customer_id IS NOT NULL AND COALESCE(oe.quotation, FALSE) THEN 'sales_quotation' |
|
418 |
WHEN oe.customer_id IS NOT NULL AND NOT COALESCE(oe.quotation, FALSE) THEN 'sales_order' |
|
419 |
WHEN oe.customer_id IS NULL AND COALESCE(oe.quotation, FALSE) THEN 'request_quotation' |
|
420 |
ELSE 'purchase_order' |
|
421 |
END AS type |
|
422 |
FROM oe |
|
423 |
WHERE oe.id = ? |
|
424 |
|
|
425 |
UNION |
|
426 |
|
|
427 |
SELECT dord.id AS id, dord.donumber AS number, |
|
428 |
CASE |
|
429 |
WHEN dord.customer_id IS NULL THEN 'purchase_delivery_order' |
|
430 |
ELSE 'sales_delivery_order' |
|
431 |
END AS type |
|
432 |
FROM delivery_orders dord |
|
433 |
WHERE dord.id = ? |
|
434 |
|
|
435 |
UNION |
|
436 |
|
|
437 |
SELECT ar.id AS id, ar.invnumber AS number, 'sales_invoice' AS type |
|
438 |
FROM ar |
|
439 |
WHERE ar.id = ? |
|
440 |
|
|
441 |
UNION |
|
442 |
|
|
443 |
SELECT ap.id AS id, ap.invnumber AS number, 'purchase_invoice' AS type |
|
444 |
FROM ap |
|
445 |
WHERE ap.id = ? |
|
446 |
SQL |
|
447 |
$h_oe_id = prepare_query($form, $dbh, $q_oe_id); |
|
448 |
} |
|
449 |
|
|
410 | 450 |
my @contents = (); |
411 | 451 |
while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { |
412 | 452 |
map { /^r_/; $ref->{"$'"} = $ref->{$_} } keys %$ref; |
... | ... | |
423 | 463 |
next if (('<=' eq $f_qty_op) && ($qty > $f_qty)); |
424 | 464 |
} |
425 | 465 |
|
466 |
if ($h_oe_id && $ref->{oe_id}) { |
|
467 |
do_statement($form, $h_oe_id, $q_oe_id, ($ref->{oe_id}) x 4); |
|
468 |
$ref->{oe_id_info} = $h_oe_id->fetchrow_hashref() || {}; |
|
469 |
} |
|
470 |
|
|
426 | 471 |
push @contents, $ref; |
427 | 472 |
} |
428 | 473 |
|
429 | 474 |
$sth->finish(); |
475 |
$h_oe_id->finish() if $h_oe_id; |
|
430 | 476 |
|
431 | 477 |
$main::lxdebug->leave_sub(); |
432 | 478 |
|
... | ... | |
732 | 778 |
my $self = shift; |
733 | 779 |
my %params = @_; |
734 | 780 |
|
735 |
Common::check_params(\%params, qw(parts_id warehouse_id)); #die brauchen wir
|
|
781 |
Common::check_params(\%params, qw(parts_id warehouse_id)); #die brauchen wir |
|
736 | 782 |
|
737 | 783 |
my $myconfig = \%main::myconfig; |
738 | 784 |
my $form = $main::form; |
... | ... | |
742 | 788 |
my $query = qq| SELECT SUM(qty), bin_id, chargenumber FROM inventory where parts_id = ? AND warehouse_id = ? GROUP BY bin_id, chargenumber|; |
743 | 789 |
|
744 | 790 |
my $sth_QTY = prepare_execute_query($form, $dbh, $query, ,$params{parts_id}, $params{warehouse_id}); #info: aufruf an DBUtils.pm |
745 |
|
|
791 |
|
|
746 | 792 |
my $max_qty_parts = 0; #Initialisierung mit 0 |
747 | 793 |
while (my $ref = $sth_QTY->fetchrow_hashref()) { # wir laufen über alle chargen und Lagerorte (s.a. SQL-Query oben) |
748 |
$max_qty_parts += $ref->{sum};
|
|
794 |
$max_qty_parts += $ref->{sum}; |
|
749 | 795 |
} |
750 | 796 |
|
751 | 797 |
$main::lxdebug->leave_sub(); |
... | ... | |
763 | 809 |
my $self = shift; |
764 | 810 |
my %params = @_; |
765 | 811 |
|
766 |
Common::check_params(\%params, qw(parts_id )); #die brauchen wir
|
|
812 |
Common::check_params(\%params, qw(parts_id )); #die brauchen wir |
|
767 | 813 |
|
768 | 814 |
my $myconfig = \%main::myconfig; |
769 | 815 |
my $form = $main::form; |
... | ... | |
773 | 819 |
my $query = qq| SELECT partnumber, description FROM parts where id = ? |; |
774 | 820 |
|
775 | 821 |
my $sth = prepare_execute_query($form, $dbh, $query, ,$params{parts_id}); #info: aufruf zu DBUtils.pm |
776 |
|
|
777 |
my $ref = $sth->fetchrow_hashref();
|
|
778 |
my $part_description = $ref->{partnumber} . " " . $ref->{description};
|
|
822 |
|
|
823 |
my $ref = $sth->fetchrow_hashref(); |
|
824 |
my $part_description = $ref->{partnumber} . " " . $ref->{description}; |
|
779 | 825 |
|
780 | 826 |
$main::lxdebug->leave_sub(); |
781 | 827 |
|
Auch abrufbar als: Unified diff
Anzeige einer Spalte "Dokument" im Lagerbewegungsbericht mit Verlinkung auf den Beleg, von dem aus Waren ein-/ausgelagert wurden.
Ist nur mit Lieferscheinen getestet, weil bisher nur von
Lieferscheinen aus direkt ein-/ausgelagert werden kann, aber der
Mechanismus ist bereits für alle Verkaufs- und Einkaufsbelege
implementiert.
Fix für Bug 1058.