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
5 %if ( $FS::CurrentUser::CurrentUser->access_right('Bill customer now')
6 % && ! $cust_main->is_encrypted($cust_main->payinfo)
8 %# (<A HREF="<% $p %>misc/bill.cgi?<% $cust_main->custnum %>">Bill now</A>)
9 (<% include('/elements/bill.html',
10 custnum => $cust_main->custnum,
12 url => $p.'view/cust_main.cgi?'.$cust_main->custnum,
16 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
18 %( my $balance = $cust_main->balance )
19 % =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/;
22 <TD ALIGN="right">Balance due</TD>
23 <TD BGCOLOR="#ffffff"><B><% $balance %></B></TD>
27 <TD ALIGN="right">Billing type</TD>
28 <TD BGCOLOR="#ffffff">
29 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) {
32 Credit card <% $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' %>
36 <TD ALIGN="right">Card number</TD>
37 <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
40 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
42 %my $date = $cust_main->paydate || '12-2037';
43 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
44 % ( $mon, $year ) = ( $2, $1 );
45 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
46 % ( $mon, $year ) = ( $1, $3 );
48 % warn "unrecognized expiration date format: $date";
49 % ( $mon, $year ) = ( '', '' );
54 <TD ALIGN="right">Expiration</TD>
55 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
57 % if ( $cust_main->paystart_month ) {
60 <TD ALIGN="right">Start date</TD>
61 <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
63 % } elsif ( $cust_main->payissue ) {
66 <TD ALIGN="right">Issue #</TD>
67 <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
73 <TD ALIGN="right">Name on card</TD>
74 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
76 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
77 % my( $account, $aba ) = split('@', $cust_main->paymask );
80 Electronic check <% $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' %>
84 <TD ALIGN="right">ABA/Routing code</TD>
85 <TD BGCOLOR="#ffffff"><% $aba %></TD>
88 <TD ALIGN="right">Account number</TD>
89 <TD BGCOLOR="#ffffff"><% $account %></TD>
92 <TD ALIGN="right">Account type</TD>
93 <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
96 <TD ALIGN="right">Bank name</TD>
97 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
99 % if ( $conf->exists('show_bankstate') ) {
101 <TD ALIGN="right"><% $paystate_label %></TD>
102 <TD BGCOLOR="#ffffff"><% $cust_main->paystate || ' ' %></TD>
105 % } elsif ( $cust_main->payby eq 'LECB' ) {
106 % $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
107 % my $payinfo = "$1-$2-$3";
111 Phone bill billing
115 <TD ALIGN="right">Phone number</TD>
116 <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
118 % } elsif ( $cust_main->payby eq 'BILL' ) {
124 % if ( $cust_main->payinfo ) {
127 <TD ALIGN="right">P.O. </TD>
128 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
134 <TD ALIGN="right">Attention</TD>
135 <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
137 % } elsif ( $cust_main->payby eq 'COMP' ) {
144 <TD ALIGN="right">Authorized by</TD>
145 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
148 %#false laziness w/above etc.
150 %my $date = $cust_main->paydate || '12-2037';
151 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
152 % ( $mon, $year ) = ( $2, $1 );
153 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
154 % ( $mon, $year ) = ( $1, $3 );
156 % warn "unrecognized expiration date format: $date";
157 % ( $mon, $year ) = ( '', '' );
162 <TD ALIGN="right">Expiration</TD>
163 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
167 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
169 <TD ALIGN="right">Tax exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
170 <TD BGCOLOR="#ffffff"><% $cust_main->tax ? 'yes' : 'no' %></TD>
172 % foreach my $exempt_group ( @exempt_groups ) {
174 <TD ALIGN="right">Tax exempt (<% $exempt_group %> taxes)</TD>
175 <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? 'yes' : 'no' %></TD>
179 % if ( $conf->exists('enable_taxproducts') ) {
181 <TD ALIGN="right">Tax location</TD>
182 <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
186 <TD ALIGN="right">Postal invoices</TD>
187 <TD BGCOLOR="#ffffff">
188 <% ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no' %>
192 <TD ALIGN="right">FAX invoices</TD>
193 <TD BGCOLOR="#ffffff">
194 <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'yes' : 'no' %>
198 <TD ALIGN="right">Email invoices</TD>
199 <TD BGCOLOR="#ffffff">
200 <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %>
204 <TD ALIGN="right">Invoice terms</TD>
205 <TD BGCOLOR="#ffffff">
206 <% $cust_main->invoice_terms || 'Default ('. ( $conf->config('invoice_default_terms') || 'Payable upon receipt' ). ')' %>
210 <TD ALIGN="right">Credit limit</TD>
211 <TD BGCOLOR="#ffffff">
212 <% length($cust_main->credit_limit) ?
213 $money_char.sprintf("%.2f", $cust_main->credit_limit) :
218 % if ( $conf->exists('voip-cust_cdr_spools') ) {
220 <TD ALIGN="right">Spool CDRs</TD>
221 <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? 'yes' : 'no' %></TD>
225 % if ( $conf->exists('voip-cust_cdr_squelch') ) {
227 <TD ALIGN="right">Print CDRs</TD>
228 <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? 'no' : 'yes' %></TD>
232 % if ( $conf->exists('voip-cust_email_csv_cdr') ) {
234 <TD ALIGN="right">Email CDRs as CSV</TD>
235 <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? 'yes' : 'no' %></TD>
239 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
241 <TD ALIGN="right">CDR termination settlement</TD>
242 <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
246 </TABLE></TD></TR></TABLE>
249 my $paystate_label = FS::Msgcat::_gettext('paystate');
250 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
255 my( $cust_main ) = @_;
256 my @invoicing_list = $cust_main->invoicing_list;
257 my $conf = new FS::Conf;
258 my $money_char = $conf->config('money_char') || '$';
260 #false laziness w/edit/cust_main/billing.html
261 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
262 my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
263 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
264 my $show_term = $term_sth->fetchrow_arrayref->[0];