RT#7266: continue fixing aging reports
authormark <mark>
Fri, 11 Jun 2010 21:18:11 +0000 (21:18 +0000)
committermark <mark>
Fri, 11 Jun 2010 21:18:11 +0000 (21:18 +0000)
FS/FS/cust_main.pm
FS/FS/cust_pay.pm
FS/FS/cust_refund.pm
httemplate/search/elements/cust_main_dayranges.html
httemplate/search/unapplied_cust_pay.html

index 0e04df3..de39874 100644 (file)
@@ -8301,9 +8301,11 @@ Available options are:
 =cut
 
 sub unapplied_payments_date_sql {
-  my( $class, $start, $end, ) = @_;
+  my( $class, $start, $end, %opt ) = @_;
+
+  my $cutoff = $opt{'cutoff'};
 
-  my $unapp_pay    = FS::cust_pay->unapplied_sql;
+  my $unapp_pay    = FS::cust_pay->unapplied_sql($cutoff);
 
   my $pay_where = $class->_money_table_where( 'cust_pay', $start, $end,
                                                           'unapplied_date'=>1 );
index f9185cc..a78cb5d 100644 (file)
@@ -657,7 +657,7 @@ Returns an SQL fragment to retreive the unapplied amount.
 =cut 
 
 sub unapplied_sql {
-  my ($class, $start, $end) = shift;
+  my ($class, $start, $end) = @_;
   my $bill_start   = $start ? "AND cust_bill_pay._date <= $start"   : '';
   my $bill_end     = $end   ? "AND cust_bill_pay._date > $end"     : '';
   my $refund_start = $start ? "AND cust_pay_refund._date <= $start" : '';
index 894d190..044d16c 100644 (file)
@@ -321,7 +321,7 @@ Returns an SQL fragment to retreive the unapplied amount.
 =cut 
 
 sub unapplied_sql {
-  my ($class, $start, $end) = shift;
+  my ($class, $start, $end) = @_;
   my $credit_start = $start ? "AND cust_credit_refund._date <= $start" : '';
   my $credit_end   = $end   ? "AND cust_credit_refund._date > $end"   : '';
   my $pay_start    = $start ? "AND cust_pay_refund._date <= $start"    : '';
index 476f138..aa13388 100644 (file)
@@ -145,7 +145,7 @@ unless ( $cgi->param('all_customers') ) {
   }
 
   push @where,
-    call_range_sub($range_sub, $days + $offset, 0, 'no_as'=>1). ' > 0'; # != 0';
+    call_range_sub($range_sub, $days, 0, 'offset' => $offset, 'no_as'=>1). ' > 0'; # != 0';
 }
 
 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
index 73361c0..161c650 100755 (executable)
@@ -23,7 +23,8 @@ sub unapplied_payments {
            "( $str2time now() $closing - ".($end   + $offset) * 86400 . ' )'
            : '';
 
-  FS::cust_main->unapplied_payments_date_sql( $start, $end );
+  FS::cust_main->unapplied_payments_date_sql( $start, $end, 
+          'cutoff' => "( $str2time now() $closing - ".$offset * 86400 . ')'  );
 
 }