separate tax exemption numbers for individual exemptions w/tax-cust_exempt-groups...
[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-billday') 
27 %    && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) {
28 <TR>
29   <TD ALIGN="right"><% mt('Billing day of month') |h %></TD>
30   <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
31   </TD>
32 </TR>
33 % }
34
35 <TR>
36   <TD ALIGN="right"><% mt('Billing type') |h %></TD>
37   <TD BGCOLOR="#ffffff">
38 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) { 
39
40 %   my $autodemand = $cust_main->payby eq 'CARD' ? 'automatic' : 'on-demand';
41     <% mt("Credit card ([_1])",$autodemand) |h %>
42   </TD>
43 </TR>
44 <TR>
45   <TD ALIGN="right"><% mt('Card number') |h %></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"><% mt('Expiration') |h %></TD>
64   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
65 </TR>
66 % if ( $cust_main->paystart_month ) { 
67
68   <TR>
69     <TD ALIGN="right"><% mt('Start date') |h %></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"><% mt('Issue #') |h %></TD>
76     <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
77   </TR>
78 % } 
79
80
81 <TR>
82   <TD ALIGN="right"><% mt('Name on card') |h %></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->config('echeck-country') eq 'CA';
89
90
91 % my $autodemand = $cust_main->payby eq 'CHEK' ? 'automatic' : 'on-demand';
92     <% mt("Electronic check ([_1])",$autodemand) |h %>
93   </TD>
94 </TR>
95
96 %  #false laziness w/edit/cust_main/billing.html and misc/payment.cgi
97 %  my $routing_label = $conf->config('echeck-country') eq 'US'
98 %                        ? 'ABA/Routing number'
99 %                        : 'Routing number';
100
101 <TR>
102   <TD ALIGN="right"><% mt($routing_label) |h %></TD>
103   <TD BGCOLOR="#ffffff"><% $aba %></TD>
104 </TR>
105
106 % if ( $conf->config('echeck-country') eq 'CA' ) {
107 <TR>
108   <TD ALIGN="right"><% mt('Branch number') |h %></TD>
109   <TD BGCOLOR="#ffffff"><% $branch %></TD>
110 <TR>
111 % }
112
113   <TD ALIGN="right"><% mt('Account number') |h %></TD>
114   <TD BGCOLOR="#ffffff"><% $account %></TD>
115 </TR>
116 <TR>
117   <TD ALIGN="right"><% mt('Account type') |h %></TD>
118   <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
119 </TR>
120 <TR>
121   <TD ALIGN="right"><% mt('Bank name') |h %></TD>
122   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
123 </TR>
124 % if ( $conf->exists('show_bankstate') ) {
125 <TR>
126   <TD ALIGN="right"><% $paystate_label %></TD>
127   <TD BGCOLOR="#ffffff"><% $cust_main->paystate || '&nbsp;&nbsp;&nbsp;' %></TD>
128 </TR>
129 % }
130 % } elsif ( $cust_main->payby eq 'LECB' ) {
131 %     $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
132 %     my $payinfo = "$1-$2-$3";
133
134     <% mt('Phone bill billing') |h %> 
135   </TD>
136 </TR>
137 <TR>
138   <TD ALIGN="right"><% mt('Phone number') |h %></TD>
139   <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
140 </TR>
141 % } elsif ( $cust_main->payby eq 'BILL' ) { 
142
143     <% mt('Billing') |h %> 
144   </TD>
145 </TR>
146 % if ( $cust_main->payinfo ) { 
147
148 <TR>
149   <TD ALIGN="right"<% mt('P.O.') |h %></TD>
150   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
151 </TR>
152 % } 
153
154
155 <TR>
156   <TD ALIGN="right"><% mt('Attention') |h %></TD>
157   <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
158 </TR>
159 % } elsif ( $cust_main->payby eq 'COMP' ) { 
160
161     <% mt('Complimentary') |h %> 
162   </TD>
163 </TR>
164 <TR>
165   <TD ALIGN="right"><% mt('Authorized by') |h %></TD>
166   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
167 </TR>
168 %
169 %#false laziness w/above etc.
170 %my( $mon, $year );
171 %my $date = $cust_main->paydate || '12-2037';
172 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
173 %  ( $mon, $year ) = ( $2, $1 );
174 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
175 %  ( $mon, $year ) = ( $1, $3 );
176 %} else {
177 %  warn "unrecognized expiration date format: $date";
178 %  ( $mon, $year ) = ( '', '' );
179 %}
180 %
181
182 <TR>
183   <TD ALIGN="right"><% mt('Expiration') |h %></TD>
184   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
185 </TR>
186 % } 
187
188 % my $yes = emt('yes');
189 % my $no = emt('no');
190
191 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
192
193 % unless (    $conf->exists('cust_class-tax_exempt')
194 %          || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
195 %        )
196 % {
197     <TR>
198       <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
199       <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
200     </TR>
201 % }
202
203 % foreach my $exempt_group ( @exempt_groups ) {
204 %   my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
205     <TR>
206       <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
207       <TD BGCOLOR="#ffffff"><% $cust_main_exemption ? $yes : $no %>
208         <% $cust_main_exemption ? $cust_main_exemption->exempt_number : '' |h %>
209       </TD>
210     </TR>
211 % }
212
213 % if ( $conf->exists('enable_taxproducts') ) {
214 <TR>
215   <TD ALIGN="right"><% mt('Tax location') |h %></TD>
216   <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
217 </TR>
218 % }
219 <TR>
220   <TD ALIGN="right"><% mt('Postal invoices') |h %></TD>
221   <TD BGCOLOR="#ffffff">
222     <% ( grep { $_ eq 'POST' } @invoicing_list ) ? $yes : $no %>
223   </TD>
224 </TR>
225 <TR>
226   <TD ALIGN="right"><% mt('FAX invoices') |h %></TD>
227   <TD BGCOLOR="#ffffff">
228     <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? $yes : $no %>
229   </TD>
230 </TR>
231 % unless ( $conf->exists('cust-email-high-visibility')) {
232 <TR>
233   <TD ALIGN="right"><% mt('Email invoices') |h %></TD>
234   <TD BGCOLOR="#ffffff">
235     <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
236   </TD>
237 </TR>
238 % }
239 <TR>
240   <TD ALIGN="right"><% mt('Invoice terms') |h %></TD>
241   <TD BGCOLOR="#ffffff">
242     <% $cust_main->invoice_terms || emt('Default').' ('. ( $conf->config('invoice_default_terms') || emt('Payable upon receipt') ). ')' %>
243   </TD>
244 </TR>
245 <TR>
246   <TD ALIGN="right"><% mt('Credit limit') |h %></TD>
247   <TD BGCOLOR="#ffffff">
248     <% length($cust_main->credit_limit) ? 
249         $money_char.sprintf("%.2f", $cust_main->credit_limit) :
250         emt('Unlimited') %>
251   </TD>
252 </TR>
253
254 % if ( $conf->exists('voip-cust_cdr_spools') ) { 
255   <TR>
256     <TD ALIGN="right"><% mt('Spool CDRs') |h %></TD>
257     <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? $yes : $no %></TD>
258   </TR>
259 % } 
260
261 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
262   <TR>
263     <TD ALIGN="right"><% mt($conf->exists('voip-cdr_email') ? 'Print CDRs' : 'Show CDRs') |h %></TD>
264     <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? $no : $yes %></TD>
265   </TR>
266 % } 
267
268 % if ( $conf->exists('voip-cust_accountcode_cdr') ) { 
269    <TR>
270      <TD ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TD>
271      <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
272    </TR>
273 % }
274
275 % if ( $conf->exists('voip-cust_email_csv_cdr') ) { 
276   <TR>
277     <TD ALIGN="right"><% mt('Email CDRs as CSV') |h %></TD>
278     <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
279   </TR>
280 % } 
281
282 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
283   <TR>
284     <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
285     <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
286   </TR>
287 % }
288
289 % if ( $cust_main->locale ) {
290 % my %locale_info = FS::Locales->locale_info($cust_main->locale);
291   <TR>
292     <TD ALIGN="right"><% mt('Invoicing locale') |h %></TD>
293     <TD BGCOLOR="#ffffff"><% $locale_info{name} . " (" . $locale_info{country} .")" %></TD>
294   </TR>
295 % }
296
297
298 </TABLE>
299 <%once>
300
301 my $paystate_label = FS::Msgcat::_gettext('paystate');
302 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
303
304 </%once>
305 <%init>
306
307 my( $cust_main ) = @_;
308 my @invoicing_list = $cust_main->invoicing_list;
309 my $conf = new FS::Conf;
310 my $money_char = $conf->config('money_char') || '$';
311
312 #false laziness w/edit/cust_main/billing.html
313 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
314 my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
315 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
316 my $show_term = $term_sth->fetchrow_arrayref->[0];
317
318 </%init>