1 <% include( 'elements/cust_main_dayranges.html',
2 'title' => 'Accounts Receivable Aging Summary',
3 'range_sub' => \&balance,
10 unless $FS::CurrentUser::CurrentUser->access_right('Receivables report')
11 or $FS::CurrentUser::CurrentUser->access_right('Financial reports');
18 # my $balance = balance(
19 # $start, $end, $offset,
20 # 'no_as' => 1, #set to true when using in a WHERE clause (supress AS clause)
21 # #or 0 / omit when using in a SELECT clause as a column
22 # # ("AS balance_$start_$end")
23 # 'sum' => 1, #set to true to get a SUM() of the values, for totals
25 # #obsolete? options for totals (passed to cust_main::balance_date_sql)
26 # 'total' => 1, #set to true to remove all customer comparison clauses
27 # 'join' => $join, #JOIN clause
28 # 'where' => \@where, #WHERE clause hashref (elements "AND"ed together)
32 my($start, $end, $offset) = @_; #, %opt ?
33 #handle start and end ranges (86400 = 24h * 60m * 60s)
34 my $str2time = str2time_sql;
35 my $closing = str2time_sql_closing;
37 # $end == 0 means "+infinity", while $start == 0 really means 0
38 # so we should always include a start condition
39 $start = "( $str2time now() $closing - ". ($start + $offset) * 86400 . ' )';
40 # but only include an end condition if $end != 0
42 "( $str2time now() $closing - ". ($end + $offset) * 86400 . ' )'
45 #$opt{'unapplied_date'} = 1;
47 FS::cust_main->balance_date_sql( $start, $end, 'unapplied_date'=>1,
48 'cutoff' => "( $str2time now() $closing - ".$offset * 86400 . ')' );