[freeside-commits] freeside/httemplate/search/elements cust_main_dayranges.html, 1.2.2.6, 1.2.2.7

Mark Wells mark at wavetail.420.am
Thu Jul 22 00:25:52 PDT 2010


Update of /home/cvs/cvsroot/freeside/httemplate/search/elements
In directory wavetail.420.am:/tmp/cvs-serv15658/httemplate/search/elements

Modified Files:
      Tag: FREESIDE_1_9_BRANCH
	cust_main_dayranges.html 
Log Message:
Fix weird behavior of aging report, RT#9234

Index: cust_main_dayranges.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/cust_main_dayranges.html,v
retrieving revision 1.2.2.6
retrieving revision 1.2.2.7
diff -u -w -d -r1.2.2.6 -r1.2.2.7
--- cust_main_dayranges.html	11 Jun 2010 21:18:11 -0000	1.2.2.6
+++ cust_main_dayranges.html	22 Jul 2010 07:25:48 -0000	1.2.2.7
@@ -11,6 +11,7 @@
     my( $start, $end ) = @_;
 
     "SQL EXPRESSION BASED ON $start AND $end";
+    # where $start and $end are unix timestamps
   };
 
 </%doc>
@@ -252,7 +253,16 @@
 
   my $as = $opt{'no_as'} ? '' : " AS rangecol_${start}_$end";
 
-  my $sql = &{$range_sub}( $start, $end, $opt{'offset'} ); #%opt?
+  my $offset = $opt{'offset'} || 0;
+  # Time::ParseDate for excruciating correctness
+  # Always use $offset - 1day + 1sec = the last second of that day
+  $start =  parsedate('00:00 '.($start + $offset - 1).' days ago') - 1;
+  $end = $end ?
+            parsedate('00:00 '.($end + $offset - 1).' days ago') - 1 : 
+            '';
+  my $cutoff = parsedate('00:00 '.($offset - 1).' days ago') - 1;
+
+  my $sql = &{$range_sub}( $start, $end, $cutoff ); #%opt?
 
   $sql = "SUM($sql)" if $opt{'sum'};
 



More information about the freeside-commits mailing list