Revision 4978ae56
Von Moritz Bunkus vor fast 11 Jahren hinzugefügt
SL/DB/Helper/TransNumberGenerator.pm | ||
---|---|---|
53 | 53 |
require SL::DB::Default; |
54 | 54 |
require SL::DB::Business; |
55 | 55 |
|
56 |
my %conditions = ( query => [ $scoping_conditions ? $scoping_conditions->($spec_type) : () ] ); |
|
56 |
my %conditions = ( query => [ $scoping_conditions ? $scoping_conditions->($spec_type) : () ] ); |
|
57 |
my %conditions_for_in_use = ( query => [ $scoping_conditions ? $scoping_conditions->($spec_type) : () ] ); |
|
57 | 58 |
|
58 | 59 |
my $business; |
59 | 60 |
if ($spec_type =~ m{^(?:customer|vendor)$}) { |
... | ... | |
69 | 70 |
} |
70 | 71 |
} |
71 | 72 |
|
72 |
my @numbers = map { $_->$number_column } @{ $self->_get_manager_class->get_all(%conditions) }; |
|
73 |
my %numbers_in_use = map { ( $_ => 1 ) } @numbers; |
|
73 |
my %numbers_in_use = map { ( $_->$number_column => 1 ) } @{ $self->_get_manager_class->get_all(%conditions_for_in_use) }; |
|
74 | 74 |
|
75 | 75 |
my $range_table = $business ? $business : SL::DB::Default->get; |
76 | 76 |
my $start_number = $range_table->$number_range_column; |
77 | 77 |
$start_number = $range_table->articlenumber if ($number_range_column eq 'assemblynumber') && (length($start_number) < 1); |
78 | 78 |
my $sequence = SL::PrefixedNumber->new(number => $start_number); |
79 | 79 |
|
80 |
$sequence->set_to_max(@numbers) if !$fill_holes_in_range; |
|
80 |
if (!$fill_holes_in_range) { |
|
81 |
my @numbers = map { $_->$number_column } @{ $self->_get_manager_class->get_all(%conditions) }; |
|
82 |
$sequence->set_to_max(@numbers) ; |
|
83 |
} |
|
81 | 84 |
|
82 | 85 |
my $new_number = $sequence->get_next; |
83 | 86 |
$new_number = $sequence->get_next while $numbers_in_use{$new_number}; |
Auch abrufbar als: Unified diff
Kunden-/Lieferantennummern erzeugen bei Kunden-/Lieferantentyp gefixt