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.' ' : '';
42 # need to clean this up. the false symmetry of "gross" and "net" everything
43 # makes it aesthetically hard to make this report more useful.
44 my @items = ($cgi->param('exclude_discount') ? 'invoiced' : 'gross');
46 qw( discounted netsales
54 'gross' => 'Gross Sales',
55 'invoiced' => 'Invoiced Sales',
56 'netsales' => 'Net Sales',
57 'discounted' => 'Discounts',
58 'credits' => 'Gross Credits',
59 'netcredits' => 'Net Credits',
60 'payments' => 'Gross Receipts',
61 'receipts' => 'Net Receipts',
62 'refunds' => 'Gross Refunds',
63 'netrefunds' => 'Net Refunds',
64 'cashflow' => 'Gross Cashflow',
65 'netcashflow' => 'Net Cashflow',
69 'gross' => ' (invoiced + discounts)',
71 'netsales' => ' (invoiced - applied credits)',
73 'credits' => ' (credited)',
74 'netcredits' => ' (applied credits)',
75 'payments' => ' (payments)',
76 'receipts' => ' (applied payments)',
77 'refunds' => ' (refunds)',
78 'netrefunds' => ' (applied refunds)',
79 'cashflow' => ' (payments - refunds)',
80 'netcashflow' => ' (applied payments - applied refunds)',
82 my %graph_label = map { $_ => $label{$_}.$graph_suffix{$_} } keys %label;
85 'gross' => '9999ff', #light blue
86 'invoiced' => '9999ff', #light blue
87 'netsales' => '0000cc', #blue
88 'credits' => 'ff9999', #light red
89 'netcredits' => 'cc0000', #red
90 'payments' => '99cc99', #light green
91 'receipts' => '00cc00', #green
92 'refunds' => 'ffcc99', #light orange
93 'netrefunds' => 'ff9900', #orange
94 'cashflow' => '99cc33', #light olive
95 'netcashflow' => '339900', #olive
96 'discounted' => 'cc33cc', #purple-ish?
98 $color{$_.'_12mo'} = $color{$_}
101 my $ar = "agentnum=$agentnum;refnum=$refnum";
102 $ar .= ";cust_classnum=$_" foreach @classnums;
105 'gross' => "${p}search/cust_bill.html?$ar;",
106 'invoiced' => "${p}search/cust_bill.html?$ar;invoiced=1;",
107 'netsales' => "${p}search/cust_bill.html?$ar;net=1;",
108 'credits' => "${p}search/cust_credit.html?$ar;",
109 'netcredits' => "${p}search/cust_credit_bill.html?$ar;",
110 'payments' => "${p}search/cust_pay.html?magic=_date;$ar;",
111 'receipts' => "${p}search/cust_bill_pay.html?$ar;",
112 'refunds' => "${p}search/cust_refund.html?magic=_date;$ar;",
113 'netrefunds' => "${p}search/cust_credit_refund.html?$ar;",
114 'discounted' => "${p}search/cust_bill_pkg_discount.html?$ar;",
118 if ( $cgi->param('12mo') ) {
119 $label{$_} .= " (prev 12 months)"
122 $graph_label{$_} .= " (prev 12 months)"
123 foreach keys %graph_label;