X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fbulk_void;h=8f0c882a8032a4a6d4f6c406486afc4d96ea5378;hp=a1428180e3fe16296a068b857f7767602b584008;hb=29d80a8582103ead0b5910391cabc45cb85fa836;hpb=6613f62b2d2de673cc9a83646054761402389f7f diff --git a/bin/bulk_void b/bin/bulk_void index a1428180e..8f0c882a8 100755 --- a/bin/bulk_void +++ b/bin/bulk_void @@ -1,9 +1,13 @@ #!/usr/bin/perl +use strict; +use warnings; +use vars qw( %opt ); use FS::Misc::Getopt; use FS::Record qw(qsearch qsearchs dbh); -getopts('cpifXr:'); +getopts('cpiXr:t:'); + my $dbh = dbh; $FS::UID::AutoCommit = 0; @@ -11,11 +15,13 @@ sub usage() { "Usage: bulk_void -s start -e end -r void_reason { -c | -p | -i } + [ -t payby ] [ -X ] -s, -e: date range (required) -r: void reason text (required) --c, -p, -i, -f: void credits, payments, invoices +-c, -p, -i: void credits, payments, invoices +-t: only void payments with this payby -X: commit changes "; } @@ -26,7 +32,11 @@ if (!$opt{start} or !$opt{end} or !$opt{r}) { print "DRY RUN--changes will not be committed.\n" unless $opt{X}; -my $date = " WHERE _date >= $opt{start} AND _date <= $opt{end}"; +my %search = (); +$search{payby} = $opt{t} if $opt{t} && $opt{p}; + +my $date = (keys %search ? ' AND ' : ' WHERE '). + " _date >= $opt{start} AND _date <= $opt{end}"; my %tables = ( c => 'cust_credit', @@ -45,6 +55,7 @@ foreach my $k (keys %tables) { my $cursor = FS::Cursor->new({ table => $table, + hashref => \%search, extra_sql => $date, }); my $error;