[freeside-commits] freeside/FS/FS pay_batch.pm,1.26,1.27

Mark Wells mark at wavetail.420.am
Thu Nov 11 19:21:33 PST 2010


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv19093

Modified Files:
	pay_batch.pm 
Log Message:
better support for batch-increment_expiration, RT#10453

Index: pay_batch.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/pay_batch.pm,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -w -d -r1.26 -r1.27
--- pay_batch.pm	21 Sep 2010 05:54:24 -0000	1.26
+++ pay_batch.pm	12 Nov 2010 03:21:31 -0000	1.27
@@ -7,6 +7,7 @@
 use FS::Record qw( dbh qsearch qsearchs );
 use FS::cust_pay;
 use FS::Conf;
+use Date::Parse qw(str2time);
 use Business::CreditCard qw(cardtype);
 
 @ISA = qw(FS::Record);
@@ -482,6 +483,19 @@
   my @cust_pay_batch = sort { $a->paybatchnum <=> $b->paybatchnum }
                       qsearch('cust_pay_batch', { batchnum => $self->batchnum } );
 
+  # handle batch-increment_expiration option
+  if ( $self->payby eq 'CARD' ) {
+    my ($cmon, $cyear) = (localtime(time))[4,5];
+    foreach (@cust_pay_batch) {
+      my $etime = str2time($_->exp) or next;
+      my ($day, $mon, $year) = (localtime($etime))[3,4,5];
+      if( $conf->exists('batch-increment_expiration') ) {
+        $year++ while( $year < $cyear or ($year == $cyear and $mon <= $cmon) );
+        $_->exp( sprintf('%4u-%02u-%02u', $year + 1900, $mon+1, $day) );
+      }
+      $_->setfield('expmmyy', sprintf('%02u%02u', $mon+1, $year % 100));
+    }
+  }
   my $h = $info->{'header'};
   if(ref($h) eq 'CODE') {
     $batch .= &$h($self, \@cust_pay_batch) . "\n";



More information about the freeside-commits mailing list