[freeside-commits] branch FREESIDE_3_BRANCH updated. 760e803c76087f74788e65b63ea102d32a2af4ac

Ivan ivan at 420.am
Tue Nov 15 14:52:20 PST 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  760e803c76087f74788e65b63ea102d32a2af4ac (commit)
      from  12becc874109c0e063be8f7bfd1b0c68571e54c4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 760e803c76087f74788e65b63ea102d32a2af4ac
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Nov 15 14:52:19 2016 -0800

    add -t flag to bulk void for payment type, RT#73413

diff --git a/bin/bulk_void b/bin/bulk_void
index a142818..c75da5d 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;

-----------------------------------------------------------------------

Summary of changes:
 bin/bulk_void |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)




More information about the freeside-commits mailing list