4 use vars qw( $opt_a $opt_d );
6 use FS::UID qw(adminsuidsetup);
7 use FS::Record qw(qsearch);
10 die "i cancel and delete all customers of an agent - use the -d switch first and be careful - remove this line to enable";
14 my $user = shift or die "usage: wipe-agent -a agentnum [ -d ] username\n";
17 die "no agentnum specified" unless $opt_a;
19 foreach my $cust_main (
21 qsearch('cust_main', { 'agentnum' => $opt_a } )
25 warn "deleting ". $cust_main->custnum.': '. $cust_main->name. "\n";
27 unless ( $opt_d ) { #dry run
29 my @cerrors = $cust_main->cancel( quiet=>1, nobill=>1 );
31 die join(' / ', @cerrors);
34 my $error = $cust_main->delete( 'delete_financials' => 1);