[freeside-commits] freeside/FS/FS/part_event/Condition cust_bill_past_due.pm, 1.2, 1.3

Mark Wells mark at wavetail.420.am
Fri Dec 2 14:11:41 PST 2011


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

Modified Files:
	cust_bill_past_due.pm 
Log Message:
adjustable delay for invoice past due condition, #15069

Index: cust_bill_past_due.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_event/Condition/cust_bill_past_due.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- cust_bill_past_due.pm	18 Sep 2010 04:28:45 -0000	1.2
+++ cust_bill_past_due.pm	2 Dec 2011 22:11:39 -0000	1.3
@@ -17,25 +17,31 @@
     };
 }
 
+sub option_fields {
+  (
+    'delay' => { label  => 'Delay additional days',
+      type   => 'text',
+      value  => '0',
+    },
+  );
+}
+
 sub condition {
   my($self, $cust_bill, %opt) = @_;
 
-  # If the invoice date is 1/1 at noon and the terms are Net 15,
-  # the due_date will be 1/16 at noon.  Past due events will not 
-  # trigger until after the start of 1/17.
+  my $delay = $self->option('delay') || 0;
   my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($opt{'time'}))[0..5];
-  my $start_of_today = timelocal(0,0,0,$mday,$mon,$year)+1;
-  ($cust_bill->due_date || $cust_bill->_date) < $start_of_today;
+  my $as_of = timelocal(0,0,0,$mday,$mon,$year) - $delay * 86400;
+  $as_of >= ($cust_bill->due_date || $cust_bill->_date);
 }
 
 sub condition_sql {
-  return 'true' if $FS::UID::driver_name ne 'Pg';
   my( $class, $table, %opt ) = @_;
+  return 'true' if $opt{'driver_name'} ne 'Pg';
+  my $delay = $class->condition_sql_option_integer('delay', 'Pg');
   my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($opt{'time'}))[0..5];
-  my $start_of_today = timelocal(0,0,0,$mday,$mon,$year)+1;
-
-  FS::cust_bill->due_date_sql . " < $start_of_today";
-
+  my $as_of = timelocal(0,0,0,$mday,$mon,$year) . " - ($delay * 86400)";
+  "( $as_of ) >= ".FS::cust_bill->due_date_sql;
 }
 
 1;



More information about the freeside-commits mailing list