894b2dfc0ac1abe2ec5f5daa526d787ff49e20a6
[freeside.git] / httemplate / view / cust_main / billing.html
1 <FONT CLASS="fsinnerbox-title"><% mt('Billing information') |h %></FONT>
2 % my $yes = emt('yes');
3 % my $no = emt('no');
4 % my $allowed = emt('allowed');
5 % my $refused = emt('refused');
6
7 <TABLE CLASS="fsinnerbox">
8
9 % if ( $cust_main->complimentary ) {
10   <TR>
11     <TH ALIGN="right"><% mt('Complimentary') |h %></TH>
12     <TD><% $yes %></TD>
13   </TR>
14 % }
15
16 %( my $balance = $cust_main->balance )
17 %  =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/;
18
19 <TR>
20   <TH ALIGN="right"><% mt('Balance due') |h %></TH>
21   <TD><B><% $balance %></B></TD>
22 </TR>
23
24 % #54: just an arbitrary number i pulled out of my goober.  ideally we'd like
25 % # to consider e.g. a histogram of num_ncancelled_packages for the entire
26 % # customer base, and compare it to a graph of the overhead for generating this
27 % # information.  (and optimize it better, we could get it more from SQL)
28 % if ( $cust_main->num_ncancelled_pkgs < 54 ) {
29 %   foreach my $freq_info ($cust_main->display_recurring) {
30       <TR>
31         <TH ALIGN="right"><% emt( ucfirst($freq_info->{'freq_pretty'}). ' recurring' ) %></TH>
32         <TD><% $money_char. sprintf('%.2f', $freq_info->{'amount'}) %></TD>
33       </TR>
34 %   }
35 % }
36
37 % if ( $conf->exists('cust_main-select-prorate_day') ) {
38 <TR>
39   <TH ALIGN="right"><% mt('Prorate day of month') |h %></TH>
40   <TD><% $cust_main->prorate_day %>
41   </TD>
42 </TR>
43 % }
44
45 % if ( $conf->exists('cust_main-select-billday') 
46 %        && qsearch({ 'table'     => 'cust_payby',
47 %                     'hashref'   => { 'custnum' => $cust_main->custnum, },
48 %                     'extra_sql' => "AND payby IN ( 'CARD', 'CHEK' )",
49 %                     'order_by'  => 'LIMIT 1',
50 %                  })
51 %    )
52 % {
53     <TR>
54       <TH ALIGN="right"><% mt('Payment day of month') |h %></TH>
55       <TD><% $cust_main->billday %>
56       </TD>
57     </TR>
58 % }
59
60 % if ( $cust_main->po_number ) { 
61     <TR>
62       <TH ALIGN="right"><% mt('Purchase Order #') |h %></TH>
63       <TD><% $cust_main->po_number %></TD>
64     </TR>
65 % } 
66
67 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
68
69 % unless (    $conf->exists('cust_class-tax_exempt')
70 %          || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
71 %        )
72 % {
73     <TR>
74       <TH ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TH>
75       <TD><% $cust_main->tax ? $yes : $no %></TD>
76     </TR>
77 % }
78
79 % foreach my $exempt_group ( @exempt_groups ) {
80 %   my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
81     <TR>
82       <TH ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TH>
83       <TD><% $cust_main_exemption ? $yes : $no %>
84         <% $cust_main_exemption ? $cust_main_exemption->exempt_number : '' |h %>
85       </TD>
86     </TR>
87 % }
88
89 % if ( $conf->config('tax_data_vendor') eq 'cch' ) {
90 <TR>
91   <TH ALIGN="right"><% mt('Tax location') |h %></TH>
92 % my $tax_location = $conf->exists('tax-ship_address')
93 %                    ? $cust_main->ship_location
94 %                    : $cust_main->bill_location;
95   <TD><% $tax_location->geocode('cch') %></TD>
96 </TR>
97 % }
98 <TR>
99   <TH ALIGN="right"><% mt('Postal mail invoices') |h %></TH>
100 % if ( $cust_main->postal_invoice ) {
101   <TD><% $yes .  ( $cust_main->invoice_attn
102                      ? ', attn: '. $cust_main->invoice_attn
103                      : ''
104                  ) %>
105   </TD>
106 % } elsif ( $cust_main->invoice_noemail
107 %           or scalar(@invoicing_list) == 0 ) {
108 %   # alert the user that this customer has no way to receive an invoice
109   <TD CLASS="error"><% $no %></TD>
110 % } else {
111   <TD><% $no %></TD>
112 % }
113   </TD>
114 </TR>
115 <TR>
116   <TH ALIGN="right"><% mt('Email invoices') |h %></TH>
117 % if ( $cust_main->invoice_noemail and ! $cust_main->postal_invoice ) {
118 %   # as above, warn if the customer refuses both email and postal invoices
119   <TD CLASS="error"><% $refused %></TD>
120 % } else {
121   <TD><% $cust_main->invoice_noemail ? $refused : $allowed %></TD>
122 % }
123 </TR>
124 <TR>
125   <TH ALIGN="right"><% mt('Other email notices') |h %></TH>
126   <TD>
127     <% $cust_main->message_noemail ? $refused : $allowed %>
128   </TD>
129 </TR>
130 <TR>
131   <TH ALIGN="right"><% mt('Invoice terms') |h %></TH>
132   <TD>
133     <% $cust_main->invoice_terms
134          || emt('Default').' ('. ( $conf->config('invoice_default_terms', $cust_main->agentnum)
135                                      || emt('Payable upon receipt')
136                                  ).
137                            ')'
138     %>
139   </TD>
140 </TR>
141 <TR>
142   <TH ALIGN="right"><% mt('Credit limit') |h %></TH>
143   <TD>
144 %   my $default_credit_limit = $conf->config('default_credit_limit');
145     <% length($cust_main->credit_limit)
146          ? $money_char. sprintf("%.2f", $cust_main->credit_limit)
147          : $default_credit_limit
148            ? "Default ($money_char". sprintf("%.2f", $default_credit_limit). ")"
149            : emt('Unlimited')
150     %>
151 %   if ( $cust_main->num_cust_main_credit_limit ) {
152       <A HREF="<% $p %>search/cust_main_credit_limit.html?custnum=<% $cust_main->custnum %>">(incidents)</A>
153 %   }
154   </TD>
155 </TR>
156
157 % if ( $conf->exists('voip-cust_cdr_spools') ) { 
158   <TR>
159     <TH ALIGN="right"><% mt('Spool CDRs') |h %></TH>
160     <TD><% $cust_main->spool_cdr ? $yes : $no %></TD>
161   </TR>
162 % } 
163
164 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
165   <TR>
166     <TH ALIGN="right"><% mt($conf->exists('voip-cdr_email') ? 'Print CDRs' : 'Show CDRs') |h %></TH>
167     <TD><% $cust_main->squelch_cdr ? $no : $yes %></TD>
168   </TR>
169 % } 
170
171 % if ( $conf->exists('voip-cust_accountcode_cdr') ) { 
172    <TR>
173      <TH ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TH>
174      <TD><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
175    </TR>
176 % }
177
178 % if ( my $attach = $conf->config('voip-cdr_email_attach') ) { 
179   <TR>
180     <TH ALIGN="right"><% mt('Email CDRs as '.uc($attach)) |h %></TH>
181     <TD><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
182   </TR>
183 % } 
184
185 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
186   <TR>
187     <TH ALIGN="right"><% mt('CDR termination settlement') |h %></TH>
188     <TD><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
189   </TR>
190 % }
191
192 % if ( $cust_main->currency ) {
193   <TR>
194     <TH ALIGN="right"><% mt('Invoicing currency') |h %></TH>
195     <TD><% $cust_main->currency. ': '. code2currency($cust_main->currency) %></TD>
196   </TR>
197 % }
198
199 % if ( $cust_main->locale ) {
200 % my %locale_info = FS::Locales->locale_info($cust_main->locale);
201   <TR>
202     <TH ALIGN="right"><% mt('Invoicing locale') |h %></TH>
203     <TD><% $locale_info{name} . " (" . $locale_info{country} .")" %></TD>
204   </TR>
205 % }
206
207
208 </TABLE>
209 <%init>
210
211 my( $cust_main ) = @_;
212 my @invoicing_list = $cust_main->invoicing_list_emailonly;
213 my $conf = new FS::Conf;
214 my $money_char = $conf->config('money_char') || '$';
215
216 #false laziness w/edit/cust_main/billing.html
217 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
218 my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
219 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
220 my $show_term = $term_sth->fetchrow_arrayref->[0];
221
222 </%init>