From: Moritz Bunkus Date: Tue, 7 Jan 2014 15:10:05 +0000 (+0100) Subject: Kunden-/Lieferantennummern erzeugen bei Kunden-/Lieferantentyp gefixt X-Git-Tag: release-3.1.0beta1~22^2~22^2~21^2~7^2 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=4978ae56d7df54633be060c4adc50f20e3ba677d;p=kivitendo-erp.git Kunden-/Lieferantennummern erzeugen bei Kunden-/Lieferantentyp gefixt --- diff --git a/SL/DB/Helper/TransNumberGenerator.pm b/SL/DB/Helper/TransNumberGenerator.pm index 6cdc281a8..cc5fc327c 100644 --- a/SL/DB/Helper/TransNumberGenerator.pm +++ b/SL/DB/Helper/TransNumberGenerator.pm @@ -53,7 +53,8 @@ sub get_next_trans_number { require SL::DB::Default; require SL::DB::Business; - my %conditions = ( query => [ $scoping_conditions ? $scoping_conditions->($spec_type) : () ] ); + my %conditions = ( query => [ $scoping_conditions ? $scoping_conditions->($spec_type) : () ] ); + my %conditions_for_in_use = ( query => [ $scoping_conditions ? $scoping_conditions->($spec_type) : () ] ); my $business; if ($spec_type =~ m{^(?:customer|vendor)$}) { @@ -69,15 +70,17 @@ sub get_next_trans_number { } } - my @numbers = map { $_->$number_column } @{ $self->_get_manager_class->get_all(%conditions) }; - my %numbers_in_use = map { ( $_ => 1 ) } @numbers; + my %numbers_in_use = map { ( $_->$number_column => 1 ) } @{ $self->_get_manager_class->get_all(%conditions_for_in_use) }; my $range_table = $business ? $business : SL::DB::Default->get; my $start_number = $range_table->$number_range_column; $start_number = $range_table->articlenumber if ($number_range_column eq 'assemblynumber') && (length($start_number) < 1); my $sequence = SL::PrefixedNumber->new(number => $start_number); - $sequence->set_to_max(@numbers) if !$fill_holes_in_range; + if (!$fill_holes_in_range) { + my @numbers = map { $_->$number_column } @{ $self->_get_manager_class->get_all(%conditions) }; + $sequence->set_to_max(@numbers) ; + } my $new_number = $sequence->get_next; $new_number = $sequence->get_next while $numbers_in_use{$new_number};