3 %# If we can't see the unencrypted card, then bill now is an exercise in
4 %# frustration (without some sort of job queue magic to send it to a secure
6 %if ( $FS::CurrentUser::CurrentUser->access_right('Bill customer now')
7 % && ! $cust_main->is_encrypted($cust_main->payinfo)
9 %# (<A HREF="<% $p %>misc/bill.cgi?<% $cust_main->custnum %>">Bill now</A>)
10 (<% include('/elements/bill.html',
11 custnum => $cust_main->custnum,
13 formname => 'billnow',
14 url => $p.'view/cust_main.cgi?'.$cust_main->custnum,
18 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
20 %( my $balance = $cust_main->balance )
21 % =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/;
24 <TD ALIGN="right">Balance due</TD>
25 <TD BGCOLOR="#ffffff"><B><% $balance %></B></TD>
29 <TD ALIGN="right">Billing type</TD>
30 <TD BGCOLOR="#ffffff">
31 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) {
34 Credit card <% $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' %>
38 <TD ALIGN="right">Card number</TD>
39 <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
42 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
44 %my $date = $cust_main->paydate || '12-2037';
45 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
46 % ( $mon, $year ) = ( $2, $1 );
47 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
48 % ( $mon, $year ) = ( $1, $3 );
50 % warn "unrecognized expiration date format: $date";
51 % ( $mon, $year ) = ( '', '' );
56 <TD ALIGN="right">Expiration</TD>
57 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
59 % if ( $cust_main->paystart_month ) {
62 <TD ALIGN="right">Start date</TD>
63 <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
65 % } elsif ( $cust_main->payissue ) {
68 <TD ALIGN="right">Issue #</TD>
69 <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
75 <TD ALIGN="right">Name on card</TD>
76 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
78 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
79 % my( $account, $aba ) = split('@', $cust_main->paymask );
82 Electronic check <% $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' %>
86 <TD ALIGN="right">ABA/Routing code</TD>
87 <TD BGCOLOR="#ffffff"><% $aba %></TD>
90 <TD ALIGN="right">Account number</TD>
91 <TD BGCOLOR="#ffffff"><% $account %></TD>
94 <TD ALIGN="right">Account type</TD>
95 <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
98 <TD ALIGN="right">Bank name</TD>
99 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
101 % if ( $conf->exists('show_bankstate') ) {
103 <TD ALIGN="right"><% $paystate_label %></TD>
104 <TD BGCOLOR="#ffffff"><% $cust_main->paystate || ' ' %></TD>
107 % } elsif ( $cust_main->payby eq 'LECB' ) {
108 % $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
109 % my $payinfo = "$1-$2-$3";
113 Phone bill billing
117 <TD ALIGN="right">Phone number</TD>
118 <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
120 % } elsif ( $cust_main->payby eq 'BILL' ) {
126 % if ( $cust_main->payinfo ) {
129 <TD ALIGN="right">P.O. </TD>
130 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
136 <TD ALIGN="right">Attention</TD>
137 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
139 % } elsif ( $cust_main->payby eq 'COMP' ) {
146 <TD ALIGN="right">Authorized by</TD>
147 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
150 %#false laziness w/above etc.
152 %my $date = $cust_main->paydate || '12-2037';
153 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
154 % ( $mon, $year ) = ( $2, $1 );
155 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
156 % ( $mon, $year ) = ( $1, $3 );
158 % warn "unrecognized expiration date format: $date";
159 % ( $mon, $year ) = ( '', '' );
164 <TD ALIGN="right">Expiration</TD>
165 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
169 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
171 <TD ALIGN="right">Tax exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
172 <TD BGCOLOR="#ffffff"><% $cust_main->tax ? 'yes' : 'no' %></TD>
174 % foreach my $exempt_group ( @exempt_groups ) {
176 <TD ALIGN="right">Tax exempt (<% $exempt_group %> taxes)</TD>
177 <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? 'yes' : 'no' %></TD>
181 % if ( $conf->exists('enable_taxproducts') ) {
183 <TD ALIGN="right">Tax location</TD>
184 <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
188 <TD ALIGN="right">Postal invoices</TD>
189 <TD BGCOLOR="#ffffff">
190 <% ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no' %>
194 <TD ALIGN="right">FAX invoices</TD>
195 <TD BGCOLOR="#ffffff">
196 <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'yes' : 'no' %>
200 <TD ALIGN="right">Email invoices</TD>
201 <TD BGCOLOR="#ffffff">
202 <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %>
206 <TD ALIGN="right">Invoice terms</TD>
207 <TD BGCOLOR="#ffffff">
208 <% $cust_main->invoice_terms || 'Default ('. ( $conf->config('invoice_default_terms') || 'Payable upon receipt' ). ')' %>
212 % if ( $conf->exists('voip-cust_cdr_spools') ) {
214 <TD ALIGN="right">Spool CDRs</TD>
215 <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? 'yes' : 'no' %></TD>
219 % if ( $conf->exists('voip-cust_cdr_squelch') ) {
221 <TD ALIGN="right">Print CDRs</TD>
222 <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? 'no' : 'yes' %></TD>
226 % if ( $conf->exists('voip-cust_email_csv_cdr') ) {
228 <TD ALIGN="right">Email CDRs as CSV</TD>
229 <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? 'yes' : 'no' %></TD>
233 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
235 <TD ALIGN="right">CDR termination settlement</TD>
236 <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
240 </TABLE></TD></TR></TABLE>
243 my $paystate_label = FS::Msgcat::_gettext('paystate');
244 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
249 my( $cust_main ) = @_;
250 my @invoicing_list = $cust_main->invoicing_list;
251 my $conf = new FS::Conf;
252 my $money_char = $conf->config('money_char') || '$';
254 #false laziness w/edit/cust_main/billing.html
255 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
256 my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
257 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
258 my $show_term = $term_sth->fetchrow_arrayref->[0];