Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision df0d4d3f

Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt

  • ID df0d4d3fb8a275b7f96a260d403966c873123666
  • Vorgänger 33b0b2ca
  • Nachfolger e08c98d4

Verhindern, dass Artikelnummern mehrfach vergeben werden

Fix für Bug 1667.

Unterschiede anzeigen:

SL/IC.pm
40 40

  
41 41
use SL::CVar;
42 42
use SL::DBUtils;
43
use SL::TransNumber;
43 44

  
44 45
use strict;
45 46

  
......
311 312
  my $priceupdate = ', priceupdate = current_date';
312 313

  
313 314
  if ($form->{id}) {
315
    my $trans_number = SL::TransNumber->new(type => $form->{item}, dbh => $dbh, number => $form->{partnumber}, id => $form->{id});
316
    if (!$trans_number->is_unique) {
317
      $::lxdebug->leave_sub;
318
      return 3;
319
    }
314 320

  
315 321
    # get old price
316 322
    $query = qq|SELECT sellprice, weight FROM parts WHERE id = ?|;
......
346 352
    $priceupdate        = '' if (all { $previous_values->{$_} == $form->{$_} } qw(sellprice lastcost listprice));
347 353

  
348 354
  } else {
349
    my ($count) = selectrow_query($form, $dbh, qq|SELECT COUNT(*) FROM parts WHERE partnumber = ?|, $form->{partnumber});
350
    if ($count) {
351
      $main::lxdebug->leave_sub();
355
    my $trans_number = SL::TransNumber->new(type => $form->{item}, dbh => $dbh, number => $form->{partnumber}, save => 1);
356

  
357
    if ($form->{partnumber} && !$trans_number->is_unique) {
358
      $::lxdebug->leave_sub;
352 359
      return 3;
353 360
    }
354 361

  
362
    $form->{partnumber} = $trans_number->create_unique;
363

  
355 364
    ($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('id')|);
356
    do_query($form, $dbh, qq|INSERT INTO parts (id, partnumber, unit) VALUES (?, '', '')|, $form->{id});
365
    do_query($form, $dbh, qq|INSERT INTO parts (id, partnumber, unit) VALUES (?, ?, '')|, $form->{id}, $form->{partnumber});
357 366

  
358 367
    $form->{orphaned} = 1;
359
    if ($form->{partnumber} eq "" && $form->{"item"} eq "service") {
360
      $form->{partnumber} = $form->update_defaults($myconfig, "servicenumber");
361
    }
362
    if ($form->{partnumber} eq "" && $form->{"item"} ne "service") {
363
      $form->{partnumber} = $form->update_defaults($myconfig, "articlenumber");
364
    }
365

  
366 368
  }
367 369
  my $partsgroup_id = 0;
368 370

  

Auch abrufbar als: Unified diff