1 <% mt('Billing information') |h %>
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 %>"><% mt('Bill now') |h %></A>)
9 (<& /elements/bill.html,
10 custnum => $cust_main->custnum,
11 label => emt('Bill now'),
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"><% mt('Balance due') |h %></TD>
23 <TD BGCOLOR="#ffffff"><B><% $balance %></B></TD>
26 % if ( $conf->exists('cust_main-select-billday')
27 % && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) {
29 <TD ALIGN="right"><% mt('Billing day of month') |h %></TD>
30 <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
36 <TD ALIGN="right"><% mt('Billing type') |h %></TD>
37 <TD BGCOLOR="#ffffff">
38 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) {
40 % my $autodemand = $cust_main->payby eq 'CARD' ? 'automatic' : 'on-demand';
41 <% mt("Credit card ([_1])",$autodemand) |h %>
45 <TD ALIGN="right"><% mt('Card number') |h %></TD>
46 <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
49 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
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 );
57 % warn "unrecognized expiration date format: $date";
58 % ( $mon, $year ) = ( '', '' );
63 <TD ALIGN="right"><% mt('Expiration') |h %></TD>
64 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
66 % if ( $cust_main->paystart_month ) {
69 <TD ALIGN="right"><% mt('Start date') |h %></TD>
70 <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
72 % } elsif ( $cust_main->payissue ) {
75 <TD ALIGN="right"><% mt('Issue #') |h %></TD>
76 <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
82 <TD ALIGN="right"><% mt('Name on card') |h %></TD>
83 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
85 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
86 % my( $account, $aba ) = split('@', $cust_main->paymask );
88 % ($branch,$aba) = split('\.',$aba) if $conf->exists('cust_main-require-bank-branch');
91 % my $autodemand = $cust_main->payby eq 'CHEK' ? 'automatic' : 'on-demand';
92 <% mt("Electronic check ([_1])",$autodemand) |h %>
96 % unless ( $conf->exists('echeck-no_routing') ) {
98 <TD ALIGN="right"><% mt('ABA/Routing code') |h %></TD>
99 <TD BGCOLOR="#ffffff"><% $aba %></TD>
103 % if ( $conf->exists('cust_main-require-bank-branch') ) {
105 <TD ALIGN="right"><% mt('Branch number') |h %></TD>
106 <TD BGCOLOR="#ffffff"><% $branch %></TD>
110 <TD ALIGN="right"><% mt('Account number') |h %></TD>
111 <TD BGCOLOR="#ffffff"><% $account %></TD>
114 <TD ALIGN="right"><% mt('Account type') |h %></TD>
115 <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
118 <TD ALIGN="right"><% mt('Bank name') |h %></TD>
119 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
121 % if ( $conf->exists('show_bankstate') ) {
123 <TD ALIGN="right"><% $paystate_label %></TD>
124 <TD BGCOLOR="#ffffff"><% $cust_main->paystate || ' ' %></TD>
127 % } elsif ( $cust_main->payby eq 'LECB' ) {
128 % $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
129 % my $payinfo = "$1-$2-$3";
131 <% mt('Phone bill billing') |h %>
135 <TD ALIGN="right"><% mt('Phone number') |h %></TD>
136 <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
138 % } elsif ( $cust_main->payby eq 'BILL' ) {
140 <% mt('Billing') |h %>
143 % if ( $cust_main->payinfo ) {
146 <TD ALIGN="right"<% mt('>P.O.') |h %></TD>
147 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
153 <TD ALIGN="right"><% mt('Attention') |h %></TD>
154 <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
156 % } elsif ( $cust_main->payby eq 'COMP' ) {
158 <% mt('Complimentary') |h %>
162 <TD ALIGN="right"><% mt('Authorized by') |h %></TD>
163 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
166 %#false laziness w/above etc.
168 %my $date = $cust_main->paydate || '12-2037';
169 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
170 % ( $mon, $year ) = ( $2, $1 );
171 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
172 % ( $mon, $year ) = ( $1, $3 );
174 % warn "unrecognized expiration date format: $date";
175 % ( $mon, $year ) = ( '', '' );
180 <TD ALIGN="right"><% mt('Expiration') |h %></TD>
181 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
185 % my $yes = emt('yes');
186 % my $no = emt('no');
188 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
190 <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
191 <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
193 % foreach my $exempt_group ( @exempt_groups ) {
195 <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
196 <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? $yes : $no %></TD>
200 % if ( $conf->exists('enable_taxproducts') ) {
202 <TD ALIGN="right"><% mt('Tax location') |h %></TD>
203 <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
207 <TD ALIGN="right"><% mt('Postal invoices') |h %></TD>
208 <TD BGCOLOR="#ffffff">
209 <% ( grep { $_ eq 'POST' } @invoicing_list ) ? $yes : $no %>
213 <TD ALIGN="right"><% mt('FAX invoices') |h %></TD>
214 <TD BGCOLOR="#ffffff">
215 <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? $yes : $no %>
218 % unless ( $conf->exists('cust-email-high-visibility')) {
220 <TD ALIGN="right"><% mt('Email invoices') |h %></TD>
221 <TD BGCOLOR="#ffffff">
222 <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
227 <TD ALIGN="right"><% mt('Invoice terms') |h %></TD>
228 <TD BGCOLOR="#ffffff">
229 <% $cust_main->invoice_terms || emt('Default').' ('. ( $conf->config('invoice_default_terms') || emt('Payable upon receipt') ). ')' %>
233 <TD ALIGN="right"><% mt('Credit limit') |h %></TD>
234 <TD BGCOLOR="#ffffff">
235 <% length($cust_main->credit_limit) ?
236 $money_char.sprintf("%.2f", $cust_main->credit_limit) :
241 % if ( $conf->exists('voip-cust_cdr_spools') ) {
243 <TD ALIGN="right"><% mt('Spool CDRs') |h %></TD>
244 <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? $yes : $no %></TD>
248 % if ( $conf->exists('voip-cust_cdr_squelch') ) {
250 <TD ALIGN="right"><% mt($conf->exists('voip-cdr_email') ? 'Print CDRs' : 'Show CDRs') |h %></TD>
251 <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? $no : $yes %></TD>
255 % if ( $conf->exists('voip-cust_accountcode_cdr') ) {
257 <TD ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TD>
258 <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
262 % if ( $conf->exists('voip-cust_email_csv_cdr') ) {
264 <TD ALIGN="right"><% mt('Email CDRs as CSV') |h %></TD>
265 <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
269 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
271 <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
272 <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
276 </TABLE></TD></TR></TABLE>
279 my $paystate_label = FS::Msgcat::_gettext('paystate');
280 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
285 my( $cust_main ) = @_;
286 my @invoicing_list = $cust_main->invoicing_list;
287 my $conf = new FS::Conf;
288 my $money_char = $conf->config('money_char') || '$';
290 #false laziness w/edit/cust_main/billing.html
291 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
292 my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
293 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
294 my $show_term = $term_sth->fetchrow_arrayref->[0];