summaryrefslogtreecommitdiff
path: root/FS/FS/pay_batch.pm
diff options
context:
space:
mode:
authormark <mark>2010-11-12 03:21:31 +0000
committermark <mark>2010-11-12 03:21:31 +0000
commitcefae4ba10cf42b5fc48bc63ef9aee861f6e8b2a (patch)
tree5d9aa441621279cd75bd1266b25bbcf7a63a392a /FS/FS/pay_batch.pm
parent886357c11bf29fc9edd1113ef81d51efe5bf9ca7 (diff)
better support for batch-increment_expiration, RT#10453
Diffstat (limited to 'FS/FS/pay_batch.pm')
-rw-r--r--FS/FS/pay_batch.pm16
1 files changed, 15 insertions, 1 deletions
diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm
index afff261..b5ef85b 100644
--- a/FS/FS/pay_batch.pm
+++ b/FS/FS/pay_batch.pm
@@ -7,6 +7,7 @@ use Text::CSV_XS;
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);
@@ -481,7 +482,20 @@ sub export_batch {
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";