Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 096f9e3e

Von Bernd Blessmann vor mehr als 14 Jahren hinzugefügt

  • ID 096f9e3e06dc378bcc2f97df58c74cec02b9f7ff
  • Vorgänger 0e01f2fe
  • Nachfolger 9869ed81

Funktionalität für Mindesthaltbarkeitsdatum hinzugefügt.

Unterschiede anzeigen:

SL/WH.pm
73 73

  
74 74
  my ($now)     = selectrow_query($form, $dbh, qq|SELECT current_date|);
75 75

  
76
  $query = qq|INSERT INTO inventory (warehouse_id, bin_id, parts_id, chargenumber, oe_id, orderitems_id, shippingdate,
76
  $query = qq|INSERT INTO inventory (warehouse_id, bin_id, parts_id, chargenumber, bestbefore,
77
                                     oe_id, orderitems_id, shippingdate,
77 78
                                     employee_id, project_id, trans_id, trans_type_id, comment, qty)
78
              VALUES (?, ?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, ?, ?, ?, ?)|;
79
              VALUES (?, ?, ?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, ?, ?, ?, ?)|;
79 80

  
80 81
  $sth   = prepare_query($form, $dbh, $query);
81 82

  
......
90 91
    $direction |= 1 if ($transfer->{src_warehouse_id} && $transfer->{src_bin_id});
91 92
    $direction |= 2 if ($transfer->{dst_warehouse_id} && $transfer->{dst_bin_id});
92 93

  
93
    push @values, conv_i($transfer->{parts_id}), "$transfer->{chargenumber}", conv_i($transfer->{oe_id}), conv_i($transfer->{orderitems_id});
94
    push @values, conv_i($transfer->{parts_id}), "$transfer->{chargenumber}", conv_date($transfer->{bestbefore}), conv_i($transfer->{oe_id}), conv_i($transfer->{orderitems_id});
94 95
    push @values, $transfer->{shippingdate} eq 'current_date' ? $now : conv_date($transfer->{shippingdate}), $form->{login}, conv_i($transfer->{project_id}), $trans_id;
95 96

  
96 97
    if ($transfer->{transfer_type_id}) {
......
131 132

  
132 133
  my $self     = shift;
133 134
  my %params   = @_;
134
  Common::check_params(\%params, qw(assembly_id dst_warehouse_id login qty unit dst_bin_id chargenumber comment));
135
  Common::check_params(\%params, qw(assembly_id dst_warehouse_id login qty unit dst_bin_id chargenumber bestbefore comment));
135 136

  
136 137
#  my $maxcreate=WH->check_assembly_max_create(assembly_id =>$params{'assembly_id'}, dbh => $my_dbh);
137 138

  
......
163 164
  my $sth_part_qty_assembly = prepare_execute_query($form, $dbh, $query, $params{assembly_id});
164 165

  
165 166
  # Hier wird das prepared Statement für die Schleife über alle Lagerplätze vorbereitet
166
  my $transferPartSQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, comment, employee_id, qty, trans_id, trans_type_id)
167
                           VALUES (?, ?, ?, ?, ?,(SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
167
  my $transferPartSQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, bestbefore, comment, employee_id, qty, trans_id, trans_type_id)
168
                           VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
168 169
                           (SELECT id FROM transfer_type WHERE direction = 'out' AND description = 'used'))|;
169 170
  my $sthTransferPartSQL   = prepare_query($form, $dbh, $transferPartSQL);
170 171

  
......
191 192
      next; # die weiteren Überprüfungen sind unnötig, daher das nächste elemente prüfen (genaue Ausgabe, was noch fehlt)
192 193
    }
193 194

  
194
    # Eine kurze Vorabfrage, um den Lagerplatz und die Chargennummber zu bestimmen
195
    # Eine kurze Vorabfrage, um den Lagerplatz, Chargennummer und die Mindesthaltbarkeit zu bestimmen
195 196
    # Offen: Die Summe über alle Lagerplätze wird noch nicht gebildet
196 197
    # Gelöst: Wir haben vorher schon die Abfrage durchgeführt, ob wir fertigen können.
197 198
    # Noch besser gelöst: Wir laufen durch alle benötigten Waren zum Fertigen und geben eine Rückmeldung an den Benutzer was noch fehlt
