Revision 639c7f18
Von Martin Helmling vor mehr als 3 Jahren hinzugefügt
SL/WH.pm | ||
---|---|---|
239 | 239 |
|
240 | 240 |
# Hier wird das prepared Statement für die Schleife über alle Lagerplätze vorbereitet |
241 | 241 |
my $transferPartSQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, bestbefore, comment, employee_id, qty, |
242 |
trans_id, id, trans_type_id, shippingdate)
|
|
243 |
VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), ?,
|
|
242 |
trans_id, trans_type_id, shippingdate) |
|
243 |
VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, ?, |
|
244 | 244 |
(SELECT id FROM transfer_type WHERE direction = 'out' AND description = 'used'), |
245 | 245 |
(SELECT current_date))|; |
246 | 246 |
my $sthTransferPartSQL = prepare_query($form, $dbh, $transferPartSQL); |
247 |
my $trans_id; |
|
247 | 248 |
|
248 | 249 |
# der return-string für die fehlermeldung inkl. welche waren zum fertigen noch fehlen |
249 | 250 |
|
... | ... | |
280 | 281 |
my $temppart_chargenumber = ""; |
281 | 282 |
my $temppart_bestbefore = localtime(); |
282 | 283 |
my $temppart_qty = $partsQTY * -1; |
284 |
($trans_id) = selectrow_query($form, $dbh, qq|SELECT nextval('id')| ) unless $trans_id; |
|
283 | 285 |
|
284 | 286 |
my ($trans_id) = selectrow_query($form, $dbh, $query_trans_id); |
285 | 287 |
push @trans_ids, $trans_id; |
286 | 288 |
do_statement($form, $sthTransferPartSQL, $transferPartSQL, $currentPart_ID, $currentPart_WH_ID, |
287 | 289 |
$temppart_bin_id, $temppart_chargenumber, $temppart_bestbefore, 'Verbraucht für ' . |
288 |
$self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty, |
|
289 |
$trans_id); |
|
290 |
$self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty, $trans_id); |
|
290 | 291 |
next; |
291 | 292 |
} |
292 | 293 |
# Überprüfen, ob diese Anzahl gefertigt werden kann |
... | ... | |
324 | 325 |
my $temppart_bestbefore = conv_date($temphash_ref->{bestbefore}); |
325 | 326 |
my $temppart_qty = $temphash_ref->{sum}; |
326 | 327 |
|
328 |
($trans_id) = selectrow_query($form, $dbh, qq|SELECT nextval('id')| ) unless $trans_id; |
|
327 | 329 |
if ($tmpPartsQTY > $temppart_qty) { # wir haben noch mehr waren zum wegbuchen. |
328 | 330 |
# Wir buchen den kompletten Lagerplatzbestand und zählen die Hilfsvariable runter |
329 | 331 |
$tmpPartsQTY = $tmpPartsQTY - $temppart_qty; |
... | ... | |
357 | 359 |
# keine einzelteile definiert |
358 | 360 |
$kannNichtFertigen ="Für dieses Erzeugnis sind keine Einzelteile definiert. |
359 | 361 |
Dementsprechend kann auch nichts hergestellt werden"; |
360 |
} |
|
362 |
}
|
|
361 | 363 |
# gibt die Fehlermeldung zurück. A.) Keine Teile definiert |
362 | 364 |
# B.) Artikel und Anzahl der fehlenden Teile/Dienstleistungen |
363 | 365 |
die "<br><br>" . $kannNichtFertigen if ($kannNichtFertigen); |
364 | 366 |
|
365 | 367 |
# soweit alles gut. Jetzt noch die wirkliche Lagerbewegung für das Erzeugnis ausführen ... |
368 |
($trans_id) = selectrow_query($form, $dbh, qq|SELECT nextval('id')| ) unless $trans_id; |
|
366 | 369 |
my $transferAssemblySQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, bestbefore, |
367 |
comment, employee_id, qty, trans_id, id, trans_type_id, shippingdate)
|
|
368 |
VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), ?,
|
|
370 |
comment, employee_id, qty, trans_id, trans_type_id, shippingdate) |
|
371 |
VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, ?, |
|
369 | 372 |
(SELECT id FROM transfer_type WHERE direction = 'in' AND description = 'assembled'), |
370 | 373 |
(select current_date))|; |
371 | 374 |
my $sthTransferAssemblySQL = prepare_query($form, $dbh, $transferAssemblySQL); |
372 |
my ($assembly_trans_id) = selectrow_query($form, $dbh, $query_trans_id); |
|
373 | 375 |
do_statement($form, $sthTransferAssemblySQL, $transferAssemblySQL, $params{assembly_id}, $params{dst_warehouse_id}, |
374 |
$params{dst_bin_id}, $params{chargenumber}, conv_date($params{bestbefore}), $params{comment}, $params{login}, $params{qty}, $assembly_trans_id);
|
|
376 |
$params{dst_bin_id}, $params{chargenumber}, conv_date($params{bestbefore}), $params{comment}, $params{login}, $params{qty}, $trans_id); |
|
375 | 377 |
|
376 | 378 |
# save inventory transactions for this assembly |
377 | 379 |
for my $part_id (@trans_ids) { |
378 |
do_statement($form, $sth_query_trans_ids, $query_trans_ids, $assembly_trans_id, $part_id);
|
|
380 |
do_statement($form, $sth_query_trans_ids, $query_trans_ids, $trans_id, $part_id); |
|
379 | 381 |
} |
380 | 382 |
|
381 | 383 |
1; |
... | ... | |
587 | 589 |
LEFT JOIN project pr ON i1.project_id = pr.id |
588 | 590 |
LEFT JOIN employee e ON i1.employee_id = e.id |
589 | 591 |
WHERE $where_clause i1.qty < 0 AND |
590 |
i1.trans_id IN ( SELECT i.trans_id FROM inventory i GROUP BY i.trans_id HAVING COUNT(i.trans_id) = 1 ) |
|
592 |
i1.trans_id IN ( SELECT i.trans_id FROM inventory i GROUP BY i.trans_id HAVING COUNT(i.trans_id) >= 1 )
|
|
591 | 593 |
GROUP BY $group_clause |
592 | 594 |
|
593 | 595 |
UNION |
... | ... | |
604 | 606 |
LEFT JOIN project pr ON i1.project_id = pr.id |
605 | 607 |
LEFT JOIN employee e ON i1.employee_id = e.id |
606 | 608 |
WHERE $where_clause i1.qty > 0 AND |
607 |
i1.trans_id IN ( SELECT i.trans_id FROM inventory i GROUP BY i.trans_id HAVING COUNT(i.trans_id) = 1 ) |
|
609 |
i1.trans_id IN ( SELECT i.trans_id FROM inventory i GROUP BY i.trans_id HAVING COUNT(i.trans_id) >= 1 )
|
|
608 | 610 |
GROUP BY $group_clause |
609 | 611 |
ORDER BY r_${sort_spec}) AS lines WHERE r_qty>0|; |
610 | 612 |
|
Auch abrufbar als: Unified diff
Erzeugnis fertigen: Eindeutige Zuordnung zwischen Lagerentnahme und neuem Erzeugnis
Eindeutige Transid für das Fertigen per SL/WH.pm
Hebt den having count = 1 für den Lagerbuchungs-Bericht auf