Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5f7cab51

Von Jan Büren vor fast 10 Jahren hinzugefügt

  • ID 5f7cab519820f9d5d7bbad3ba32271ef9995d78e
  • Vorgänger 2b32359d
  • Nachfolger 903029f6

delivery_order_items_stock persistent machen Teil 3

Testfall (Einkauf-Lieferschein):
Update drücken (alles wird erneuert) => i.O. (alle ids werden gelöscht)
Position löschen mit schon ausgewählten stock_items => i.O. (keine verwaisten dois)

Stichproben:
Verkaufs-LS als neu speichern i.O.
Einkaufs-LS mittlere Position löschen (mit und ohne dois) i.O.
Einkaufs-LS E-Mail-Knopf statt Speichern i.O.
Einkaufs-LS Rechnung (keine hiddens doi!) i.O.
Einkaufs-LS mit dois Löschen i.O. (keine verwaisten doi oder dois)

Unterschiede anzeigen:

SL/DO.pm
386 386
                                dbh          => $dbh);
387 387
  }
388 388

  
389
  # search for orphaned doi
390
  $query  = sprintf 'SELECT id FROM delivery_order_items WHERE delivery_order_id = ? AND NOT id IN (%s)', join ', ', ("?") x scalar @processed_doi;
391
  @values = (conv_i($form->{id}), map { conv_i($_) } @processed_doi);
392
  my @orphaned_ids = map { $_->{id} } selectall_hashref_query($form, $dbh, $query, @values);
393
  if (scalar @orphaned_ids) {
394
    # clean up delivery_order_items
395
    $query  = sprintf 'DELETE FROM delivery_order_items WHERE id IN (%s)', join ', ', ("?") x scalar @orphaned_ids;
396
    do_query($form, $dbh, $query, @orphaned_ids);
397
  }
398
  # search for orphaned dois
389
  # 1. search for orphaned dois; processed_dois may be empty (no transfer) TODO: be supersafe and alter same statement for doi and oi
399 390
  $query  = sprintf 'SELECT id FROM delivery_order_items_stock WHERE delivery_order_item_id in
400
                      (select id from delivery_order_items where delivery_order_id = ?) AND NOT id IN (%s)', join ', ', ("?") x scalar @processed_dois;
391
                      (select id from delivery_order_items where delivery_order_id = ?)';
392
  $query .= sprintf ' AND NOT id IN (%s)', join ', ', ("?") x scalar @processed_dois if (scalar @processed_dois);
401 393
  @values = (conv_i($form->{id}), map { conv_i($_) } @processed_dois);
402 394
  my @orphaned_dois_ids = map { $_->{id} } selectall_hashref_query($form, $dbh, $query, @values);
403 395
  if (scalar @orphaned_dois_ids) {
......
405 397
    $query  = sprintf 'DELETE FROM delivery_order_items_stock WHERE id IN (%s)', join ', ', ("?") x scalar @orphaned_dois_ids;
406 398
    do_query($form, $dbh, $query, @orphaned_dois_ids);
407 399
  }
400
  # 2. search for orphaned doi
401
  $query  = sprintf 'SELECT id FROM delivery_order_items WHERE delivery_order_id = ? AND NOT id IN (%s)', join ', ', ("?") x scalar @processed_doi;
402
  @values = (conv_i($form->{id}), map { conv_i($_) } @processed_doi);
403
  my @orphaned_ids = map { $_->{id} } selectall_hashref_query($form, $dbh, $query, @values);
404
  if (scalar @orphaned_ids) {
405
    # clean up delivery_order_items
406
    $query  = sprintf 'DELETE FROM delivery_order_items WHERE id IN (%s)', join ', ', ("?") x scalar @orphaned_ids;
407
    do_query($form, $dbh, $query, @orphaned_ids);
408
  }
408 409
  $h_item->finish();
409 410
  $h_item_stock->finish();
410 411

  
bin/mozilla/do.pl
1089 1089

  
1090 1090
  foreach my $i (1..$form->{rowcount}) {
1091 1091
    $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
1092
    push @{ $stock_info }, { map { $_ => $form->{"${_}_${i}"} } qw(warehouse_id bin_id chargenumber bestbefore qty unit) };
1092
    push @{ $stock_info }, { map { $_ => $form->{"${_}_${i}"} } qw(warehouse_id bin_id chargenumber
1093
                                                                   bestbefore qty unit delivery_order_items_stock_id) };
1093 1094
  }
1094 1095

  
1095 1096
  display_stock_in_form($stock_info);

Auch abrufbar als: Unified diff