1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#!/usr/bin/perl
use strict;
use Data::Faker;
use Business::CreditCard;
use FS::UID qw(adminsuidsetup);
use FS::cust_main;
use Getopt::Std;
my $agentnum = 1;
my $refnum = 1;
use vars qw( $opt_p );
getopts('p:');
my $user = shift or die &usage;
my $num = shift or die &usage;
adminsuidsetup($user);
my $onum = $num;
my $start = time;
until ( $num-- <= 0 ) {
my $faker = new Data::Faker;
my $cust_main = new FS::cust_main {
'agentnum' => $agentnum,
'refnum' => $refnum,
'first' => $faker->first_name,
'last' => $faker->last_name,
'company' => ( $num % 2 ? $faker->company. ', '. $faker->company_suffix : '' ), #half with companies..
'address1' => $faker->street_address,
'city' => 'Tofutown', #missing, so everyone is from tofutown# $faker->city,
'state' => $faker->us_state_abbr,
'zip' => $faker->us_zip_code,
'country' => 'US',
'daytime' => $faker->phone_number,
'night' => $faker->phone_number,
#forget it, these can have extensions# 'fax' => ( $num % 2 ? $faker->phone_number : '' ), #ditto
#bah, forget shipping addresses
'payby' => 'BILL',
'payip' => $faker->ip_address,
};
if ( $opt_p eq 'CARD' || ( !$opt_p && rand() > .33 ) ) {
$cust_main->payby('CARD');
my $cardnum = '4123'. sprintf('%011u', int(rand(100000000000)) );
$cust_main->payinfo( $cardnum. generate_last_digit($cardnum) );
$cust_main->paydate( '2009-05-01' );
} elsif ( $opt_p eq 'CHEK' || ( !$opt_p && rand() > .66 ) ) {
$cust_main->payby('CHEK');
my $payinfo = sprintf('%7u@%09u', int(rand(10000000)), int(rand(1000000000)) );
$cust_main->payinfo($payinfo);
$cust_main->payname( 'First International Bank of Testing' );
}
# could insert invoicing_list and other stuff too.. hell, could insert
# packages, services, more
# but i just wanted 10k customers to test the pager and this was good enough
my $error = $cust_main->insert;
die $error if $error;
}
my $end = time;
my $sec = $end-$start;
$sec=1 if $sec==0;
my $persec = $onum / $sec;
print "$onum customers inserted in $sec seconds ($persec customers/sec)\n";
#---
sub usage {
die "Usage:\n\n customer-faker [ -p payby ] user num_fakes\n";
}
|