6 use Business::CreditCard;
7 use FS::UID qw(adminsuidsetup);
8 use FS::Record qw(qsearch);
16 #my @pkgs = ( 2, 3, 4 );
17 my @pkgs = ( 4, 5, 6 );
20 use vars qw( $opt_p );
23 my $user = shift or die &usage;
24 my $num = shift or die &usage;
25 adminsuidsetup($user);
30 until ( $num-- <= 0 ) {
32 my $faker = new Data::Faker;
34 my $cust_main = new FS::cust_main {
35 'agentnum' => $agentnum,
37 'first' => $faker->first_name,
38 'last' => $faker->last_name,
39 'company' => ( $num % 2 ? $faker->company. ', '. $faker->company_suffix : '' ), #half with companies..
40 'address1' => $faker->street_address,
41 'city' => 'Tofutown', #missing, so everyone is from tofutown# $faker->city,
42 'state' => $faker->us_state_abbr,
43 'zip' => $faker->us_zip_code,
45 'daytime' => $faker->phone_number,
46 'night' => $faker->phone_number,
47 #forget it, these can have extensions# 'fax' => ( $num % 2 ? $faker->phone_number : '' ), #ditto
48 #bah, forget shipping addresses
50 'payip' => $faker->ip_address,
53 if ( $opt_p eq 'CARD' || ( !$opt_p && rand() > .33 ) ) {
54 $cust_main->payby('CARD');
55 my $cardnum = '4123'. sprintf('%011u', int(rand(100000000000)) );
56 $cust_main->payinfo( $cardnum. generate_last_digit($cardnum) );
57 $cust_main->paydate( '2009-05-01' );
58 } elsif ( $opt_p eq 'CHEK' || ( !$opt_p && rand() > .66 ) ) {
59 $cust_main->payby('CHEK');
60 my $payinfo = sprintf('%7u@%09u', int(rand(10000000)), int(rand(1000000000)) );
61 $cust_main->payinfo($payinfo);
62 $cust_main->payname( 'First International Bank of Testing' );
65 # could insert invoicing_list and other stuff too.. hell, could insert
66 # packages, services, more
67 # but i just wanted 10k customers to test the pager and this was good enough
68 # not anymore, here's some services and packages
71 my $year = 31556736; #60*60*24*365.24
72 my $setup = $now - int(rand($year));
74 my $cust_pkg = new FS::cust_pkg {
75 'pkgpart' => $pkgs[ int(rand(scalar(@pkgs))) ],
77 #some dates in here would be nice
86 my $svc_acct = new FS::svc_acct {
87 'svcpart' => $svcpart,
88 'username' => $faker->username,
91 while ( qsearch( 'svc_acct', { 'username' => $svc_acct->username } ) ) {
92 my $username = $svc_acct->username;
94 $svc_acct->username($username);
98 tie my %hash, 'Tie::RefHash',
99 $cust_pkg => [ $svc_acct ],
102 my $error = $cust_main->insert( \%hash );
103 die $error if $error;
109 my $sec = $end-$start;
111 my $persec = $onum / $sec;
112 print "$onum customers inserted in $sec seconds ($persec customers/sec)\n";
117 die "Usage:\n\n customer-faker [ -p payby ] user num_fakes\n";