Revision f50ddd66
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
SL/TransNumber.pm | ||
---|---|---|
7 | 7 |
use Carp; |
8 | 8 |
use List::MoreUtils qw(any none); |
9 | 9 |
use SL::DBUtils; |
10 |
use SL::PrefixedNumber; |
|
10 | 11 |
|
11 | 12 |
use Rose::Object::MakeMethods::Generic |
12 | 13 |
( |
... | ... | |
129 | 130 |
my $number = $business_number; |
130 | 131 |
($number) = selectfirst_array_query($form, $self->dbh, qq|SELECT $filters{numberfield} FROM defaults|) if !$number; |
131 | 132 |
$number ||= ''; |
133 |
my $sequence = SL::PrefixedNumber->new(number => $number); |
|
132 | 134 |
|
133 | 135 |
do { |
134 |
if ($number =~ m/\d+$/) { |
|
135 |
my $new_number = substr($number, $-[0]) * 1 + 1; |
|
136 |
my $len_diff = length($number) - $-[0] - length($new_number); |
|
137 |
$number = substr($number, 0, $-[0]) . ($len_diff > 0 ? '0' x $len_diff : '') . $new_number; |
|
138 |
|
|
139 |
} else { |
|
140 |
$number = $number . '1'; |
|
141 |
} |
|
136 |
$number = $sequence->get_next; |
|
142 | 137 |
} while ($numbers_in_use{$number}); |
143 | 138 |
|
144 | 139 |
if ($self->save) { |
Auch abrufbar als: Unified diff
SL::PrefixedNumber -- Nummernkreisartige Nummer erhöhen ohne Datenbank