198 199
    # und lösen den Rest dann so wie bei xplace im Barcode-Programm
199 200
    # S.a. Kommentar im bin/mozilla-Code mb übernimmt und macht das in ordentlich
200 201

  
201
    my $tempquery = qq|SELECT SUM(qty), bin_id, chargenumber   FROM inventory  
202
                       WHERE warehouse_id = ? AND parts_id = ?  GROUP BY bin_id, chargenumber having SUM(qty)>0|;
202
    my $tempquery = qq|SELECT SUM(qty), bin_id, chargenumber, bestbefore   FROM inventory  
203
                       WHERE warehouse_id = ? AND parts_id = ?  GROUP BY bin_id, chargenumber, bestbefore having SUM(qty)>0|;
203 204
    my $tempsth   = prepare_execute_query($form, $dbh, $tempquery, $params{dst_warehouse_id}, $currentPart_ID);
204 205

  
205 206
    # Alle Werte zu dem einzelnen Artikel, die wir später auslagern
......
208 209
    while (my $temphash_ref = $tempsth->fetchrow_hashref()) {
209 210
      my $temppart_bin_id       = $temphash_ref->{bin_id}; # kann man hier den quelllagerplatz beim verbauen angeben?
210 211
      my $temppart_chargenumber = $temphash_ref->{chargenumber};
212
      my $temppart_bestbefore   = $temphash_ref->{bestbefore};
211 213
      my $temppart_qty          = $temphash_ref->{sum};
212 214

  
213 215
      if ($tmpPartsQTY > $temppart_qty) {  # wir haben noch mehr waren zum wegbuchen. 
......
218 220
                                            # Dieser Wert IST und BLEIBT positiv!! Hilfe. 
219 221
                                            # Liegt das daran, dass dieser Wert aus einem SQL-Statement stammt?
220 222
        do_statement($form, $sthTransferPartSQL, $transferPartSQL, $currentPart_ID, $params{dst_warehouse_id}, 
221
                     $temppart_bin_id, $temppart_chargenumber, 'Verbraucht für ' .
223
                     $temppart_bin_id, $temppart_chargenumber, $temppart_bestbefore, 'Verbraucht für ' .
222 224
                     $self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $temppart_qty);
223 225

  
224 226
        # hier ist noch ein fehler am besten mit definierten erzeugnissen debuggen 02/2009 jb
......
228 230
      } else { # okay, wir haben weniger oder gleich Waren die wir wegbuchen müssen, wir können also aufhören
229 231
        $tmpPartsQTY *=-1;
230 232
        do_statement($form, $sthTransferPartSQL, $transferPartSQL, $currentPart_ID, $params{dst_warehouse_id},
231
                     $temppart_bin_id, $temppart_chargenumber, 'Verbraucht für ' .
233
                     $temppart_bin_id, $temppart_chargenumber, $temppart_bestbefore, 'Verbraucht für ' .
232 234
                     $self->get_part_description(parts_id => $params{assembly_id}), $params{login}, $tmpPartsQTY);
233 235
        last; # beendet die schleife (springt zum letzten element)
234 236
      }
235
    }  # ende while SELECT SUM(qty), bin_id, chargenumber   FROM inventory  WHERE warehouse_id
237
    }  # ende while SELECT SUM(qty), bin_id, chargenumber, bestbefore   FROM inventory  WHERE warehouse_id
236 238
  } #ende while select parts_id,qty from assembly where id = ?
237 239
  if ($kannNichtFertigen) {
238 240
    return $kannNichtFertigen;
239 241
  }
240 242

  
241 243
  # soweit alles gut. Jetzt noch die wirkliche Lagerbewegung für das Erzeugnis ausführen ...
242
  my $transferAssemblySQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, 
244
  my $transferAssemblySQL = qq|INSERT INTO inventory (parts_id, warehouse_id, bin_id, chargenumber, bestbefore,
243 245
                                                      comment, employee_id, qty, trans_id, trans_type_id)
