fix CCH geocode lookup and display with 3.x-style locations, #25547
[freeside.git] / httemplate / view / cust_main / billing.html
1 <FONT CLASS="fsinnerbox-title"><% mt('Billing information') |h %></FONT>
2 %# If we can't see the unencrypted card, then bill now is an exercise in
3 %# frustration (without some sort of job queue magic to send it to a secure
4 %# machine, anyway)
5 %if (  $FS::CurrentUser::CurrentUser->access_right('Bill customer now')
6 %      && ! $cust_main->is_encrypted($cust_main->payinfo)
7 %   ) { 
8 %#  (<A HREF="<% $p %>misc/bill.cgi?<% $cust_main->custnum %>"><% mt('Bill now') |h %></A>)
9   <& /elements/bill.html,
10        custnum   => $cust_main->custnum,
11        label     => emt('Bill now'),
12        url       => $p.'view/cust_main.cgi?'.$cust_main->custnum,
13   &>
14 % } 
15
16 <TABLE CLASS="fsinnerbox">
17
18 %( my $balance = $cust_main->balance )
19 %  =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/;
20
21 <TR>
22   <TD ALIGN="right"><% mt('Balance due') |h %></TD>
23   <TD BGCOLOR="#ffffff"><B><% $balance %></B></TD>
24 </TR>
25
26 % if ( $conf->exists('cust_main-select-prorate_day') ) {
27 <TR>
28   <TD ALIGN="right"><% mt('Prorate day of month') |h %></TD>
29   <TD BGCOLOR="#ffffff"><% $cust_main->prorate_day %>
30   </TD>
31 </TR>
32 % }
33
34 % if ( $conf->exists('cust_main-select-billday') 
35 %    && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) {
36 <TR>
37   <TD ALIGN="right"><% mt('Billing day of month') |h %></TD>
38   <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
39   </TD>
40 </TR>
41 % }
42
43 <TR>
44   <TD ALIGN="right"><% mt('Billing type') |h %></TD>
45   <TD BGCOLOR="#ffffff">
46 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) { 
47
48 %   my $autodemand = $cust_main->payby eq 'CARD' ? 'automatic' : 'on-demand';
49     <% mt("Credit card ([_1])",$autodemand) |h %>
50   </TD>
51 </TR>
52 <TR>
53   <TD ALIGN="right"><% mt('Card number') |h %></TD>
54   <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
55 </TR>
56 %
57 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
58 %my( $mon, $year );
59 %my $date = $cust_main->paydate || '12-2037';
60 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
61 %  ( $mon, $year ) = ( $2, $1 );
62 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
63 %  ( $mon, $year ) = ( $1, $3 );
64 %} else {
65 %  warn "unrecognized expiration date format: $date";
66 %  ( $mon, $year ) = ( '', '' );
67 %}
68 %
69
70 <TR>
71   <TD ALIGN="right"><% mt('Expiration') |h %></TD>
72   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
73 </TR>
74 % if ( $cust_main->paystart_month ) { 
75
76   <TR>
77     <TD ALIGN="right"><% mt('Start date') |h %></TD>
78     <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
79   </TR>
80 % } elsif ( $cust_main->payissue ) { 
81
82   <TR>
83     <TD ALIGN="right"><% mt('Issue #') |h %></TD>
84     <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
85   </TR>
86 % } 
87
88
89 <TR>
90   <TD ALIGN="right"><% mt('Name on card') |h %></TD>
91   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
92 </TR>
93 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
94 %     my( $account, $aba ) = split('@', $cust_main->paymask );
95 %  my $branch = '';
96 %  ($branch,$aba) = split('\.',$aba) if $conf->config('echeck-country') eq 'CA';
97
98
99 % my $autodemand = $cust_main->payby eq 'CHEK' ? 'automatic' : 'on-demand';
100     <% mt("Electronic check ([_1])",$autodemand) |h %>
101   </TD>
102 </TR>
103
104 %  #false laziness w/edit/cust_main/billing.html and misc/payment.cgi
105 %  my $routing_label = $conf->config('echeck-country') eq 'US'
106 %                        ? 'ABA/Routing number'
107 %                        : 'Routing number';
108
109 <TR>
110   <TD ALIGN="right"><% mt($routing_label) |h %></TD>
111   <TD BGCOLOR="#ffffff"><% $aba %></TD>
112 </TR>
113
114 % if ( $conf->config('echeck-country') eq 'CA' ) {
115 <TR>
116   <TD ALIGN="right"><% mt('Branch number') |h %></TD>
117   <TD BGCOLOR="#ffffff"><% $branch %></TD>
118 <TR>
119 % }
120
121   <TD ALIGN="right"><% mt('Account number') |h %></TD>
122   <TD BGCOLOR="#ffffff"><% $account %></TD>
123 </TR>
124 <TR>
125   <TD ALIGN="right"><% mt('Account type') |h %></TD>
126   <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
127 </TR>
128 <TR>
129   <TD ALIGN="right"><% mt('Bank name') |h %></TD>
130   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
131 </TR>
132 % if ( $conf->exists('show_bankstate') ) {
133 <TR>
134   <TD ALIGN="right"><% $paystate_label %></TD>
135   <TD BGCOLOR="#ffffff"><% $cust_main->paystate || '&nbsp;&nbsp;&nbsp;' %></TD>
136 </TR>
137 % }
138 % } elsif ( $cust_main->payby eq 'LECB' ) {
139 %     $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
140 %     my $payinfo = "$1-$2-$3";
141
142     <% mt('Phone bill billing') |h %> 
143   </TD>
144 </TR>
145 <TR>
146   <TD ALIGN="right"><% mt('Phone number') |h %></TD>
147   <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
148 </TR>
149 % } elsif ( $cust_main->payby eq 'BILL' ) { 
150
151     <% mt('Billing') |h %> 
152   </TD>
153 </TR>
154 % if ( $cust_main->payinfo ) { 
155
156 <TR>
157   <TD ALIGN="right"><% mt('P.O.') |h %></TD>
158   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
159 </TR>
160 % } 
161
162
163 <TR>
164   <TD ALIGN="right"><% mt('Attention') |h %></TD>
165   <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
166 </TR>
167 % } elsif ( $cust_main->payby eq 'COMP' ) { 
168
169     <% mt('Complimentary') |h %> 
170   </TD>
171 </TR>
172 <TR>
173   <TD ALIGN="right"><% mt('Authorized by') |h %></TD>
174   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
175 </TR>
176 %
177 %#false laziness w/above etc.
178 %my( $mon, $year );
179 %my $date = $cust_main->paydate || '12-2037';
180 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
181 %  ( $mon, $year ) = ( $2, $1 );
182 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
183 %  ( $mon, $year ) = ( $1, $3 );
184 %} else {
185 %  warn "unrecognized expiration date format: $date";
186 %  ( $mon, $year ) = ( '', '' );
187 %}
188 %
189
190 <TR>
191   <TD ALIGN="right"><% mt('Expiration') |h %></TD>
192   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
193 </TR>
194 % } 
195
196 % my $yes = emt('yes');
197 % my $no = emt('no');
198
199 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
200
201 % unless (    $conf->exists('cust_class-tax_exempt')
202 %          || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
203 %        )
204 % {
205     <TR>
206       <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
207       <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
208     </TR>
209 % }
210
211 % foreach my $exempt_group ( @exempt_groups ) {
212 %   my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
213     <TR>
214       <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
215       <TD BGCOLOR="#ffffff"><% $cust_main_exemption ? $yes : $no %>
216         <% $cust_main_exemption ? $cust_main_exemption->exempt_number : '' |h %>
217       </TD>
218     </TR>
219 % }
220
221 % if ( $conf->exists('enable_taxproducts') ) {
222 <TR>
223   <TD ALIGN="right"><% mt('Tax location') |h %></TD>
224 % my $tax_location = $conf->exists('tax-ship_address')
225 %                    ? $cust_main->ship_location
226 %                    : $cust_main->bill_location;
227   <TD BGCOLOR="#ffffff"><% $tax_location->geocode('cch') %></TD>
228 </TR>
229 % }
230 <TR>
231   <TD ALIGN="right"><% mt('Postal mail invoices') |h %></TD>
232   <TD BGCOLOR="#ffffff">
233     <% ( grep { $_ eq 'POST' } @invoicing_list ) ? $yes : $no %>
234   </TD>
235 </TR>
236 <TR>
237   <TD ALIGN="right"><% mt('Fax invoices') |h %></TD>
238   <TD BGCOLOR="#ffffff">
239     <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? $yes : $no %>
240   </TD>
241 </TR>
242 <TR>
243   <TD ALIGN="right"><% mt('Email invoices') |h %></TD>
244   <TD BGCOLOR="#ffffff">
245     <% $cust_main->invoice_noemail ? $no : $yes %>
246   </TD>
247 </TR>
248 % unless ( $conf->exists('cust-email-high-visibility')) {
249 <TR>
250   <TD ALIGN="right"><% mt('Email address(es)') |h %></TD>
251   <TD BGCOLOR="#ffffff">
252     <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
253 %   if ( $cust_main->message_noemail ) {
254     <BR>
255     <SPAN STYLE="font-size: small"><% emt('(do not send notices)') %></SPAN>
256 %   }
257   </TD>
258 </TR>
259 % }
260 <TR>
261   <TD ALIGN="right"><% mt('Invoice terms') |h %></TD>
262   <TD BGCOLOR="#ffffff">
263     <% $cust_main->invoice_terms || emt('Default').' ('. ( $conf->config('invoice_default_terms') || emt('Payable upon receipt') ). ')' %>
264   </TD>
265 </TR>
266 <TR>
267   <TD ALIGN="right"><% mt('Credit limit') |h %></TD>
268   <TD BGCOLOR="#ffffff">
269     <% length($cust_main->credit_limit) ? 
270         $money_char.sprintf("%.2f", $cust_main->credit_limit) :
271         emt('Unlimited') %>
272   </TD>
273 </TR>
274
275 % if ( $conf->exists('voip-cust_cdr_spools') ) { 
276   <TR>
277     <TD ALIGN="right"><% mt('Spool CDRs') |h %></TD>
278     <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? $yes : $no %></TD>
279   </TR>
280 % } 
281
282 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
283   <TR>
284     <TD ALIGN="right"><% mt($conf->exists('voip-cdr_email') ? 'Print CDRs' : 'Show CDRs') |h %></TD>
285     <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? $no : $yes %></TD>
286   </TR>
287 % } 
288
289 % if ( $conf->exists('voip-cust_accountcode_cdr') ) { 
290    <TR>
291      <TD ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TD>
292      <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
293    </TR>
294 % }
295
296 % if ( $conf->exists('voip-cust_email_csv_cdr') ) { 
297   <TR>
298     <TD ALIGN="right"><% mt('Email CDRs as CSV') |h %></TD>
299     <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
300   </TR>
301 % } 
302
303 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
304   <TR>
305     <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
306     <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
307   </TR>
308 % }
309
310 % if ( $cust_main->currency ) {
311   <TR>
312     <TD ALIGN="right"><% mt('Invoicing currency') |h %></TD>
313     <TD BGCOLOR="#ffffff"><% $cust_main->currency. ': '. code2currency($cust_main->currency) %></TD>
314   </TR>
315 % }
316
317 % if ( $cust_main->locale ) {
318 % my %locale_info = FS::Locales->locale_info($cust_main->locale);
319   <TR>
320     <TD ALIGN="right"><% mt('Invoicing locale') |h %></TD>
321     <TD BGCOLOR="#ffffff"><% $locale_info{name} . " (" . $locale_info{country} .")" %></TD>
322   </TR>
323 % }
324
325
326 </TABLE>
327 <%once>
328
329 my $paystate_label = FS::Msgcat::_gettext('paystate');
330 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
331
332 </%once>
333 <%init>
334
335 my( $cust_main ) = @_;
336 my @invoicing_list = $cust_main->invoicing_list;
337 my $conf = new FS::Conf;
338 my $money_char = $conf->config('money_char') || '$';
339
340 #false laziness w/edit/cust_main/billing.html
341 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
342 my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
343 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
344 my $show_term = $term_sth->fetchrow_arrayref->[0];
345
346 </%init>