[freeside-commits] freeside/bin customer-faker, 1.2,
1.3 payment-faker, NONE, 1.1
Ivan,,,
ivan at wavetail.420.am
Sun Nov 5 14:28:18 PST 2006
Update of /home/cvs/cvsroot/freeside/bin
In directory wavetail:/tmp/cvs-serv27281
Modified Files:
customer-faker
Added Files:
payment-faker
Log Message:
some sample data creators
Index: customer-faker
===================================================================
RCS file: /home/cvs/cvsroot/freeside/bin/customer-faker,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- customer-faker 8 Oct 2006 08:17:06 -0000 1.2
+++ customer-faker 5 Nov 2006 22:28:16 -0000 1.3
@@ -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 @@
# 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 $error = $cust_main->insert;
+ 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( \%hash );
die $error if $error;
}
--- NEW FILE: payment-faker ---
#!/usr/bin/perl
use Date::Parse;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch);
use FS::cust_pay;
use FS::cust_credit;
my $user;
$user = shift or die "usage: payment-faker $user";
adminsuidsetup($user);
for $month ( 1 .. 11 ) {
print "month $month\n";
system(qq!freeside-daily -d "$month/1/2006" $user!);
foreach my $cust_main ( qsearch('cust_main', {} ) ) {
next unless $cust_main->balance > 0;
my $item = '';
if ( rand() > .95 ) {
$item = new FS::cust_credit {
'amount' => $cust_main->balance,
'_date' => str2time("$month/1/2006"),
'reason' => 'testing',
};
} else {
if ( rand() > .5 ) {
$payby = 'BILL';
$payinfo = int(rand(10000));
} else {
$payby = 'CARD';
$payinfo = '4111111111111111';
}
$item = new FS::cust_pay {
'paid' => $cust_main->balance,
'_date' => str2time("$month/1/2006"),
'payby' => $payby,
'payinfo' => $payinfo,
};
}
$item->custnum($cust_main->custnum);
my $error = $item->insert;
die $error if $error;
$cust_main->apply_payments;
$cust_main->apply_credits;
}
}
More information about the freeside-commits
mailing list