[freeside-commits] freeside/FS/FS/part_event/Condition once_every.pm, 1.2, 1.3 cust_paydate_within.pm, NONE, 1.1

Mark Wells mark at wavetail.420.am
Tue Jul 12 00:54:24 PDT 2011


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

Modified Files:
	once_every.pm 
Added Files:
	cust_paydate_within.pm 
Log Message:
credit card expiration event, #13202

--- NEW FILE: cust_paydate_within.pm ---
package FS::part_event::Condition::cust_paydate_within;

use strict;
use base qw( FS::part_event::Condition );
use FS::Record qw( str2time_sql str2time_sql_closing );
use Time::Local 'timelocal';

sub description {
  'Credit card expires within upcoming interval';
}

# Run the event when the customer's credit card expiration 
# date is less than X days in the future.
# Combine this with a "once_every" condition so that the event
# won't repeat every day until the expiration date.

sub eventtable_hashref {
    { 'cust_main' => 1,
      'cust_bill' => 0,
      'cust_pkg'  => 0,
    };
}

sub option_fields {
  (
    'within'  =>  { 'label'   => 'Expiration date within',
                    'type'    => 'freq',
                  },
  );
}

sub condition {
  my( $self, $cust_main, %opt ) = @_;
  my $expire_time = $cust_main->paydate_epoch or return 0;
  $opt{'time'} >= $self->option_age_from('within', $expire_time);
}

sub condition_sql {
  my ($self, $table, %opt) = @_;
  my $expire_time = FS::cust_main->paydate_epoch_sql or return 'true';
  $opt{'time'} . ' >= ' .  
    $self->condition_sql_option_age_from('within', $expire_time);
}

1;


Index: once_every.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_event/Condition/once_every.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- once_every.pm	25 Aug 2010 22:02:02 -0000	1.2
+++ once_every.pm	12 Jul 2011 07:54:22 -0000	1.3
@@ -31,7 +31,7 @@
                      'eventpart' => $self->eventpart,
                      'tablenum'  => $tablenum,
                      'status'    => { op=>'!=', value=>'failed'  },
-                     '_date'     => { op=>'>=', value=>$max_date },
+                     '_date'     => { op=>'>',  value=>$max_date },
                    },
     'extra_sql' => ( $opt{'cust_event'}->eventnum =~ /^(\d+)$/
                        ? " AND eventnum != $1 "



More information about the freeside-commits mailing list