[freeside-commits] freeside/httemplate/search/elements cust_main_dayranges.html, 1.10, 1.11

Mark Wells mark at wavetail.420.am
Thu Jul 29 09:41:33 PDT 2010


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

Modified Files:
	cust_main_dayranges.html 
Log Message:
aging report now uses DateTime, RT#9417

Index: cust_main_dayranges.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/search/elements/cust_main_dayranges.html,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -d -r1.10 -r1.11
--- cust_main_dayranges.html	22 Jul 2010 07:25:36 -0000	1.10
+++ cust_main_dayranges.html	29 Jul 2010 16:41:30 -0000	1.11
@@ -249,20 +249,25 @@
 # )
 
 sub call_range_sub {
-  my($range_sub, $start, $end, %opt) = @_;
+  my($range_sub, $startdays, $enddays, %opt) = @_;
 
-  my $as = $opt{'no_as'} ? '' : " AS rangecol_${start}_$end";
+  my $as = $opt{'no_as'} ? '' : " AS rangecol_${startdays}_$enddays";
 
   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 $cutoff = DateTime->now->set(hour => 23, minute => 59, second => 59);
+  $cutoff->subtract(days => $offset);
 
-  my $sql = &{$range_sub}( $start, $end, $cutoff ); #%opt?
+  my $start = $cutoff->clone;
+  $start->subtract(days => $startdays);
+ 
+  my $end = $cutoff->clone;
+  $end->subtract(days => $enddays);
+
+  #warn "offset $offset (".$cutoff->epoch."), range $startdays-$enddays (".$start->epoch . '-' . ($enddays ? $end->epoch : '').")\n";
+  my $sql = &{$range_sub}( $start->epoch, 
+                           $enddays ? $end->epoch : '', 
+                           $cutoff->epoch ); #%opt?
 
   $sql = "SUM($sql)" if $opt{'sum'};
 



More information about the freeside-commits mailing list