echeck: add optional bank branch format, RT13360
[freeside.git] / httemplate / view / cust_main / billing.html
1 Billing information
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 %>">Bill now</A>)
9   (<% include('/elements/bill.html',
10                 custnum   => $cust_main->custnum,
11                 label     => 'Bill now',
12                 url       => $p.'view/cust_main.cgi?'.$cust_main->custnum,
13   ) %>)
14 % } 
15
16 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
17
18 %( my $balance = $cust_main->balance )
19 %  =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/;
20
21 <TR>
22   <TD ALIGN="right">Balance due</TD>
23   <TD BGCOLOR="#ffffff"><B><% $balance %></B></TD>
24 </TR>
25
26 % if ( $conf->exists('cust_main-select-billday') 
27 %    && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) {
28 <TR>
29   <TD ALIGN="right">Billing day of month</TD>
30   <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
31   </TD>
32 </TR>
33 % }
34
35 <TR>
36   <TD ALIGN="right">Billing&nbsp;type</TD>
37   <TD BGCOLOR="#ffffff">
38 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) { 
39
40
41     Credit&nbsp;card&nbsp;<% $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' %>
42   </TD>
43 </TR>
44 <TR>
45   <TD ALIGN="right">Card number</TD>
46   <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
47 </TR>
48 %
49 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
50 %my( $mon, $year );
51 %my $date = $cust_main->paydate || '12-2037';
52 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
53 %  ( $mon, $year ) = ( $2, $1 );
54 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
55 %  ( $mon, $year ) = ( $1, $3 );
56 %} else {
57 %  warn "unrecognized expiration date format: $date";
58 %  ( $mon, $year ) = ( '', '' );
59 %}
60 %
61
62 <TR>
63   <TD ALIGN="right">Expiration</TD>
64   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
65 </TR>
66 % if ( $cust_main->paystart_month ) { 
67
68   <TR>
69     <TD ALIGN="right">Start date</TD>
70     <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
71   </TR>
72 % } elsif ( $cust_main->payissue ) { 
73
74   <TR>
75     <TD ALIGN="right">Issue #</TD>
76     <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
77   </TR>
78 % } 
79
80
81 <TR>
82   <TD ALIGN="right">Name on card</TD>
83   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
84 </TR>
85 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
86 %     my( $account, $aba ) = split('@', $cust_main->paymask );
87 %  my $branch = '';
88 %  ($branch,$aba) = split('\.',$aba) if $conf->exists('cust_main-require-bank-branch');
89
90
91     Electronic&nbsp;check&nbsp;<% $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' %>
92   </TD>
93 </TR>
94 <TR>
95   <TD ALIGN="right">ABA/Routing code</TD>
96   <TD BGCOLOR="#ffffff"><% $aba %></TD>
97 </TR>
98
99 % if ( $conf->exists('cust_main-require-bank-branch') ) {
100 <TR>
101   <TD ALIGN="right">Branch number</TD>
102   <TD BGCOLOR="#ffffff"><% $branch %></TD>
103  <TR>
104 % }
105
106 <TR>
107   <TD ALIGN="right">Account number</TD>
108   <TD BGCOLOR="#ffffff"><% $account %></TD>
109 </TR>
110 <TR>
111   <TD ALIGN="right">Account type</TD>
112   <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
113 </TR>
114 <TR>
115   <TD ALIGN="right">Bank name</TD>
116   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
117 </TR>
118 % if ( $conf->exists('show_bankstate') ) {
119 <TR>
120   <TD ALIGN="right"><% $paystate_label %></TD>
121   <TD BGCOLOR="#ffffff"><% $cust_main->paystate || '&nbsp;&nbsp;&nbsp;' %></TD>
122 </TR>
123 % }
124 % } elsif ( $cust_main->payby eq 'LECB' ) {
125 %     $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
126 %     my $payinfo = "$1-$2-$3";
127 %
128
129
130     Phone&nbsp;bill&nbsp;billing
131   </TD>
132 </TR>
133 <TR>
134   <TD ALIGN="right">Phone number</TD>
135   <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
136 </TR>
137 % } elsif ( $cust_main->payby eq 'BILL' ) { 
138
139
140     Billing
141   </TD>
142 </TR>
143 % if ( $cust_main->payinfo ) { 
144
145 <TR>
146   <TD ALIGN="right">P.O. </TD>
147   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
148 </TR>
149 % } 
150
151
152 <TR>
153   <TD ALIGN="right">Attention</TD>
154   <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
155 </TR>
156 % } elsif ( $cust_main->payby eq 'COMP' ) { 
157
158
159     Complimentary
160   </TD>
161 </TR>
162 <TR>
163   <TD ALIGN="right">Authorized&nbsp;by</TD>
164   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
165 </TR>
166 %
167 %#false laziness w/above etc.
168 %my( $mon, $year );
169 %my $date = $cust_main->paydate || '12-2037';
170 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
171 %  ( $mon, $year ) = ( $2, $1 );
172 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
173 %  ( $mon, $year ) = ( $1, $3 );
174 %} else {
175 %  warn "unrecognized expiration date format: $date";
176 %  ( $mon, $year ) = ( '', '' );
177 %}
178 %
179
180 <TR>
181   <TD ALIGN="right">Expiration</TD>
182   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
183 </TR>
184 % } 
185
186 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
187 <TR>
188   <TD ALIGN="right">Tax&nbsp;exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
189   <TD BGCOLOR="#ffffff"><% $cust_main->tax ? 'yes' : 'no' %></TD>
190 </TR>
191 % foreach my $exempt_group ( @exempt_groups ) {
192 <TR>
193   <TD ALIGN="right">Tax&nbsp;exempt (<% $exempt_group %> taxes)</TD>
194   <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? 'yes' : 'no' %></TD>
195 </TR>
196 % }
197
198 % if ( $conf->exists('enable_taxproducts') ) {
199 <TR>
200   <TD ALIGN="right">Tax&nbsp;location</TD>
201   <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
202 </TR>
203 % }
204 <TR>
205   <TD ALIGN="right">Postal&nbsp;invoices</TD>
206   <TD BGCOLOR="#ffffff">
207     <% ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no' %>
208   </TD>
209 </TR>
210 <TR>
211   <TD ALIGN="right">FAX&nbsp;invoices</TD>
212   <TD BGCOLOR="#ffffff">
213     <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'yes' : 'no' %>
214   </TD>
215 </TR>
216 % unless ( $conf->exists('cust-email-high-visibility')) {
217 <TR>
218   <TD ALIGN="right">Email&nbsp;invoices</TD>
219   <TD BGCOLOR="#ffffff">
220     <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %>
221   </TD>
222 </TR>
223 % }
224 <TR>
225   <TD ALIGN="right">Invoice&nbsp;terms</TD>
226   <TD BGCOLOR="#ffffff">
227     <% $cust_main->invoice_terms || 'Default ('. ( $conf->config('invoice_default_terms') || 'Payable upon receipt' ). ')' %>
228   </TD>
229 </TR>
230 <TR>
231   <TD ALIGN="right">Credit&nbsp;limit</TD>
232   <TD BGCOLOR="#ffffff">
233     <% length($cust_main->credit_limit) ? 
234         $money_char.sprintf("%.2f", $cust_main->credit_limit) :
235         'Unlimited' %>
236   </TD>
237 </TR>
238
239 % if ( $conf->exists('voip-cust_cdr_spools') ) { 
240   <TR>
241     <TD ALIGN="right">Spool&nbsp;CDRs</TD>
242     <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? 'yes' : 'no' %></TD>
243   </TR>
244 % } 
245
246 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
247   <TR>
248     <TD ALIGN="right">Print&nbsp;CDRs</TD>
249     <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? 'no' : 'yes' %></TD>
250   </TR>
251 % } 
252
253 % if ( $conf->exists('voip-cust_email_csv_cdr') ) { 
254   <TR>
255     <TD ALIGN="right">Email&nbsp;CDRs&nbsp;as&nbsp;CSV</TD>
256     <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? 'yes' : 'no' %></TD>
257   </TR>
258 % } 
259
260 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
261   <TR>
262     <TD ALIGN="right">CDR termination settlement</TD>
263     <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
264   </TR>
265 % }
266
267 </TABLE></TD></TR></TABLE>
268 <%once>
269
270 my $paystate_label = FS::Msgcat::_gettext('paystate');
271 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
272
273 </%once>
274 <%init>
275
276 my( $cust_main ) = @_;
277 my @invoicing_list = $cust_main->invoicing_list;
278 my $conf = new FS::Conf;
279 my $money_char = $conf->config('money_char') || '$';
280
281 #false laziness w/edit/cust_main/billing.html
282 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
283 my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
284 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
285 my $show_term = $term_sth->fetchrow_arrayref->[0];
286
287 </%init>