[freeside-commits] freeside/FS/bin freeside-void-payments,1.2,1.3
Mark Wells
mark at wavetail.420.am
Thu Jul 23 22:51:21 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail.420.am:/tmp/cvs-serv1284
Modified Files:
freeside-void-payments
Log Message:
Add -v switch (verbose) to freeside-void-payments
Index: freeside-void-payments
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-void-payments,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- freeside-void-payments 23 Jul 2009 19:40:28 -0000 1.2
+++ freeside-void-payments 24 Jul 2009 05:51:19 -0000 1.3
@@ -8,13 +8,14 @@
use FS::Conf;
use FS::cust_main;
use FS::cust_pay;
+use FS::cust_pay_void;
use Business::OnlinePayment; # For retrieving the void list only.
use Time::Local;
use Date::Parse 'str2time';
use Date::Format 'time2str';
my %opt;
-getopts("r:f:ca:g:s:e:", \%opt);
+getopts("r:f:ca:g:s:e:vn", \%opt);
$user = shift or die &usage;
&adminsuidsetup( $user );
@@ -80,20 +81,41 @@
}
$opt{'r'} ||= 'freeside-void-payments';
-
+my $success = 0;
+my $notfound = 0;
+print "Voiding ".scalar(@auths)." transactions:\n" if $opt{'v'};
foreach my $authnum (@auths) {
my $paybatch = $gatewaynum . $processor . ':' . $authnum;
my $cust_pay = qsearchs('cust_pay', { paybatch => $paybatch } );
+ my $error;
if($cust_pay) {
- $cust_pay->void($opt{'r'});
+ $error = $cust_pay->void($opt{'r'});
+ $success++ if not $error;
}
else {
- warn "cust_pay record not found: '$paybatch'";
+ my $cpv = qsearchs('cust_pay_void', { paybatch => $paybatch });
+ if($cpv) {
+ $error = 'already voided '.time2str('%Y-%m-%d', $cpv->void_date) .
+ ' by ' . $cpv->otaker;
+ }
+ else {
+ $error = 'not found';
+ $notfound++;
+ }
}
+ if($opt{'v'}) {
+ print $authnum;
+ print "\t($error)" if $error;
+ print "\n";
+ }
+}
+
+if($opt{'v'}) {
+ print scalar(@auths)." transactions: $success voided, $notfound not found\n";
}
sub usage {
- die "Usage:\n\n freeside-void-payments [ -f file | [ -s start-date ] [ -e end-date ] ] [ -r 'reason' ] [ -g gatewaynum | -a agentnum ] [ -c ] user\n";
+ die "Usage:\n\n freeside-void-payments [ -f file | [ -s start-date ] [ -e end-date ] ] [ -r 'reason' ] [ -g gatewaynum | -a agentnum ] [ -c ] [ -v ] [ -n ]user\n";
}
__END__
@@ -106,7 +128,7 @@
=head1 SYNOPSIS
- freeside-void-payments [ -f file | [ -s start-date ] [ -e end-date ] ] [ -r 'reason' ] [ -g gatewaynum | -a agentnum ] [ -c ] user
+ freeside-void-payments [ -f file | [ -s start-date ] [ -e end-date ] ] [ -r 'reason' ] [ -g gatewaynum | -a agentnum ] [ -c ] [ -v ] [ -n ] user
=head1 DESCRIPTION
@@ -145,6 +167,8 @@
-c: Use the default gateway for check transactions rather than
credit cards.
+ -v: Be verbose.
+
A warning will be emitted for each transaction that can't be found.
This may happen if it's already been voided, or if the gateway
doesn't match.
More information about the freeside-commits
mailing list