taqua accountcode billing, part 1 of 2, RT12181
[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
88
89     Electronic&nbsp;check&nbsp;<% $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' %>
90   </TD>
91 </TR>
92 <TR>
93   <TD ALIGN="right">ABA/Routing code</TD>
94   <TD BGCOLOR="#ffffff"><% $aba %></TD>
95 </TR>
96 <TR>
97   <TD ALIGN="right">Account number</TD>
98   <TD BGCOLOR="#ffffff"><% $account %></TD>
99 </TR>
100 <TR>
101   <TD ALIGN="right">Account type</TD>
102   <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
103 </TR>
104 <TR>
105   <TD ALIGN="right">Bank name</TD>
106   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
107 </TR>
108 % if ( $conf->exists('show_bankstate') ) {
109 <TR>
110   <TD ALIGN="right"><% $paystate_label %></TD>
111   <TD BGCOLOR="#ffffff"><% $cust_main->paystate || '&nbsp;&nbsp;&nbsp;' %></TD>
112 </TR>
113 % }
114 % } elsif ( $cust_main->payby eq 'LECB' ) {
115 %     $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
116 %     my $payinfo = "$1-$2-$3";
117 %
118
119
120     Phone&nbsp;bill&nbsp;billing
121   </TD>
122 </TR>
123 <TR>
124   <TD ALIGN="right">Phone number</TD>
125   <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
126 </TR>
127 % } elsif ( $cust_main->payby eq 'BILL' ) { 
128
129
130     Billing
131   </TD>
132 </TR>
133 % if ( $cust_main->payinfo ) { 
134
135 <TR>
136   <TD ALIGN="right">P.O. </TD>
137   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
138 </TR>
139 % } 
140
141
142 <TR>
143   <TD ALIGN="right">Attention</TD>
144   <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
145 </TR>
146 % } elsif ( $cust_main->payby eq 'COMP' ) { 
147
148
149     Complimentary
150   </TD>
151 </TR>
152 <TR>
153   <TD ALIGN="right">Authorized&nbsp;by</TD>
154   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
155 </TR>
156 %
157 %#false laziness w/above etc.
158 %my( $mon, $year );
159 %my $date = $cust_main->paydate || '12-2037';
160 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
161 %  ( $mon, $year ) = ( $2, $1 );
162 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
163 %  ( $mon, $year ) = ( $1, $3 );
164 %} else {
165 %  warn "unrecognized expiration date format: $date";
166 %  ( $mon, $year ) = ( '', '' );
167 %}
168 %
169
170 <TR>
171   <TD ALIGN="right">Expiration</TD>
172   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
173 </TR>
174 % } 
175
176 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
177 <TR>
178   <TD ALIGN="right">Tax&nbsp;exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
179   <TD BGCOLOR="#ffffff"><% $cust_main->tax ? 'yes' : 'no' %></TD>
180 </TR>
181 % foreach my $exempt_group ( @exempt_groups ) {
182 <TR>
183   <TD ALIGN="right">Tax&nbsp;exempt (<% $exempt_group %> taxes)</TD>
184   <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? 'yes' : 'no' %></TD>
185 </TR>
186 % }
187
188 % if ( $conf->exists('enable_taxproducts') ) {
189 <TR>
190   <TD ALIGN="right">Tax&nbsp;location</TD>
191   <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
192 </TR>
193 % }
194 <TR>
195   <TD ALIGN="right">Postal&nbsp;invoices</TD>
196   <TD BGCOLOR="#ffffff">
197     <% ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no' %>
198   </TD>
199 </TR>
200 <TR>
201   <TD ALIGN="right">FAX&nbsp;invoices</TD>
202   <TD BGCOLOR="#ffffff">
203     <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'yes' : 'no' %>
204   </TD>
205 </TR>
206 <TR>
207   <TD ALIGN="right">Email&nbsp;invoices</TD>
208   <TD BGCOLOR="#ffffff">
209     <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %>
210   </TD>
211 </TR>
212 <TR>
213   <TD ALIGN="right">Invoice&nbsp;terms</TD>
214   <TD BGCOLOR="#ffffff">
215     <% $cust_main->invoice_terms || 'Default ('. ( $conf->config('invoice_default_terms') || 'Payable upon receipt' ). ')' %>
216   </TD>
217 </TR>
218 <TR>
219   <TD ALIGN="right">Credit&nbsp;limit</TD>
220   <TD BGCOLOR="#ffffff">
221     <% length($cust_main->credit_limit) ? 
222         $money_char.sprintf("%.2f", $cust_main->credit_limit) :
223         'Unlimited' %>
224   </TD>
225 </TR>
226
227 % if ( $conf->exists('voip-cust_cdr_spools') ) { 
228   <TR>
229     <TD ALIGN="right">Spool&nbsp;CDRs</TD>
230     <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? 'yes' : 'no' %></TD>
231   </TR>
232 % } 
233
234 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
235   <TR>
236     <TD ALIGN="right">Print&nbsp;CDRs</TD>
237     <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? 'no' : 'yes' %></TD>
238   </TR>
239 % } 
240
241 % if ( $conf->exists('voip-cust_accountcode_cdr') ) { 
242    <TR>
243      <TD ALIGN="right">Breakdown CDRs by accountcode</TD>
244      <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? 'yes' : 'no' %></TD>
245    </TR>
246 % }
247
248 % if ( $conf->exists('voip-cust_email_csv_cdr') ) { 
249   <TR>
250     <TD ALIGN="right">Email&nbsp;CDRs&nbsp;as&nbsp;CSV</TD>
251     <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? 'yes' : 'no' %></TD>
252   </TR>
253 % } 
254
255 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
256   <TR>
257     <TD ALIGN="right">CDR termination settlement</TD>
258     <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
259   </TR>
260 % }
261
262 </TABLE></TD></TR></TABLE>
263 <%once>
264
265 my $paystate_label = FS::Msgcat::_gettext('paystate');
266 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
267
268 </%once>
269 <%init>
270
271 my( $cust_main ) = @_;
272 my @invoicing_list = $cust_main->invoicing_list;
273 my $conf = new FS::Conf;
274 my $money_char = $conf->config('money_char') || '$';
275
276 #false laziness w/edit/cust_main/billing.html
277 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
278 my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
279 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
280 my $show_term = $term_sth->fetchrow_arrayref->[0];
281
282 </%init>