1 <% include('elements/monthly.html',
2 'title' => $agentname. $referralname.
3 'Sales, Credits and Receipts Summary',
6 'graph_labels' => \%graph_label,
9 'agentnum' => $agentnum,
11 'cust_classnum'=> \@classnums,
12 'nototal' => scalar($cgi->param('12mo')),
18 unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
21 my( $agentnum, $agent ) = ('', '');
22 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
24 $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
25 die "agentnum $agentnum not found!" unless $agent;
27 my $agentname = $agent ? $agent->agent.' ' : '';
30 if ( $cgi->param('cust_classnum') ) {
31 @classnums = grep /^\d+$/, $cgi->param('cust_classnum');
34 my( $refnum, $part_referral ) = ('', '');
35 if ( $cgi->param('refnum') =~ /^(\d+)$/ ) {
37 $part_referral = qsearchs('part_referral', { 'refnum' => $refnum } );
38 die "refnum $refnum not found!" unless $part_referral;
40 my $referralname = $part_referral ? $part_referral->referral.' ' : '';
43 my @items = qw( invoiced netsales
49 if ( $cgi->param('12mo') == 1 ) {
50 @items = map $_.'_12mo', @items;
54 'invoiced' => 'Gross Sales',
55 'netsales' => 'Net Sales',
56 'credits' => 'Gross Credits',
57 'netcredits' => 'Net Credits',
58 'payments' => 'Gross Receipts',
59 'receipts' => 'Net Receipts',
60 'refunds' => 'Gross Refunds',
61 'netrefunds' => 'Net Refunds',
62 'cashflow' => 'Gross Cashflow',
63 'netcashflow' => 'Net Cashflow',
67 'invoiced' => ' (invoiced)',
68 'netsales' => ' (invoiced - applied credits)',
69 'credits' => ' (credited)',
70 'netcredits' => ' (applied credits)',
71 'payments' => ' (payments)',
72 'receipts' => ' (applied payments)',
73 'refunds' => ' (refunds)',
74 'netrefunds' => ' (applied refunds)',
75 'cashflow' => ' (payments - refunds)',
76 'netcashflow' => ' (applied payments - applied refunds)',
78 my %graph_label = map { $_ => $label{$_}.$graph_suffix{$_} } keys %label;
80 $label{$_.'_12mo'} = $label{$_}. " (prev 12 months)"
83 $graph_label{$_.'_12mo'} = $graph_label{$_}. " (prev 12 months)"
84 foreach keys %graph_label;
87 'invoiced' => '9999ff', #light blue
88 'netsales' => '0000cc', #blue
89 'credits' => 'ff9999', #light red
90 'netcredits' => 'cc0000', #red
91 'payments' => '99cc99', #light green
92 'receipts' => '00cc00', #green
93 'refunds' => 'ffcc99', #light orange
94 'netrefunds' => 'ff9900', #orange
95 'cashflow' => '99cc33', #light olive
96 'netcashflow' => '339900', #olive
98 $color{$_.'_12mo'} = $color{$_}
101 my $ar = "agentnum=$agentnum;refnum=$refnum";
102 $ar .= ";cust_classnum=$_" foreach @classnums;
105 'invoiced' => "${p}search/cust_bill.html?$ar;",
106 'netsales' => "${p}search/cust_bill.html?$ar;net=1;",
107 'credits' => "${p}search/cust_credit.html?$ar;",
108 'netcredits' => "${p}search/cust_credit_bill.html?$ar;",
109 'payments' => "${p}search/cust_pay.html?magic=_date;$ar;",
110 'receipts' => "${p}search/cust_bill_pay.html?$ar;",
111 'refunds' => "${p}search/cust_refund.html?magic=_date;$ar;",
112 'netrefunds' => "${p}search/cust_credit_refund.html?$ar;",