7 ( select sum(amount) from cust_bill_pay
8 where cust_bill.invnum = cust_bill_pay.invnum )
12 ( select sum(amount) from cust_credit_bill
13 where cust_bill.invnum = cust_credit_bill.invnum )
20 my $owed_cols = <<END;
22 ( select $charged from cust_bill
23 where cust_bill._date > extract(epoch from now())-2592000
24 and cust_main.custnum = cust_bill.custnum
30 ( select $charged from cust_bill
31 where cust_bill._date > extract(epoch from now())-5184000
32 and cust_bill._date <= extract(epoch from now())-2592000
33 and cust_main.custnum = cust_bill.custnum
39 ( select $charged from cust_bill
40 where cust_bill._date > extract(epoch from now())-7776000
41 and cust_bill._date <= extract(epoch from now())-5184000
42 and cust_main.custnum = cust_bill.custnum
48 ( select $charged from cust_bill
49 where cust_bill._date <= extract(epoch from now())-7776000
50 and cust_main.custnum = cust_bill.custnum
56 ( select $charged from cust_bill
57 where cust_main.custnum = cust_bill.custnum
65 select *, $owed_cols from cust_main
68 ( select $charged from cust_bill
69 where cust_main.custnum = cust_bill.custnum
74 order by company, last
78 my $total_sql = "select $owed_cols";
80 my $sth = dbh->prepare($sql) or die dbh->errstr;
81 $sth->execute or die $sth->errstr;
83 my $total_sth = dbh->prepare($total_sql) or die dbh->errstr;
84 $total_sth->execute or die $total_sth->errstr;
87 <%= header('Accounts Receivable Aging Summary', menubar( 'Main Menu'=>$p, ) ) %>
97 <% while ( my $row = $sth->fetchrow_hashref() ) { %>
99 <TD><A HREF="<%= $p %>view/cust_main.cgi?<%= $row->{'custnum'} %>">
100 <%= $row->{'company'} ? $row->{'company'}. ' (' : '' %>
101 <%= $row->{'last'}. ', '. $row->{'first'} %>
102 <%= $row->{'company'} ? ')' : '' %></A>
104 <TD ALIGN="right">$<%= sprintf("%.2f", $row->{'owed_0_30'} ) %></TD>
105 <TD ALIGN="right">$<%= sprintf("%.2f", $row->{'owed_30_60'} ) %></TD>
106 <TD ALIGN="right">$<%= sprintf("%.2f", $row->{'owed_60_90'} ) %></TD>
107 <TD ALIGN="right">$<%= sprintf("%.2f", $row->{'owed_90_plus'} ) %></TD>
108 <TD ALIGN="right"><B>$<%= sprintf("%.2f", $row->{'owed_total'} ) %></B></TD>
111 <% my $row = $total_sth->fetchrow_hashref(); %>
113 <TD COLSPAN=6> </TD>
116 <TD><I>Total</I></TD>
117 <TD ALIGN="right"><I>$<%= sprintf("%.2f", $row->{'owed_0_30'} ) %></TD>
118 <TD ALIGN="right"><I>$<%= sprintf("%.2f", $row->{'owed_30_60'} ) %></TD>
119 <TD ALIGN="right"><I>$<%= sprintf("%.2f", $row->{'owed_60_90'} ) %></TD>
120 <TD ALIGN="right"><I>$<%= sprintf("%.2f", $row->{'owed_90_plus'} ) %></TD>
121 <TD ALIGN="right"><I><B>$<%= sprintf("%.2f", $row->{'owed_total'} ) %></B></I></TD>