From 9f3d1466f4dd917aeb07d7e85222d97e131062f1 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 11 Aug 2010 06:35:20 +0000 Subject: a better customer delete, RT#9564 --- bin/wipe-customers | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 bin/wipe-customers (limited to 'bin/wipe-customers') diff --git a/bin/wipe-customers b/bin/wipe-customers new file mode 100644 index 000000000..e65ed61be --- /dev/null +++ b/bin/wipe-customers @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +use strict; +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearch); +use FS::cust_main; + +die "this removes all customers in your database except for customer 1 - remove this line to enable"; + +my $user = shift or die "usage: wipe-customers username\n"; +adminsuidsetup $user; + +#this isn't terribly efficient, but the idea was clearing out a test database, +#not actually destroying a large amount of data + +foreach my $cust_main ( + + qsearch('cust_main', { 'custnum' => { op=>'!=', value=>'1' } } ) + +) { + + my @cerrors = $cust_main->cancel( quiet=>1, nobill=>1 ); + if ( @cerrors ) { + die join(' / ', @cerrors); + } + + my $error = $cust_main->delete( 'delete_financials' => 1); + die $error if $error; + +} -- cgit v1.2.1