244
                               VALUES (?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
246
                               VALUES (?, ?, ?, ?, ?, ?, (SELECT id FROM employee WHERE login = ?), ?, nextval('id'),
245 247
                               (SELECT id FROM transfer_type WHERE direction = 'in' AND description = 'stock'))|;
246 248
  my $sthTransferAssemblySQL   = prepare_query($form, $dbh, $transferAssemblySQL);
247 249
  do_statement($form, $sthTransferAssemblySQL, $transferAssemblySQL, $params{assembly_id}, $params{dst_warehouse_id}, 
248
               $params{dst_bin_id}, $params{chargenumber}, $params{comment}, $params{login}, $params{qty});
250
               $params{dst_bin_id}, $params{chargenumber}, $params{bestbefore}, $params{comment}, $params{login}, $params{qty});
249 251
  $dbh->commit();
250 252

  
251 253
  $main::lxdebug->leave_sub();
......
294 296
    push @filter_vars, '%' . $filter{chargenumber} . '%';
295 297
  }
296 298

  
299
  if ($form->{bestbefore}) {
300
    push @filter_ary, "?::DATE = i1.bestbefore::DATE";
301
    push @filter_vars, $form->{bestbefore};
302
  }
303

  
297 304
  if ($form->{fromdate}) {
298 305
    push @filter_ary, "?::DATE <= i1.itime::DATE";
299 306
    push @filter_vars, $form->{fromdate};
......
344 351
     "partdescription"      => "p.description",
345 352
     "bindescription"       => "b.description",
346 353
     "chargenumber"         => "i1.chargenumber",
354
     "bestbefore"           => "i1.bestbefore",
347 355
     "warehousedescription" => "w.description",
348 356
     "partunit"             => "p.unit",
349 357
     "bin_from"             => "b1.description",
......
512 520
#  - partsid      - will return matches with this parts_id only
513 521
#  - description  - will return only matches where the given string is a substring of the description
514 522
#  - chargenumber - will return only matches where the given string is a substring of the chargenumber
523
#  - bestbefore   - will return only matches with this bestbefore date
515 524
#  - ean          - will return only matches where the given string is a substring of the ean as stored in the table parts (article)
516 525
#  - charge_ids   - must be an arrayref. will return contents with these ids only
517 526
#  - expires_in   - will only return matches that expire within the given number of days
......
574 583
    push @filter_ary,  "i.chargenumber ILIKE ?";
575 584
    push @filter_vars, '%' . $filter{chargenumber} . '%';
576 585
  }
586

  
587
  if ($form->{bestbefore}) {
588
    push @filter_ary, "?::DATE = i.bestbefore::DATE";
589
    push @filter_vars, $form->{bestbefore};
590
  }
591

  
577 592
  if ($filter{ean}) {
578 593
    push @filter_ary,  "p.ean ILIKE ?";
579 594
    push @filter_vars, '%' . $filter{ean} . '%';
......
616 631
     "bindescription"       => "b.description",
617 632
     "binid"                => "b.id",
618 633
     "chargenumber"         => "i.chargenumber",
634
     "bestbefore"           => "i.bestbefore",
619 635
     "ean"                  => "p.ean",
620 636
     "chargeid"             => "c.id",
621 637
     "warehousedescription" => "w.description",
......
810 826

  
811 827
  my $dbh      = $params{dbh} || $form->get_standard_dbh();
812 828

  
813
  my $query = qq| SELECT SUM(qty), bin_id, chargenumber  FROM inventory where parts_id = ? AND warehouse_id = ? GROUP BY bin_id, chargenumber|;
829
  my $query = qq| SELECT SUM(qty), bin_id, chargenumber, bestbefore  FROM inventory where parts_id = ? AND warehouse_id = ? GROUP BY bin_id, chargenumber, bestbefore|;
814 830

  
815 831
  my $sth_QTY      = prepare_execute_query($form, $dbh, $query, ,$params{parts_id}, $params{warehouse_id}); #info: aufruf an DBUtils.pm
816 832

  
817 833
  my $max_qty_parts = 0; #Initialisierung mit 0
818
  while (my $ref = $sth_QTY->fetchrow_hashref()) {  # wir laufen über alle chargen und Lagerorte (s.a. SQL-Query oben)
834
  while (my $ref = $sth_QTY->fetchrow_hashref()) {  # wir laufen über alle Haltbarkeiten, chargen und Lagerorte (s.a. SQL-Query oben)
819 835
    $max_qty_parts += $ref->{sum};
820 836
  }
821 837

  

Auch abrufbar als: Unified diff