X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Freport_receivables.cgi;h=3696ed40d25bf9df4de55ab28a8106bb8a957e96;hb=7b125e587a4d1ee0aca692e23ea7897f671855ae;hp=a11fb81a56b627dbbfe59b8963a86a6a52b3a8c0;hpb=0cc20c3d66e50d640422c2d587d97ddf7768493b;p=freeside.git diff --git a/httemplate/search/report_receivables.cgi b/httemplate/search/report_receivables.cgi index a11fb81a5..3696ed40d 100755 --- a/httemplate/search/report_receivables.cgi +++ b/httemplate/search/report_receivables.cgi @@ -1,6 +1,7 @@ <% include( 'elements/cust_main_dayranges.html', 'title' => 'Accounts Receivable Aging Summary', 'range_sub' => \&balance, + 'payment_links' => 1, ) %> <%init> @@ -15,7 +16,7 @@ die "access denied" #Example: # # my $balance = balance( -# $start, $end, +# $start, $end, $offset, # 'no_as' => 1, #set to true when using in a WHERE clause (supress AS clause) # #or 0 / omit when using in a SELECT clause as a column # # ("AS balance_$start_$end") @@ -28,17 +29,23 @@ die "access denied" # ) sub balance { - my($start, $end) = @_; #, %opt ? - + my($start, $end, $offset) = @_; #, %opt ? #handle start and end ranges (86400 = 24h * 60m * 60s) my $str2time = str2time_sql; my $closing = str2time_sql_closing; - $start = $start ? "( $str2time now() $closing - ".($start * 86400). ' )' : ''; - $end = $end ? "( $str2time now() $closing - ".($end * 86400). ' )' : ''; + + # $end == 0 means "+infinity", while $start == 0 really means 0 + # so we should always include a start condition + $start = "( $str2time now() $closing - ". ($start + $offset) * 86400 . ' )'; + # but only include an end condition if $end != 0 + $end = $end ? + "( $str2time now() $closing - ". ($end + $offset) * 86400 . ' )' + : ''; #$opt{'unapplied_date'} = 1; - FS::cust_main->balance_date_sql( $start, $end, 'unapplied_date'=>1,). + FS::cust_main->balance_date_sql( $start, $end, 'unapplied_date'=>1, + 'cutoff' => "( $str2time now() $closing - ".$offset * 86400 . ')' ); }