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 formname => 'billnow',
13 url => $p.'view/cust_main.cgi?'.$cust_main->custnum,
17 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
19 %( my $balance = $cust_main->balance )
20 % =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/;
23 <TD ALIGN="right">Balance due</TD>
24 <TD BGCOLOR="#ffffff"><B><% $balance %></B></TD>
28 <TD ALIGN="right">Billing type</TD>
29 <TD BGCOLOR="#ffffff">
30 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) {
33 Credit card <% $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' %>
37 <TD ALIGN="right">Card number</TD>
38 <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
41 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
43 %my $date = $cust_main->paydate || '12-2037';
44 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
45 % ( $mon, $year ) = ( $2, $1 );
46 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
47 % ( $mon, $year ) = ( $1, $3 );
49 % warn "unrecognized expiration date format: $date";
50 % ( $mon, $year ) = ( '', '' );
55 <TD ALIGN="right">Expiration</TD>
56 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
58 % if ( $cust_main->paystart_month ) {
61 <TD ALIGN="right">Start date</TD>
62 <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
64 % } elsif ( $cust_main->payissue ) {
67 <TD ALIGN="right">Issue #</TD>
68 <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
74 <TD ALIGN="right">Name on card</TD>
75 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
77 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
78 % my( $account, $aba ) = split('@', $cust_main->paymask );
81 Electronic check <% $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' %>
85 <TD ALIGN="right">ABA/Routing code</TD>
86 <TD BGCOLOR="#ffffff"><% $aba %></TD>
89 <TD ALIGN="right">Account number</TD>
90 <TD BGCOLOR="#ffffff"><% $account %></TD>
93 <TD ALIGN="right">Account type</TD>
94 <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
97 <TD ALIGN="right">Bank name</TD>
98 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
100 % if ( $conf->exists('show_bankstate') ) {
102 <TD ALIGN="right"><% $paystate_label %></TD>
103 <TD BGCOLOR="#ffffff"><% $cust_main->paystate || ' ' %></TD>
106 % } elsif ( $cust_main->payby eq 'LECB' ) {
107 % $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
108 % my $payinfo = "$1-$2-$3";
112 Phone bill billing
116 <TD ALIGN="right">Phone number</TD>
117 <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
119 % } elsif ( $cust_main->payby eq 'BILL' ) {
125 % if ( $cust_main->payinfo ) {
128 <TD ALIGN="right">P.O. </TD>
129 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
135 <TD ALIGN="right">Attention</TD>
136 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
138 % } elsif ( $cust_main->payby eq 'COMP' ) {
145 <TD ALIGN="right">Authorized by</TD>
146 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
149 %#false laziness w/above etc.
151 %my $date = $cust_main->paydate || '12-2037';
152 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
153 % ( $mon, $year ) = ( $2, $1 );
154 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
155 % ( $mon, $year ) = ( $1, $3 );
157 % warn "unrecognized expiration date format: $date";
158 % ( $mon, $year ) = ( '', '' );
163 <TD ALIGN="right">Expiration</TD>
164 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
168 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
170 <TD ALIGN="right">Tax exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
171 <TD BGCOLOR="#ffffff"><% $cust_main->tax ? 'yes' : 'no' %></TD>
173 % foreach my $exempt_group ( @exempt_groups ) {
175 <TD ALIGN="right">Tax exempt (<% $exempt_group %> taxes)</TD>
176 <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? 'yes' : 'no' %></TD>
180 % if ( $conf->exists('enable_taxproducts') ) {
182 <TD ALIGN="right">Tax location</TD>
183 <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
187 <TD ALIGN="right">Postal invoices</TD>
188 <TD BGCOLOR="#ffffff">
189 <% ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no' %>
193 <TD ALIGN="right">FAX invoices</TD>
194 <TD BGCOLOR="#ffffff">
195 <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'yes' : 'no' %>
199 <TD ALIGN="right">Email invoices</TD>
200 <TD BGCOLOR="#ffffff">
201 <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %>
205 <TD ALIGN="right">Invoice terms</TD>
206 <TD BGCOLOR="#ffffff">
207 <% $cust_main->invoice_terms || 'Default ('. ( $conf->config('invoice_default_terms') || 'Payable upon receipt' ). ')' %>
211 % if ( $conf->exists('voip-cust_cdr_spools') ) {
213 <TD ALIGN="right">Spool CDRs</TD>
214 <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? 'yes' : 'no' %></TD>
218 % if ( $conf->exists('voip-cust_cdr_squelch') ) {
220 <TD ALIGN="right">Print CDRs</TD>
221 <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? 'no' : 'yes' %></TD>
225 % if ( $conf->exists('voip-cust_email_csv_cdr') ) {
227 <TD ALIGN="right">Email CDRs as CSV</TD>
228 <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? 'yes' : 'no' %></TD>
232 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
234 <TD ALIGN="right">CDR termination settlement</TD>
235 <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
239 </TABLE></TD></TR></TABLE>
242 my $paystate_label = FS::Msgcat::_gettext('paystate');
243 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
248 my( $cust_main ) = @_;
249 my @invoicing_list = $cust_main->invoicing_list;
250 my $conf = new FS::Conf;
251 my $money_char = $conf->config('money_char') || '$';
253 #false laziness w/edit/cust_main/billing.html
254 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
255 my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
256 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
257 my $show_term = $term_sth->fetchrow_arrayref->[0];