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>)
11 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
13 %( my $balance = $cust_main->balance )
14 % =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/;
17 <TD ALIGN="right">Balance due</TD>
18 <TD BGCOLOR="#ffffff"><B><% $balance %></B></TD>
22 <TD ALIGN="right">Billing type</TD>
23 <TD BGCOLOR="#ffffff">
24 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) {
27 Credit card <% $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' %>
31 <TD ALIGN="right">Card number</TD>
32 <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
35 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
37 %my $date = $cust_main->paydate || '12-2037';
38 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
39 % ( $mon, $year ) = ( $2, $1 );
40 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
41 % ( $mon, $year ) = ( $1, $3 );
43 % warn "unrecognized expiration date format: $date";
44 % ( $mon, $year ) = ( '', '' );
49 <TD ALIGN="right">Expiration</TD>
50 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
52 % if ( $cust_main->paystart_month ) {
55 <TD ALIGN="right">Start date</TD>
56 <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
58 % } elsif ( $cust_main->payissue ) {
61 <TD ALIGN="right">Issue #</TD>
62 <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
68 <TD ALIGN="right">Name on card</TD>
69 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
71 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
72 % my( $account, $aba ) = split('@', $cust_main->paymask );
75 Electronic check <% $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' %>
79 <TD ALIGN="right">ABA/Routing code</TD>
80 <TD BGCOLOR="#ffffff"><% $aba %></TD>
83 <TD ALIGN="right">Account number</TD>
84 <TD BGCOLOR="#ffffff"><% $account %></TD>
87 <TD ALIGN="right">Account type</TD>
88 <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
91 <TD ALIGN="right">Bank name</TD>
92 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
94 % if ( $conf->exists('show_bankstate') ) {
96 <TD ALIGN="right"><% $paystate_label %></TD>
97 <TD BGCOLOR="#ffffff"><% $cust_main->paystate || ' ' %></TD>
100 % } elsif ( $cust_main->payby eq 'LECB' ) {
101 % $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
102 % my $payinfo = "$1-$2-$3";
106 Phone bill billing
110 <TD ALIGN="right">Phone number</TD>
111 <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
113 % } elsif ( $cust_main->payby eq 'BILL' ) {
119 % if ( $cust_main->payinfo ) {
122 <TD ALIGN="right">P.O. </TD>
123 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
129 <TD ALIGN="right">Attention</TD>
130 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
132 % } elsif ( $cust_main->payby eq 'COMP' ) {
139 <TD ALIGN="right">Authorized by</TD>
140 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
143 %#false laziness w/above etc.
145 %my $date = $cust_main->paydate || '12-2037';
146 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
147 % ( $mon, $year ) = ( $2, $1 );
148 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
149 % ( $mon, $year ) = ( $1, $3 );
151 % warn "unrecognized expiration date format: $date";
152 % ( $mon, $year ) = ( '', '' );
157 <TD ALIGN="right">Expiration</TD>
158 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
162 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
164 <TD ALIGN="right">Tax exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
165 <TD BGCOLOR="#ffffff"><% $cust_main->tax ? 'yes' : 'no' %></TD>
167 % foreach my $exempt_group ( @exempt_groups ) {
169 <TD ALIGN="right">Tax exempt (<% $exempt_group %> taxes)</TD>
170 <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? 'yes' : 'no' %></TD>
174 % if ( $conf->exists('enable_taxproducts') ) {
176 <TD ALIGN="right">Tax location</TD>
177 <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
181 <TD ALIGN="right">Postal invoices</TD>
182 <TD BGCOLOR="#ffffff">
183 <% ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no' %>
187 <TD ALIGN="right">FAX invoices</TD>
188 <TD BGCOLOR="#ffffff">
189 <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'yes' : 'no' %>
193 <TD ALIGN="right">Email invoices</TD>
194 <TD BGCOLOR="#ffffff">
195 <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %>
199 <TD ALIGN="right">Invoice terms</TD>
200 <TD BGCOLOR="#ffffff">
201 <% $cust_main->invoice_terms || 'Default ('. ( $conf->config('invoice_default_terms') || 'Payable upon receipt' ). ')' %>
205 % if ( $conf->exists('voip-cust_cdr_spools') ) {
207 <TD ALIGN="right">Spool CDRs</TD>
208 <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? 'yes' : 'no' %></TD>
212 % if ( $conf->exists('voip-cust_cdr_squelch') ) {
214 <TD ALIGN="right">Print CDRs</TD>
215 <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? 'no' : 'yes' %></TD>
219 % if ( $conf->exists('voip-cust_email_csv_cdr') ) {
221 <TD ALIGN="right">Email CDRs as CSV</TD>
222 <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? 'yes' : 'no' %></TD>
226 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
228 <TD ALIGN="right">CDR termination settlement</TD>
229 <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
233 </TABLE></TD></TR></TABLE>
236 my $paystate_label = FS::Msgcat::_gettext('paystate');
237 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
242 my( $cust_main ) = @_;
243 my @invoicing_list = $cust_main->invoicing_list;
244 my $conf = new FS::Conf;
245 my $money_char = $conf->config('money_char') || '$';
247 #false laziness w/edit/cust_main/billing.html
248 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
249 my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
250 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
251 my $show_term = $term_sth->fetchrow_arrayref->[0];