X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fbulk_void;h=b12b5a97238a7e83a0da442132b5d2996a8989a2;hp=a1428180e3fe16296a068b857f7767602b584008;hb=1f2021c9b76da7cc59e2a981fbac6b24312876d2;hpb=1aecd5bf33146bf3f374341a3814960ae1d419e8 diff --git a/bin/bulk_void b/bin/bulk_void index a1428180e..b12b5a972 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 "; } @@ -28,6 +34,9 @@ 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 %tables = ( c => 'cust_credit', p => 'cust_pay', @@ -45,6 +54,7 @@ foreach my $k (keys %tables) { my $cursor = FS::Cursor->new({ table => $table, + hashref => \%search, extra_sql => $date, }); my $error;