198 |
198 |
my %params = @_;
|
199 |
199 |
Common::check_params(\%params, qw(assembly_id dst_warehouse_id login qty unit dst_bin_id chargenumber bestbefore comment));
|
200 |
200 |
|
201 |
|
# my $maxcreate=WH->check_assembly_max_create(assembly_id =>$params{'assembly_id'}, dbh => $my_dbh);
|
202 |
|
|
203 |
201 |
my $myconfig = \%main::myconfig;
|
204 |
202 |
my $form = $main::form;
|
205 |
203 |
my $kannNichtFertigen =""; # Falls leer dann erfolgreich
|
... | ... | |
234 |
232 |
|
235 |
233 |
my $sth_part_qty_assembly = prepare_execute_query($form, $dbh, $query, $params{assembly_id});
|
236 |
234 |
|
|
235 |
my @trans_ids;
|
|
236 |
my $query_trans_id = qq|SELECT nextval('inventory_id_seq')|;
|
|
237 |
my $query_trans_ids = qq|INSERT INTO assembly_inventory_part (inventory_assembly_id, inventory_part_id) VALUES (?, ?)|;
|
|
238 |
my $sth_query_trans_ids = prepare_query($form, $dbh, $query_trans_ids);
|
|
239 |
|
237 |
240 |
# Hier wird das prepared Statement für die Schleife über alle Lagerplätze vorbereitet
|
238 |
241 |
my $transferPartSQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, bestbefore, comment, employee_id, qty,
|
239 |
|
trans_id, trans_type_id, shippingdate)
|
240 |
|
VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
|
|
242 |
trans_id, id, trans_type_id, shippingdate)
|
|
243 |
VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), ?,
|
241 |
244 |
(SELECT id FROM transfer_type WHERE direction = 'out' AND description = 'used'),
|
242 |
245 |
(SELECT current_date))|;
|
243 |
246 |
my $sthTransferPartSQL = prepare_query($form, $dbh, $transferPartSQL);
|
... | ... | |
278 |
281 |
my $temppart_bestbefore = localtime();
|
279 |
282 |
my $temppart_qty = $partsQTY * -1;
|
280 |
283 |
|
|
284 |
my ($trans_id) = selectrow_query($form, $dbh, $query_trans_id);
|
|
285 |
push @trans_ids, $trans_id;
|
281 |
286 |
do_statement($form, $sthTransferPartSQL, $transferPartSQL, $currentPart_ID, $currentPart_WH_ID,
|
282 |
287 |
$temppart_bin_id, $temppart_chargenumber, $temppart_bestbefore, 'Verbraucht für ' .
|
283 |
|
$self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty);
|
|
288 |
$self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty,
|
|
289 |
$trans_id);
|
284 |
290 |
next;
|
285 |
291 |
}
|
286 |
292 |
# Überprüfen, ob diese Anzahl gefertigt werden kann
|
... | ... | |
325 |
331 |
# wenn * -1 als berechnung in der parameter-übergabe angegeben wird.
|
326 |
332 |
# Dieser Wert IST und BLEIBT positiv!! Hilfe.
|
327 |
333 |
# Liegt das daran, dass dieser Wert aus einem SQL-Statement stammt?
|
|
334 |
my ($trans_id) = selectrow_query($form, $dbh, $query_trans_id);
|
|
335 |
push @trans_ids, $trans_id;
|
328 |
336 |
do_statement($form, $sthTransferPartSQL, $transferPartSQL, $currentPart_ID, $currentPart_WH_ID,
|
329 |
337 |
$temppart_bin_id, $temppart_chargenumber, $temppart_bestbefore, 'Verbraucht für ' .
|
330 |
|
$self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty);
|
|
338 |
$self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty, $trans_id);
|
331 |
339 |
|
332 |
340 |
# hier ist noch ein fehler am besten mit definierten erzeugnissen debuggen 02/2009 jb
|
333 |
341 |
# idee: ausbuch algorithmus mit rekursion lösen und an- und abschaltbar machen
|
... | ... | |
335 |
343 |
# auf jeden fall war der internal-server-error nach aktivierung von strict und warnings plus ein paar my-definitionen weg
|
336 |
344 |
} else { # okay, wir haben weniger oder gleich Waren die wir wegbuchen müssen, wir können also aufhören
|
337 |
345 |
$tmpPartsQTY *=-1;
|
|
346 |
my ($trans_id) = selectrow_query($form, $dbh, $query_trans_id);
|
|
347 |
push @trans_ids, $trans_id;
|
338 |
348 |
do_statement($form, $sthTransferPartSQL, $transferPartSQL, $currentPart_ID, $currentPart_WH_ID,
|
339 |
349 |
$temppart_bin_id, $temppart_chargenumber, $temppart_bestbefore, 'Verbraucht für ' .
|
340 |
|
$self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $tmpPartsQTY);
|
|
350 |
$self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $tmpPartsQTY, $trans_id);
|
341 |
351 |
last; # beendet die schleife (springt zum letzten element)
|
342 |
352 |
}
|
343 |
353 |
} # ende while SELECT SUM(qty), bin_id, chargenumber, bestbefore FROM inventory WHERE warehouse_id
|
... | ... | |
354 |
364 |
|
355 |
365 |
# soweit alles gut. Jetzt noch die wirkliche Lagerbewegung für das Erzeugnis ausführen ...
|
356 |
366 |
my $transferAssemblySQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, bestbefore,
|
357 |
|
comment, employee_id, qty, trans_id, trans_type_id, shippingdate)
|
358 |
|
VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
|
|
367 |
comment, employee_id, qty, trans_id, id, trans_type_id, shippingdate)
|
|
368 |
VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), ?,
|
359 |
369 |
(SELECT id FROM transfer_type WHERE direction = 'in' AND description = 'assembled'),
|
360 |
370 |
(select current_date))|;
|
361 |
371 |
my $sthTransferAssemblySQL = prepare_query($form, $dbh, $transferAssemblySQL);
|
|
372 |
my ($assembly_trans_id) = selectrow_query($form, $dbh, $query_trans_id);
|
362 |
373 |
do_statement($form, $sthTransferAssemblySQL, $transferAssemblySQL, $params{assembly_id}, $params{dst_warehouse_id},
|
363 |
|
$params{dst_bin_id}, $params{chargenumber}, conv_date($params{bestbefore}), $params{comment}, $params{login}, $params{qty});
|
|
374 |
$params{dst_bin_id}, $params{chargenumber}, conv_date($params{bestbefore}), $params{comment}, $params{login}, $params{qty}, $assembly_trans_id);
|
|
375 |
|
|
376 |
# save inventory transactions for this assembly
|
|
377 |
for my $part_id (@trans_ids) {
|
|
378 |
do_statement($form, $sth_query_trans_ids, $query_trans_ids, $assembly_trans_id, $part_id);
|
|
379 |
}
|
|
380 |
|
364 |
381 |
1;
|
365 |
382 |
}) or do { return $kannNichtFertigen };
|
366 |
383 |
|
Erzeugnis fertigen -> Zustand in Hilfstabelle dokumentieren