1 <% include( 'elements/cust_main_dayranges.html',
2 'title' => 'Accounts Receivable Aging Summary',
3 'range_sub' => \&balance,
9 unless $FS::CurrentUser::CurrentUser->access_right('Receivables report')
10 or $FS::CurrentUser::CurrentUser->access_right('Financial reports');
17 # my $balance = balance(
19 # 'no_as' => 1, #set to true when using in a WHERE clause (supress AS clause)
20 # #or 0 / omit when using in a SELECT clause as a column
21 # # ("AS balance_$start_$end")
22 # 'sum' => 1, #set to true to get a SUM() of the values, for totals
24 # #obsolete? options for totals (passed to cust_main::balance_date_sql)
25 # 'total' => 1, #set to true to remove all customer comparison clauses
26 # 'join' => $join, #JOIN clause
27 # 'where' => \@where, #WHERE clause hashref (elements "AND"ed together)
31 my($start, $end) = @_; #, %opt ?
33 #handle start and end ranges (86400 = 24h * 60m * 60s)
34 my $str2time = str2time_sql;
35 my $closing = str2time_sql_closing;
36 $start = $start ? "( $str2time now() $closing - ".($start * 86400). ' )' : '';
37 $end = $end ? "( $str2time now() $closing - ".($end * 86400). ' )' : '';
39 #$opt{'unapplied_date'} = 1;
41 FS::cust_main->balance_date_sql( $start, $end, 'unapplied_date'=>1,);