1 <% include('elements/monthly.html',
2 'title' => $agentname. $referralname.
3 'Sales, Credits and Receipts Summary',
6 'graph_labels' => \%graph_label,
9 'agentnum' => $agentnum,
11 'nototal' => scalar($cgi->param('12mo')),
17 unless $FS::CurrentUser::CurrentUser->access_right('Financial reports');
20 my( $agentnum, $agent ) = ('', '');
21 if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
23 $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
24 die "agentnum $agentnum not found!" unless $agent;
26 my $agentname = $agent ? $agent->agent.' ' : '';
28 my( $refnum, $part_referral ) = ('', '');
29 if ( $cgi->param('refnum') =~ /^(\d+)$/ ) {
31 $part_referral = qsearchs('part_referral', { 'refnum' => $refnum } );
32 die "refnum $refnum not found!" unless $part_referral;
34 my $referralname = $part_referral ? $part_referral->referral.' ' : '';
37 my @items = qw( invoiced netsales
43 if ( $cgi->param('12mo') == 1 ) {
44 @items = map $_.'_12mo', @items;
48 'invoiced' => 'Gross Sales',
49 'netsales' => 'Net Sales',
50 'credits' => 'Gross Credits',
51 'netcredits' => 'Net Credits',
52 'payments' => 'Gross Receipts',
53 'receipts' => 'Net Receipts',
54 'refunds' => 'Gross Refunds',
55 'netrefunds' => 'Net Refunds',
56 'cashflow' => 'Gross Cashflow',
57 'netcashflow' => 'Net Cashflow',
61 'invoiced' => ' (invoiced)',
62 'netsales' => ' (invoiced - applied credits)',
63 'credits' => ' (credited)',
64 'netcredits' => ' (applied credits)',
65 'payments' => ' (payments)',
66 'receipts' => ' (applied payments)',
67 'refunds' => ' (refunds)',
68 'netrefunds' => ' (applied refunds)',
69 'cashflow' => ' (payments - refunds)',
70 'netcashflow' => ' (applied payments - applied refunds)',
72 my %graph_label = map { $_ => $label{$_}.$graph_suffix{$_} } keys %label;
74 $label{$_.'_12mo'} = $label{$_}. " (prev 12 months)"
77 $graph_label{$_.'_12mo'} = $graph_label{$_}. " (prev 12 months)"
78 foreach keys %graph_label;
81 'invoiced' => '9999ff', #light blue
82 'netsales' => '0000cc', #blue
83 'credits' => 'ff9999', #light red
84 'netcredits' => 'cc0000', #red
85 'payments' => '99cc99', #light green
86 'receipts' => '00cc00', #green
87 'refunds' => 'ffcc99', #light orange
88 'netrefunds' => 'ff9900', #orange
89 'cashflow' => '99cc33', #light olive
90 'netcashflow' => '339900', #olive
92 $color{$_.'_12mo'} = $color{$_}
95 my $ar = "agentnum=$agentnum;refnum=$refnum";
98 'invoiced' => "${p}search/cust_bill.html?$ar;",
99 'netsales' => "${p}search/cust_bill.html?$ar;net=1;",
100 'credits' => "${p}search/cust_credit.html?$ar;",
101 'netcredits' => "${p}search/cust_credit_bill.html?$ar;",
102 'payments' => "${p}search/cust_pay.html?magic=_date;$ar;",
103 'receipts' => "${p}search/cust_bill_pay.html?$ar;",
104 'refunds' => "${p}search/cust_refund.html?magic=_date;$ar;",
105 'netrefunds' => "${p}search/cust_credit_refund.html?$ar;",