[freeside-commits] freeside/FS/FS prepay_credit.pm,1.10,1.10.4.1
Mark Wells
mark at wavetail.420.am
Tue Mar 9 13:58:11 PST 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv32170/FS/FS
Modified Files:
Tag: FREESIDE_1_9_BRANCH
prepay_credit.pm
Log Message:
RT#7407, variable length prepaid card codes
Index: prepay_credit.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/prepay_credit.pm,v
retrieving revision 1.10
retrieving revision 1.10.4.1
diff -u -w -d -r1.10 -r1.10.4.1
--- prepay_credit.pm 20 Feb 2008 02:07:01 -0000 1.10
+++ prepay_credit.pm 9 Mar 2010 21:58:09 -0000 1.10.4.1
@@ -136,7 +136,7 @@
=over 4
-=item generate NUM TYPE HASHREF
+=item generate NUM TYPE LENGTH HASHREF
Generates the specified number of prepaid cards. Returns an array reference of
the newly generated card identifiers, or a scalar error message.
@@ -145,11 +145,12 @@
#false laziness w/agent::generate_reg_codes
sub generate {
- my( $num, $type, $hashref ) = @_;
+ my( $num, $type, $length, $hashref ) = @_;
my @codeset = ();
push @codeset, ( 'A'..'Z' ) if $type =~ /alpha/;
push @codeset, ( '1'..'9' ) if $type =~ /numeric/;
+ $length ||= 8;
local $SIG{HUP} = 'IGNORE';
local $SIG{INT} = 'IGNORE';
@@ -167,7 +168,7 @@
my @cards = ();
for ( 1 ... $num ) {
- my $identifier = join('', map($codeset[int(rand $#codeset)], (0..7) ) );
+ my $identifier = join('', map($codeset[int(rand $#codeset)], (1..$length) ) );
redo if qsearchs('prepay_credit',{identifier=>$identifier}) && $condup++<23;
$condup = 0;
More information about the freeside-commits
mailing list