#!/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;
"Usage: bulk_void -s start -e end
-r void_reason
{ -c | -p | -i }
+ [ -t payby ]
[ -X ]
<user>
-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
";
}
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',
my $cursor = FS::Cursor->new({
table => $table,
+ hashref => \%search,
extra_sql => $date,
});
my $error;