From: Moritz Bunkus Date: Mon, 17 Jan 2011 11:37:10 +0000 (+0100) Subject: Beim Anlegen von Kunden-/Lieferantennummern Lücken im Nummernkreis richtig behandeln X-Git-Tag: release-2.6.2beta2~14 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=becda06d038cfbcc3b69fbdfa4b89447626e7cab;p=kivitendo-erp.git Beim Anlegen von Kunden-/Lieferantennummern Lücken im Nummernkreis richtig behandeln Fix für Bug 1553. --- diff --git a/SL/CT.pm b/SL/CT.pm index 3c17ca535..58a460039 100644 --- a/SL/CT.pm +++ b/SL/CT.pm @@ -44,6 +44,7 @@ use SL::CVar; use SL::DBUtils; use SL::FU; use SL::Notes; +use SL::TransNumber; use strict; @@ -261,21 +262,12 @@ sub save_customer { } } else { - if (!$form->{customernumber} && $form->{business}) { - $form->{customernumber} = - $form->update_business($myconfig, $form->{business}, $dbh); - } - if (!$form->{customernumber}) { - $form->{customernumber} = - $form->update_defaults($myconfig, "customernumber", $dbh); - } - - $query = qq|SELECT c.id FROM customer c WHERE c.customernumber = ?|; - ($f_id) = selectrow_query($form, $dbh, $query, $form->{customernumber}); - if ($f_id ne "") { - $main::lxdebug->leave_sub(); - return 3; - } + my $customernumber = SL::TransNumber->new(type => 'customer', + dbh => $dbh, + number => $form->{customernumber}, + business_id => $form->{business}, + save => 1); + $form->{customernumber} = $customernumber->create_unique unless $customernumber->is_unique; $query = qq|SELECT nextval('id')|; ($form->{id}) = selectrow_query($form, $dbh, $query); @@ -488,9 +480,11 @@ sub save_vendor { $query = qq|INSERT INTO vendor (id, name) VALUES (?, '')|; do_query($form, $dbh, $query, $form->{id}); - if ( !$form->{vendornumber} ) { - $form->{vendornumber} = $form->update_defaults( $myconfig, "vendornumber", $dbh ); - } + my $vendornumber = SL::TransNumber->new(type => 'vendor', + dbh => $dbh, + number => $form->{vendornumber}, + save => 1); + $form->{vendornumber} = $vendornumber->create_unique unless $vendornumber->is_unique; } $query =