summaryrefslogtreecommitdiff
path: root/bin/customer-faker
diff options
context:
space:
mode:
authorivan <ivan>2006-11-05 22:28:16 +0000
committerivan <ivan>2006-11-05 22:28:16 +0000
commit7d3f11ceb72d002c38825170ee87d8692e31c890 (patch)
tree32e61c77ec67c325fbbdc3e80621d933ee20c141 /bin/customer-faker
parent4fe74d42b872b1012ec0f35cd71bdd46ce6eec59 (diff)
some sample data creators
Diffstat (limited to 'bin/customer-faker')
-rwxr-xr-xbin/customer-faker44
1 files changed, 42 insertions, 2 deletions
diff --git a/bin/customer-faker b/bin/customer-faker
index 5ddc6d4..b4032d1 100755
--- a/bin/customer-faker
+++ b/bin/customer-faker
@@ -1,15 +1,22 @@
#!/usr/bin/perl
use strict;
+use Getopt::Std;
use Data::Faker;
use Business::CreditCard;
use FS::UID qw(adminsuidsetup);
+use FS::Record qw(qsearch);
use FS::cust_main;
-use Getopt::Std;
+use FS::cust_pkg;
+use FS::svc_acct;
my $agentnum = 1;
my $refnum = 1;
+#my @pkgs = ( 2, 3, 4 );
+my @pkgs = ( 4, 5, 6 );
+my $svcpart = 2;
+
use vars qw( $opt_p );
getopts('p:');
@@ -58,8 +65,41 @@ until ( $num-- <= 0 ) {
# 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
+ # not anymore, here's some services and packages
+
+ my $now = time;
+ my $year = 31556736; #60*60*24*365.24
+ my $setup = $now - int(rand($year));
+
+ my $cust_pkg = new FS::cust_pkg {
+ 'pkgpart' => $pkgs[ int(rand(scalar(@pkgs))) ],
+
+ #some dates in here would be nice
+ 'setup' => $setup,
+ #'last_bill'
+ #'bill'
+ #'susp'
+ #'expire'
+ #'cancel'
+ };
+
+ my $svc_acct = new FS::svc_acct {
+ 'svcpart' => $svcpart,
+ 'username' => $faker->username,
+ };
+
+ while ( qsearch( 'svc_acct', { 'username' => $svc_acct->username } ) ) {
+ my $username = $svc_acct->username;
+ $username++;
+ $svc_acct->username($username);
+ }
+
+ use Tie::RefHash;
+ tie my %hash, 'Tie::RefHash',
+ $cust_pkg => [ $svc_acct ],
+ ;
- my $error = $cust_main->insert;
+ my $error = $cust_main->insert( \%hash );
die $error if $error;
}