X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/b810b2e9c9384cace8b78db3e6acbc3916da5aea..c9c4734626e355fc52d91cb0e375b1864a49ccf6:/SL/TransNumber.pm diff --git a/SL/TransNumber.pm b/SL/TransNumber.pm index 4f8cb4345..210abc091 100644 --- a/SL/TransNumber.pm +++ b/SL/TransNumber.pm @@ -7,6 +7,7 @@ use parent qw(Rose::Object); use Carp; use List::MoreUtils qw(any none); use SL::DBUtils; +use SL::PrefixedNumber; use Rose::Object::MakeMethods::Generic ( @@ -129,16 +130,10 @@ SQL my $number = $business_number; ($number) = selectfirst_array_query($form, $self->dbh, qq|SELECT $filters{numberfield} FROM defaults|) if !$number; $number ||= ''; + my $sequence = SL::PrefixedNumber->new(number => $number); do { - if ($number =~ m/\d+$/) { - my $new_number = substr($number, $-[0]) * 1 + 1; - my $len_diff = length($number) - $-[0] - length($new_number); - $number = substr($number, 0, $-[0]) . ($len_diff > 0 ? '0' x $len_diff : '') . $new_number; - - } else { - $number = $number . '1'; - } + $number = $sequence->get_next; } while ($numbers_in_use{$number}); if ($self->save) {