X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fprepay_credit.pm;h=302ba37c75e62f0049b7f7938d31f91db47f0830;hb=2f8f5c1d17ad9854613edc265e08c066a5d5d9d9;hp=92f2a303247f3d8d852107a77ee03894d37dd177;hpb=f93e5e60d4f995eabf4d660ce618a9e83c5d31a2;p=freeside.git diff --git a/FS/FS/prepay_credit.pm b/FS/FS/prepay_credit.pm index 92f2a3032..302ba37c7 100644 --- a/FS/FS/prepay_credit.pm +++ b/FS/FS/prepay_credit.pm @@ -61,7 +61,7 @@ fields are currently supported: =item new HASHREF -Creates a new pre-paid credit. To add the example to the database, see +Creates a new pre-paid credit. To add the pre-paid credit to the database, see L<"insert">. Note that this stores the hash reference, not a distinct copy of the hash it @@ -110,6 +110,9 @@ sub check { || $self->ut_alpha('identifier') || $self->ut_money('amount') || $self->ut_numbern('seconds') + || $self->ut_numbern('upbytes') + || $self->ut_numbern('downbytes') + || $self->ut_numbern('totalbytes') || $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum') || $self->SUPER::check ; @@ -159,10 +162,18 @@ sub generate { local $FS::UID::AutoCommit = 0; my $dbh = dbh; + my $condup = 0; #don't retry forever + my @cards = (); for ( 1 ... $num ) { + + my $identifier = join('', map($codeset[int(rand $#codeset)], (0..7) ) ); + + redo if qsearchs('prepay_credit',{identifier=>$identifier}) && $condup++<23; + $condup = 0; + my $prepay_credit = new FS::prepay_credit { - 'identifier' => join('', map($codeset[int(rand $#codeset)], (0..7) ) ), + 'identifier' => $identifier, %$hashref, }; my $error = $prepay_credit->check || $prepay_credit->insert;