diff options
author | Ivan Kohler <ivan@freeside.biz> | 2016-11-15 14:52:17 -0800 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2016-11-15 14:52:17 -0800 |
commit | 69a70c66135ece60c08584cf3b931b4ff141c47a (patch) | |
tree | 53966548e946d5b12582c19815736ce2f64598b8 /bin | |
parent | 8568f687b70154d27c32fe16b0d018420807ded1 (diff) |
add -t flag to bulk void for payment type, RT#73413
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bulk_void | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/bin/bulk_void b/bin/bulk_void index a1428180e..c75da5d16 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('s:e:cpiXr:t:'); + my $dbh = dbh; $FS::UID::AutoCommit = 0; @@ -11,22 +15,27 @@ sub usage() { "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 "; } -if (!$opt{start} or !$opt{end} or !$opt{r}) { +if (!$opt{s} or !$opt{e} or !$opt{r}) { die usage; } print "DRY RUN--changes will not be committed.\n" unless $opt{X}; -my $date = " WHERE _date >= $opt{start} AND _date <= $opt{end}"; +my $date = " WHERE _date >= $opt{s} AND _date <= $opt{e}"; + +my %search = (); +$search{payby} = $opt{t} if $opt{t} && $opt{p}; my %tables = ( c => 'cust_credit', @@ -45,6 +54,7 @@ foreach my $k (keys %tables) { my $cursor = FS::Cursor->new({ table => $table, + hashref => \%search, extra_sql => $date, }); my $error; |