From: Bernd Blessmann Date: Sat, 6 Mar 2010 00:16:11 +0000 (+0100) Subject: Funktionalität für Mindesthaltbarkeitsdatum hinzugefügt. X-Git-Tag: release-2.6.1beta1~10 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=096f9e3e06dc378bcc2f97df58c74cec02b9f7ff;p=kivitendo-erp.git Funktionalität für Mindesthaltbarkeitsdatum hinzugefügt. --- diff --git a/SL/DO.pm b/SL/DO.pm index b5faeae8a..cdb244175 100644 --- a/SL/DO.pm +++ b/SL/DO.pm @@ -258,8 +258,8 @@ sub save { my $h_item = prepare_query($form, $dbh, $q_item); my $q_item_stock = - qq|INSERT INTO delivery_order_items_stock (delivery_order_item_id, qty, unit, warehouse_id, bin_id, chargenumber) - VALUES (?, ?, ?, ?, ?, ?)|; + qq|INSERT INTO delivery_order_items_stock (delivery_order_item_id, qty, unit, warehouse_id, bin_id, chargenumber, bestbefore) + VALUES (?, ?, ?, ?, ?, ?, ?)|; my $h_item_stock = prepare_query($form, $dbh, $q_item_stock); my $in_out = $form->{type} =~ /^sales/ ? 'out' : 'in'; @@ -309,7 +309,7 @@ sub save { foreach my $sinfo (@{ $stock_info }) { @values = ($item_id, $sinfo->{qty}, $sinfo->{unit}, conv_i($sinfo->{warehouse_id}), - conv_i($sinfo->{bin_id}), $sinfo->{chargenumber}); + conv_i($sinfo->{bin_id}), $sinfo->{chargenumber}, conv_date($sinfo->{bestbefore})); do_statement($form, $h_item_stock, $q_item_stock, @values); } @@ -693,7 +693,7 @@ sub retrieve { my $in_out = $form->{type} =~ /^sales/ ? 'out' : 'in'; $query = - qq|SELECT qty, unit, bin_id, warehouse_id, chargenumber + qq|SELECT qty, unit, bin_id, warehouse_id, chargenumber, bestbefore FROM delivery_order_items_stock WHERE delivery_order_item_id = ?|; my $sth = prepare_query($form, $dbh, $query); @@ -792,7 +792,7 @@ sub order_details { qw(runningnumber number description longdescription qty unit partnotes serialnumber reqdate projectnumber si_runningnumber si_number si_description - si_warehouse si_bin si_chargenumber si_qty si_unit); + si_warehouse si_bin si_chargenumber si_bestbefore si_qty si_unit); map { $form->{TEMPLATE_ARRAYS}->{$_} = [] } (@arrays); @@ -875,6 +875,7 @@ sub order_details { push @{ $form->{TEMPLATE_ARRAYS}{si_warehouse}[$position-1] }, $bin_wh->{warehouse}; push @{ $form->{TEMPLATE_ARRAYS}{si_bin}[$position-1] }, $bin_wh->{bin}; push @{ $form->{TEMPLATE_ARRAYS}{si_chargenumber}[$position-1] }, $si->{chargenumber}; + push @{ $form->{TEMPLATE_ARRAYS}{si_bestbefore}[$position-1] }, $si->{bestbefore}; push @{ $form->{TEMPLATE_ARRAYS}{si_qty}[$position-1] }, $form->format_amount($myconfig, $si->{qty} * 1); push @{ $form->{TEMPLATE_ARRAYS}{si_unit}[$position-1] }, $si->{unit}; } @@ -944,16 +945,16 @@ sub get_item_availability { my $myconfig = \%main::myconfig; my $query = - qq|SELECT i.warehouse_id, i.bin_id, i.chargenumber, SUM(qty) AS qty, i.parts_id, + qq|SELECT i.warehouse_id, i.bin_id, i.chargenumber, i.bestbefore, SUM(qty) AS qty, i.parts_id, w.description AS warehousedescription, b.description AS bindescription FROM inventory i LEFT JOIN warehouse w ON (i.warehouse_id = w.id) LEFT JOIN bin b ON (i.bin_id = b.id) WHERE (i.parts_id IN (| . join(', ', ('?') x scalar(@parts_ids)) . qq|)) - GROUP BY i.warehouse_id, i.bin_id, i.chargenumber, i.parts_id, w.description, b.description + GROUP BY i.warehouse_id, i.bin_id, i.chargenumber, i.bestbefore, i.parts_id, w.description, b.description HAVING SUM(qty) > 0 - ORDER BY LOWER(w.description), LOWER(b.description), LOWER(i.chargenumber) + ORDER BY LOWER(w.description), LOWER(b.description), LOWER(i.chargenumber), i.bestbefore |; my $contents = selectall_hashref_query($form, $form->get_standard_dbh($myconfig), $query, @parts_ids); @@ -991,7 +992,8 @@ sub check_stock_availability { foreach my $row (@contents) { next if (($row->{bin_id} != $sinfo->{bin_id}) || ($row->{warehouse_id} != $sinfo->{warehouse_id}) || - ($row->{chargenumber} ne $sinfo->{chargenumber})); + ($row->{chargenumber} ne $sinfo->{chargenumber}) || + ($row->{bestbefore} ne $sinfo->{bestbefore})); $found = 1; @@ -1039,6 +1041,7 @@ sub transfer_in_out { "${prefix}_warehouse_id" => $request->{warehouse_id}, "${prefix}_bin_id" => $request->{bin_id}, 'chargenumber' => $request->{chargenumber}, + 'bestbefore' => $request->{bestbefore}, 'qty' => $request->{qty}, 'unit' => $request->{unit}, 'oe_id' => $form->{id}, diff --git a/SL/WH.pm b/SL/WH.pm index 08f7a80d5..5b0054d96 100644 --- a/SL/WH.pm +++ b/SL/WH.pm @@ -73,9 +73,10 @@ sub transfer { my ($now) = selectrow_query($form, $dbh, qq|SELECT current_date|); - $query = qq|INSERT INTO inventory (warehouse_id, bin_id, parts_id, chargenumber, oe_id, orderitems_id, shippingdate, + $query = qq|INSERT INTO inventory (warehouse_id, bin_id, parts_id, chargenumber, bestbefore, + oe_id, orderitems_id, shippingdate, employee_id, project_id, trans_id, trans_type_id, comment, qty) - VALUES (?, ?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, ?, ?, ?, ?)|; + VALUES (?, ?, ?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, ?, ?, ?, ?)|; $sth = prepare_query($form, $dbh, $query); @@ -90,7 +91,7 @@ sub transfer { $direction |= 1 if ($transfer->{src_warehouse_id} && $transfer->{src_bin_id}); $direction |= 2 if ($transfer->{dst_warehouse_id} && $transfer->{dst_bin_id}); - push @values, conv_i($transfer->{parts_id}), "$transfer->{chargenumber}", conv_i($transfer->{oe_id}), conv_i($transfer->{orderitems_id}); + push @values, conv_i($transfer->{parts_id}), "$transfer->{chargenumber}", conv_date($transfer->{bestbefore}), conv_i($transfer->{oe_id}), conv_i($transfer->{orderitems_id}); push @values, $transfer->{shippingdate} eq 'current_date' ? $now : conv_date($transfer->{shippingdate}), $form->{login}, conv_i($transfer->{project_id}), $trans_id; if ($transfer->{transfer_type_id}) { @@ -131,7 +132,7 @@ sub transfer_assembly { my $self = shift; my %params = @_; - Common::check_params(\%params, qw(assembly_id dst_warehouse_id login qty unit dst_bin_id chargenumber comment)); + Common::check_params(\%params, qw(assembly_id dst_warehouse_id login qty unit dst_bin_id chargenumber bestbefore comment)); # my $maxcreate=WH->check_assembly_max_create(assembly_id =>$params{'assembly_id'}, dbh => $my_dbh); @@ -163,8 +164,8 @@ sub transfer_assembly { my $sth_part_qty_assembly = prepare_execute_query($form, $dbh, $query, $params{assembly_id}); # Hier wird das prepared Statement für die Schleife über alle Lagerplätze vorbereitet - my $transferPartSQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, comment, employee_id, qty, trans_id, trans_type_id) - VALUES (?, ?, ?, ?, ?,(SELECT id FROM employee WHERE login = ?), ?, nextval('id'), + my $transferPartSQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, bestbefore, comment, employee_id, qty, trans_id, trans_type_id) + VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), (SELECT id FROM transfer_type WHERE direction = 'out' AND description = 'used'))|; my $sthTransferPartSQL = prepare_query($form, $dbh, $transferPartSQL); @@ -191,15 +192,15 @@ sub transfer_assembly { next; # die weiteren Überprüfungen sind unnötig, daher das nächste elemente prüfen (genaue Ausgabe, was noch fehlt) } - # Eine kurze Vorabfrage, um den Lagerplatz und die Chargennummber zu bestimmen + # Eine kurze Vorabfrage, um den Lagerplatz, Chargennummer und die Mindesthaltbarkeit zu bestimmen # Offen: Die Summe über alle Lagerplätze wird noch nicht gebildet # Gelöst: Wir haben vorher schon die Abfrage durchgeführt, ob wir fertigen können. # Noch besser gelöst: Wir laufen durch alle benötigten Waren zum Fertigen und geben eine Rückmeldung an den Benutzer was noch fehlt # und lösen den Rest dann so wie bei xplace im Barcode-Programm # S.a. Kommentar im bin/mozilla-Code mb übernimmt und macht das in ordentlich - my $tempquery = qq|SELECT SUM(qty), bin_id, chargenumber FROM inventory - WHERE warehouse_id = ? AND parts_id = ? GROUP BY bin_id, chargenumber having SUM(qty)>0|; + my $tempquery = qq|SELECT SUM(qty), bin_id, chargenumber, bestbefore FROM inventory + WHERE warehouse_id = ? AND parts_id = ? GROUP BY bin_id, chargenumber, bestbefore having SUM(qty)>0|; my $tempsth = prepare_execute_query($form, $dbh, $tempquery, $params{dst_warehouse_id}, $currentPart_ID); # Alle Werte zu dem einzelnen Artikel, die wir später auslagern @@ -208,6 +209,7 @@ sub transfer_assembly { while (my $temphash_ref = $tempsth->fetchrow_hashref()) { my $temppart_bin_id = $temphash_ref->{bin_id}; # kann man hier den quelllagerplatz beim verbauen angeben? my $temppart_chargenumber = $temphash_ref->{chargenumber}; + my $temppart_bestbefore = $temphash_ref->{bestbefore}; my $temppart_qty = $temphash_ref->{sum}; if ($tmpPartsQTY > $temppart_qty) { # wir haben noch mehr waren zum wegbuchen. @@ -218,7 +220,7 @@ sub transfer_assembly { # Dieser Wert IST und BLEIBT positiv!! Hilfe. # Liegt das daran, dass dieser Wert aus einem SQL-Statement stammt? do_statement($form, $sthTransferPartSQL, $transferPartSQL, $currentPart_ID, $params{dst_warehouse_id}, - $temppart_bin_id, $temppart_chargenumber, 'Verbraucht für ' . + $temppart_bin_id, $temppart_chargenumber, $temppart_bestbefore, 'Verbraucht für ' . $self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty); # hier ist noch ein fehler am besten mit definierten erzeugnissen debuggen 02/2009 jb @@ -228,24 +230,24 @@ sub transfer_assembly { } else { # okay, wir haben weniger oder gleich Waren die wir wegbuchen müssen, wir können also aufhören $tmpPartsQTY *=-1; do_statement($form, $sthTransferPartSQL, $transferPartSQL, $currentPart_ID, $params{dst_warehouse_id}, - $temppart_bin_id, $temppart_chargenumber, 'Verbraucht für ' . + $temppart_bin_id, $temppart_chargenumber, $temppart_bestbefore, 'Verbraucht für ' . $self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $tmpPartsQTY); last; # beendet die schleife (springt zum letzten element) } - } # ende while SELECT SUM(qty), bin_id, chargenumber FROM inventory WHERE warehouse_id + } # ende while SELECT SUM(qty), bin_id, chargenumber, bestbefore FROM inventory WHERE warehouse_id } #ende while select parts_id,qty from assembly where id = ? if ($kannNichtFertigen) { return $kannNichtFertigen; } # soweit alles gut. Jetzt noch die wirkliche Lagerbewegung für das Erzeugnis ausführen ... - my $transferAssemblySQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, + my $transferAssemblySQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, bestbefore, comment, employee_id, qty, trans_id, trans_type_id) - VALUES (?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), + VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'), (SELECT id FROM transfer_type WHERE direction = 'in' AND description = 'stock'))|; my $sthTransferAssemblySQL = prepare_query($form, $dbh, $transferAssemblySQL); do_statement($form, $sthTransferAssemblySQL, $transferAssemblySQL, $params{assembly_id}, $params{dst_warehouse_id}, - $params{dst_bin_id}, $params{chargenumber}, $params{comment}, $params{login}, $params{qty}); + $params{dst_bin_id}, $params{chargenumber}, $params{bestbefore}, $params{comment}, $params{login}, $params{qty}); $dbh->commit(); $main::lxdebug->leave_sub(); @@ -294,6 +296,11 @@ sub get_warehouse_journal { push @filter_vars, '%' . $filter{chargenumber} . '%'; } + if ($form->{bestbefore}) { + push @filter_ary, "?::DATE = i1.bestbefore::DATE"; + push @filter_vars, $form->{bestbefore}; + } + if ($form->{fromdate}) { push @filter_ary, "?::DATE <= i1.itime::DATE"; push @filter_vars, $form->{fromdate}; @@ -344,6 +351,7 @@ sub get_warehouse_journal { "partdescription" => "p.description", "bindescription" => "b.description", "chargenumber" => "i1.chargenumber", + "bestbefore" => "i1.bestbefore", "warehousedescription" => "w.description", "partunit" => "p.unit", "bin_from" => "b1.description", @@ -512,6 +520,7 @@ SQL # - partsid - will return matches with this parts_id only # - description - will return only matches where the given string is a substring of the description # - chargenumber - will return only matches where the given string is a substring of the chargenumber +# - bestbefore - will return only matches with this bestbefore date # - ean - will return only matches where the given string is a substring of the ean as stored in the table parts (article) # - charge_ids - must be an arrayref. will return contents with these ids only # - expires_in - will only return matches that expire within the given number of days @@ -574,6 +583,12 @@ sub get_warehouse_report { push @filter_ary, "i.chargenumber ILIKE ?"; push @filter_vars, '%' . $filter{chargenumber} . '%'; } + + if ($form->{bestbefore}) { + push @filter_ary, "?::DATE = i.bestbefore::DATE"; + push @filter_vars, $form->{bestbefore}; + } + if ($filter{ean}) { push @filter_ary, "p.ean ILIKE ?"; push @filter_vars, '%' . $filter{ean} . '%'; @@ -616,6 +631,7 @@ sub get_warehouse_report { "bindescription" => "b.description", "binid" => "b.id", "chargenumber" => "i.chargenumber", + "bestbefore" => "i.bestbefore", "ean" => "p.ean", "chargeid" => "c.id", "warehousedescription" => "w.description", @@ -810,12 +826,12 @@ $main::lxdebug->enter_sub(); my $dbh = $params{dbh} || $form->get_standard_dbh(); - my $query = qq| SELECT SUM(qty), bin_id, chargenumber FROM inventory where parts_id = ? AND warehouse_id = ? GROUP BY bin_id, chargenumber|; + my $query = qq| SELECT SUM(qty), bin_id, chargenumber, bestbefore FROM inventory where parts_id = ? AND warehouse_id = ? GROUP BY bin_id, chargenumber, bestbefore|; my $sth_QTY = prepare_execute_query($form, $dbh, $query, ,$params{parts_id}, $params{warehouse_id}); #info: aufruf an DBUtils.pm my $max_qty_parts = 0; #Initialisierung mit 0 - while (my $ref = $sth_QTY->fetchrow_hashref()) { # wir laufen über alle chargen und Lagerorte (s.a. SQL-Query oben) + while (my $ref = $sth_QTY->fetchrow_hashref()) { # wir laufen über alle Haltbarkeiten, chargen und Lagerorte (s.a. SQL-Query oben) $max_qty_parts += $ref->{sum}; } diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 17dac992e..defa5f1b0 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -76,6 +76,11 @@ sub select_part { $has_charge = 1; map { $_->{has_charge} = 1; } @parts; } + my $has_bestbefore = 0; + if (defined($parts[0]->{bestbefore})) { + $has_bestbefore = 1; + map { $_->{has_bestbefore} = 1; } @parts; + } my $has_ean = 0; if (defined($parts[0]->{ean})) { $has_ean = 1; @@ -92,6 +97,7 @@ sub select_part { "nextsub" => "select_part_internal", "callback_sub" => $callback_sub, "has_charge" => $has_charge, + "has_bestbefore" => $has_bestbefore, "has_ean" => $has_ean, "remap_parts_id" => $remap_parts_id, "remap_partnumber" => $remap_partnumber }); diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl index a57022b76..dd4d2d01a 100644 --- a/bin/mozilla/do.pl +++ b/bin/mozilla/do.pl @@ -1004,7 +1004,7 @@ sub update_stock_in { foreach my $i (1..$form->{rowcount}) { $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"}); - push @{ $stock_info }, { map { $_ => $form->{"${_}_${i}"} } qw(warehouse_id bin_id chargenumber qty unit) }; + push @{ $stock_info }, { map { $_ => $form->{"${_}_${i}"} } qw(warehouse_id bin_id chargenumber bestbefore qty unit) }; } display_stock_in_form($stock_info); @@ -1033,6 +1033,8 @@ sub display_stock_in_form { my %myconfig = %main::myconfig; my $locale = $main::locale; + $form->{jsscript} = 1; + $form->{title} = $locale->text('Stock'); my $part_info = IC->get_basic_part_info('id' => $form->{parts_id}); @@ -1068,7 +1070,7 @@ sub set_stock_in { next if ($form->{"qty_$i"} <= 0); - push @{ $stock_info }, { map { $_ => $form->{"${_}_${i}"} } qw(warehouse_id bin_id chargenumber qty unit) }; + push @{ $stock_info }, { map { $_ => $form->{"${_}_${i}"} } qw(warehouse_id bin_id chargenumber bestbefore qty unit) }; } $form->{stock} = YAML::Dump($stock_info); @@ -1107,7 +1109,8 @@ sub stock_out_form { foreach my $sinfo (@{ $stock_info }) { next if (($row->{bin_id} != $sinfo->{bin_id}) || ($row->{warehouse_id} != $sinfo->{warehouse_id}) || - ($row->{chargenumber} ne $sinfo->{chargenumber})); + ($row->{chargenumber} ne $sinfo->{chargenumber}) || + ($row->{bestbefore} ne $sinfo->{bestbefore})); map { $row->{"stock_$_"} = $sinfo->{$_} } qw(qty unit error); } @@ -1147,6 +1150,7 @@ sub set_stock_out { 'warehouse_id' => $form->{"warehouse_id_$i"}, 'bin_id' => $form->{"bin_id_$i"}, 'chargenumber' => $form->{"chargenumber_$i"}, + 'bestbefore' => $form->{"bestbefore_$i"}, 'qty' => $form->{"qty_$i"}, 'unit' => $form->{"unit_$i"}, 'row' => $i, @@ -1266,7 +1270,7 @@ sub transfer_out { $request->{parts_id} = $form->{"id_$i"}; $request->{base_qty} = $request->{qty} * $units->{$request->{unit}}->{factor} / $base_unit_factor; - my $map_key = join '--', ($form->{"id_$i"}, @{$request}{qw(warehouse_id bin_id chargenumber)}); + my $map_key = join '--', ($form->{"id_$i"}, @{$request}{qw(warehouse_id bin_id chargenumber bestbefore)}); $request_map{$map_key} ||= $request; $request_map{$map_key}->{sum_base_qty} ||= 0; @@ -1292,7 +1296,7 @@ sub transfer_out { my @contents = DO->get_item_availability('parts_id' => \@part_ids); foreach my $inv (@contents) { - my $map_key = join '--', @{$inv}{qw(parts_id warehouse_id bin_id chargenumber)}; + my $map_key = join '--', @{$inv}{qw(parts_id warehouse_id bin_id chargenumber bestbefore)}; next unless ($request_map{$map_key}); @@ -1306,9 +1310,10 @@ sub transfer_out { my $pinfo = $part_info_map{$request->{parts_id}}; my $binfo = $bin_info_map{$request->{bin_id}}; - push @{ $form->{ERRORS} }, $locale->text("There is not enough available of '#1' at warehouse '#2', bin '#3', #4, for the transfer of #5.", + push @{ $form->{ERRORS} }, $locale->text("There is not enough available of '#1' at warehouse '#2', bin '#3', #4, #5, for the transfer of #6.", $pinfo->{description}, $binfo->{warehouse_description}, $binfo->{bin_description}, $request->{chargenumber} ? $locale->text('chargenumber #1', $request->{chargenumber}) : $locale->text('no chargenumber'), + $request->{bestbefore} ? $locale->text('bestbefore #1', $request->{bestbefore}) : $locale->text('no bestbefore'), $form->format_amount_units('amount' => $request->{sum_base_qty}, 'part_unit' => $pinfo->{unit}, 'conv_units' => 'convertible_not_smaller')); diff --git a/bin/mozilla/wh.pl b/bin/mozilla/wh.pl index f96d59659..6af6980fe 100644 --- a/bin/mozilla/wh.pl +++ b/bin/mozilla/wh.pl @@ -164,12 +164,13 @@ sub transfer_or_removal_prepare_contents { $form->show_generic_error($locale->text("The source warehouse does not contain any bins.")) if (0 == scalar @{ $warehouse->{BINS} }); - map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber partunit ean); + map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber bestbefore partunit ean); $form->{sort} = 'bindescription'; my @contents = WH->get_warehouse_report("warehouse_id" => $form->{warehouse_id}, "bin_id" => $form->{bin_id}, "chargenumber" => $form->{chargenumber}, + "bestbefore" => $form->{bestbefore}, "partnumber" => $form->{partnumber}, "ean" => $form->{ean}, "description" => $form->{description}); @@ -219,7 +220,7 @@ sub transfer_parts { $form->show_generic_error($locale->text("The source warehouse does not contain any bins.")) if (0 == scalar @{ $warehouse->{BINS} }); - map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber partunit); + map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber bestbefore partunit); $form->{sort} = 'bindescription'; my @contents = WH->get_warehouse_report("warehouse_id" => $form->{warehouse_id}); @@ -243,12 +244,12 @@ sub transfer_parts { 'transfer_type_id' => $form->{transfer_type_id}, }; - map { $transfer->{$_} = $form->{"${_}_${row}"} } qw(src_bin_id chargenumber parts_id qty dst_warehouse_id dst_bin_id); + map { $transfer->{$_} = $form->{"${_}_${row}"} } qw(src_bin_id chargenumber bestbefore parts_id qty dst_warehouse_id dst_bin_id); my $entry; foreach (@contents) { - if (($_->{binid} == $transfer->{src_bin_id}) && ($_->{parts_id} == $transfer->{parts_id}) && ($_->{chargenumber} eq $transfer->{chargenumber})) { + if (($_->{binid} == $transfer->{src_bin_id}) && ($_->{parts_id} == $transfer->{parts_id}) && ($_->{chargenumber} eq $transfer->{chargenumber}) && $_->{bestbefore} eq $transfer->{bestbefore}) { $entry = $_; last; } @@ -441,6 +442,7 @@ sub create_assembly { 'dst_warehouse_id' => $form->{warehouse_id}, 'dst_bin_id' => $form->{bin_id}, 'chargenumber' => $form->{chargenumber}, + 'bestbefore' => $form->{bestbefore}, 'assembly_id' => $form->{parts_id}, 'qty' => $form->{qty}, 'unit' => $form->{unit}, @@ -455,7 +457,7 @@ sub create_assembly { $form->show_generic_error($ret, 'back_button' => 1); } - delete @{$form}{qw(parts_id partnumber description qty unit chargenumber comment)}; + delete @{$form}{qw(parts_id partnumber description qty unit chargenumber bestbefore comment)}; $form->{saved_message} = $locale->text('The assembly has been created.'); $form->{trans_type} = 'assembly'; @@ -487,6 +489,7 @@ sub transfer_stock { 'dst_warehouse_id' => $form->{warehouse_id}, 'dst_bin_id' => $form->{bin_id}, 'chargenumber' => $form->{chargenumber}, + 'bestbefore' => $form->{bestbefore}, 'parts_id' => $form->{parts_id}, 'qty' => $form->{qty}, 'unit' => $form->{unit}, @@ -495,7 +498,7 @@ sub transfer_stock { WH->transfer($transfer); - delete @{$form}{qw(parts_id partnumber description qty unit chargenumber comment)}; + delete @{$form}{qw(parts_id partnumber description qty unit chargenumber bestbefore comment)}; $form->{saved_message} = $locale->text('The parts have been stocked.'); $form->{trans_type} = 'stock'; @@ -546,7 +549,7 @@ sub remove_parts { $form->show_generic_error($locale->text("The warehouse does not contain any bins.")) if (0 == scalar @{ $warehouse->{BINS} }); - map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber partunit); + map { $form->{"l_$_"} = 'Y' } qw(parts_id qty warehouseid binid partnumber partdescription bindescription chargenumber bestbefore partunit); $form->{sort} = 'bindescription'; my @contents = WH->get_warehouse_report("warehouse_id" => $form->{warehouse_id}); @@ -570,12 +573,12 @@ sub remove_parts { 'transfer_type_id' => $form->{transfer_type_id}, }; - map { $transfer->{$_} = $form->{"${_}_${row}"} } qw(src_bin_id chargenumber parts_id qty); + map { $transfer->{$_} = $form->{"${_}_${row}"} } qw(src_bin_id chargenumber bestbefore parts_id qty); my $entry; foreach (@contents) { - if (($_->{binid} == $transfer->{src_bin_id}) && ($_->{parts_id} == $transfer->{parts_id}) && ($_->{chargenumber} eq $transfer->{chargenumber})) { + if (($_->{binid} == $transfer->{src_bin_id}) && ($_->{parts_id} == $transfer->{parts_id}) && ($_->{chargenumber} eq $transfer->{chargenumber}) && ($_->{bestbefore} eq $transfer->{bestbefore})) { $entry = $_; last; } @@ -654,10 +657,10 @@ sub generate_journal { $form->{sort} ||= 'date'; my %filter; - my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber partdescription chargenumber trans_type comment qty employee oe_id projectnumber); + my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber partdescription chargenumber bestbefore trans_type comment qty employee oe_id projectnumber); # filter stuff - map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber); + map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber bestbefore); $filter{qty_op} = WH->convert_qty_op($form->{qty_op}); if ($filter{qty_op}) { @@ -672,7 +675,7 @@ sub generate_journal { my $report = SL::ReportGenerator->new(\%myconfig, $form); my @hidden_variables = map { "l_${_}" } @columns; - push @hidden_variables, qw(warehouse_id bin_id partnumber description chargenumber qty_op qty qty_unit fromdate todate); + push @hidden_variables, qw(warehouse_id bin_id partnumber description chargenumber bestbefore qty_op qty qty_unit fromdate todate); my %column_defs = ( 'date' => { 'text' => $locale->text('Date'), }, @@ -686,6 +689,7 @@ sub generate_journal { 'partnumber' => { 'text' => $locale->text('Part Number'), }, 'partdescription' => { 'text' => $locale->text('Description'), }, 'chargenumber' => { 'text' => $locale->text('Charge Number'), }, + 'bestbefore' => { 'text' => $locale->text('Best Before'), }, 'qty' => { 'text' => $locale->text('Qty'), }, 'employee' => { 'text' => $locale->text('Employee'), }, 'projectnumber' => { 'text' => $locale->text('Project Number'), }, @@ -777,8 +781,10 @@ sub report { show_no_warehouses_error() if (!scalar @{ $form->{WAREHOUSES} }); - $form->{fokus} = "partnumber"; - $form->{onload} .= "focus();"; + $form->{jsscript} = 1; + +# $form->{fokus} = "partnumber"; +# $form->{onload} .= "focus();"; $form->{title} = $locale->text("Report about wareouse contents"); $form->header(); @@ -804,10 +810,10 @@ sub generate_report { my $sort_col = $form->{sort}; my %filter; - my @columns = qw(warehousedescription bindescription partnumber partdescription chargenumber qty stock_value); + my @columns = qw(warehousedescription bindescription partnumber partdescription chargenumber bestbefore qty stock_value); # filter stuff - map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber); + map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id partnumber description chargenumber bestbefore); $filter{qty_op} = WH->convert_qty_op($form->{qty_op}); if ($filter{qty_op}) { @@ -824,7 +830,7 @@ sub generate_report { my $report = SL::ReportGenerator->new(\%myconfig, $form); my @hidden_variables = map { "l_${_}" } @columns; - push @hidden_variables, qw(warehouse_id bin_id partnumber description chargenumber qty_op qty qty_unit l_warehousedescription l_bindescription); + push @hidden_variables, qw(warehouse_id bin_id partnumber description chargenumber bestbefore qty_op qty qty_unit l_warehousedescription l_bindescription); push @hidden_variables, qw(include_empty_bins subtotal); my %column_defs = ( @@ -833,6 +839,7 @@ sub generate_report { 'partnumber' => { 'text' => $locale->text('Part Number'), }, 'partdescription' => { 'text' => $locale->text('Description'), }, 'chargenumber' => { 'text' => $locale->text('Charge Number'), }, + 'bestbefore' => { 'text' => $locale->text('Best Before'), }, 'qty' => { 'text' => $locale->text('Qty'), }, 'stock_value' => { 'text' => $locale->text('Stock value'), }, ); diff --git a/doc/dokumentenvorlagen-und-variablen.html b/doc/dokumentenvorlagen-und-variablen.html index 9bf5a1083..763dd495e 100644 --- a/doc/dokumentenvorlagen-und-variablen.html +++ b/doc/dokumentenvorlagen-und-variablen.html @@ -1212,6 +1212,10 @@ td { si_chargenumber Chargennummer + + si_bestbefore + Mindesthaltbarkeit + si_number Artikelnummer diff --git a/sql/Pg-upgrade2/warehouse_add_bestbefore.sql b/sql/Pg-upgrade2/warehouse_add_bestbefore.sql new file mode 100644 index 000000000..325a9a327 --- /dev/null +++ b/sql/Pg-upgrade2/warehouse_add_bestbefore.sql @@ -0,0 +1,5 @@ +-- @tag: warehouse_add_bestbefore +-- @description: Spalten für Mindesthaltbarkeitsdatum +-- @depends: release_2_6_0 +ALTER TABLE inventory ADD COLUMN bestbefore date; +ALTER TABLE delivery_order_items_stock ADD COLUMN bestbefore date; diff --git a/templates/webpages/do/stock_in_form_master.html b/templates/webpages/do/stock_in_form_master.html index 42208f2e0..6b2caab24 100644 --- a/templates/webpages/do/stock_in_form_master.html +++ b/templates/webpages/do/stock_in_form_master.html @@ -92,6 +92,7 @@ Warehouse Bin Charge Number + Best Before Qty Unit @@ -105,6 +106,7 @@ [% HTML.escape(row.warehouse_description) %] [% HTML.escape(row.bin_description) %] [% HTML.escape(row.chargenumber) %] + [% HTML.escape(row.bestbefore) %] [% HTML.escape(LxERP.format_amount(row.qty)) %] [% HTML.escape(row.unit) %] @@ -120,6 +122,12 @@ + + + + + + @@ -149,6 +157,21 @@

+ [%- IF NOT delivered %] + + [%- END %] + diff --git a/templates/webpages/do/stock_out_form_master.html b/templates/webpages/do/stock_out_form_master.html index 971b6e761..8e77f9669 100644 --- a/templates/webpages/do/stock_out_form_master.html +++ b/templates/webpages/do/stock_out_form_master.html @@ -60,6 +60,7 @@ Warehouse Bin Charge Number + Best Before [%- UNLESS delivered %] Available qty [%- END %] @@ -73,6 +74,7 @@ [% HTML.escape(row.warehousedescription) %] [% HTML.escape(row.bindescription) %] [% HTML.escape(row.chargenumber) %] + [% HTML.escape(row.bestbefore) %] [%- IF delivered %] @@ -103,6 +105,7 @@ + [%- END %]

diff --git a/templates/webpages/generic/select_part_master.html b/templates/webpages/generic/select_part_master.html index c7e2f347f..732ed2f5d 100644 --- a/templates/webpages/generic/select_part_master.html +++ b/templates/webpages/generic/select_part_master.html @@ -20,6 +20,9 @@ [% IF has_charge %] Charge number [% END %] + [% IF has_bestbefore %] + Best Before + [% END %] [% IF has_ean %] EAN [% END %] @@ -49,6 +52,13 @@ [% HTML.escape(part.chargenumber) %] [% END %] + [% IF has_bestbefore %] + + + + [% HTML.escape(part.bestbefore) %] + + [% END %] [% IF has_ean %] diff --git a/templates/webpages/wh/journal_filter_master.html b/templates/webpages/wh/journal_filter_master.html index c76c06cb0..946a04c27 100644 --- a/templates/webpages/wh/journal_filter_master.html +++ b/templates/webpages/wh/journal_filter_master.html @@ -104,6 +104,13 @@ Charge Number: + + Best Before: + + + + + Transfer Quantity: @@ -159,6 +166,8 @@ + + @@ -199,6 +208,13 @@ + diff --git a/templates/webpages/wh/transfer_parts_selection_master.html b/templates/webpages/wh/transfer_parts_selection_master.html index c69572fa8..8b78a770a 100644 --- a/templates/webpages/wh/transfer_parts_selection_master.html +++ b/templates/webpages/wh/transfer_parts_selection_master.html @@ -66,6 +66,7 @@ Part Number Part Description Charge Number + Best Before EAN Available qty Transfer qty @@ -79,11 +80,13 @@ + [% HTML.escape(row.bindescription) %] [% HTML.escape(row.partnumber) %] [% HTML.escape(row.partdescription) %] [% HTML.escape(row.chargenumber) %] + [% HTML.escape(row.bestbefore) %] [% HTML.escape(row.ean) %] [% HTML.escape(row.qty) %] diff --git a/templates/webpages/wh/warehouse_selection_assembly_master.html b/templates/webpages/wh/warehouse_selection_assembly_master.html index dd9c86594..27f034439 100644 --- a/templates/webpages/wh/warehouse_selection_assembly_master.html +++ b/templates/webpages/wh/warehouse_selection_assembly_master.html @@ -105,6 +105,14 @@ + + Best Before + + + + + + Quantity @@ -131,5 +139,16 @@

+ + diff --git a/templates/webpages/wh/warehouse_selection_master.html b/templates/webpages/wh/warehouse_selection_master.html index 1c9c35f77..c6da317e4 100644 --- a/templates/webpages/wh/warehouse_selection_master.html +++ b/templates/webpages/wh/warehouse_selection_master.html @@ -118,6 +118,15 @@ Charge number + + + Best Before + + + + + + EAN @@ -130,5 +139,16 @@

+ + diff --git a/templates/webpages/wh/warehouse_selection_stock_master.html b/templates/webpages/wh/warehouse_selection_stock_master.html index 33bcd76b7..9b68561ff 100644 --- a/templates/webpages/wh/warehouse_selection_stock_master.html +++ b/templates/webpages/wh/warehouse_selection_stock_master.html @@ -104,6 +104,15 @@ Charge number + + + Best Before + + + + + + EAN @@ -135,5 +144,16 @@

+ +