1 <FONT CLASS="fsinnerbox-title"><% mt('Billing information') |h %></FONT>
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 <TABLE CLASS="fsinnerbox">
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 <TR ID="recurring_row">
27 <TD ID="recurring_label" ALIGN="right"><% emt( 'Recurring' ) %></TD>
28 <TD ID="recurring_value" BGCOLOR="#ffffff"><IMG SRC="<% $fsurl %>images/wait-orange.gif"></TD>
31 <& '/elements/xmlhttp.html',
32 'url' => $fsurl.'misc/xmlhttp-cust_main-display_recurring.html',
33 'subs' => [ 'get_display_recurring'] &>
36 <&| /elements/onload.js &>
37 get_display_recurring('custnum',<% $cust_main->custnum %>, function (xmlresult) {
38 var recurring = JSON.parse(xmlresult);
39 var rlabel = document.getElementById('recurring_label');
40 var rvalue = document.getElementById('recurring_value');
41 var rrow = document.getElementById('recurring_row');
42 if (recurring['error']) {
43 rvalue.innerHTML = '<SPAN STYLE="color: red">Error</SPAN>';
44 console.log('display_recurring error: ' + recurring['error']);
45 } else if (recurring['display_recurring'].length) {
46 for (var ri = 0; ri < recurring['display_recurring'].length; ri++) {
47 var robj = recurring['display_recurring'][ri];
48 var freq_pretty = robj['freq_pretty'].charAt(0).toUpperCase()+robj['freq_pretty'].slice(1)+' recurring';
49 var amount = '<% $money_char %>'+parseFloat(robj['amount']).toFixed(2);
50 if (ri + 1 < recurring['display_recurring'].length) {
51 var rr = document.createElement('TR');
52 var rl = document.createElement('TD');
53 rl.style.textAlign = 'right';
54 rl.innerHTML = freq_pretty;
56 var rv = document.createElement('TD');
57 rv.style.backgroundColor = '#ffffff';
58 rv.innerHTML = amount;
60 rrow.parentNode.insertBefore(rr,rrow);
62 rlabel.innerHTML = freq_pretty;
63 rvalue.innerHTML = amount;
67 rrow.parentNode.removeChild(rrow);
73 % if ( $conf->exists('cust_main-select-prorate_day') ) {
75 <TD ALIGN="right"><% mt('Prorate day of month') |h %></TD>
76 <TD BGCOLOR="#ffffff"><% $cust_main->prorate_day %>
81 % if ( $conf->exists('cust_main-select-billday')
82 % && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) {
84 <TD ALIGN="right"><% mt('Billing day of month') |h %></TD>
85 <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
91 <TD ALIGN="right"><% mt('Billing type') |h %></TD>
92 <TD BGCOLOR="#ffffff">
93 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) {
95 % my $autodemand = $cust_main->payby eq 'CARD' ? 'automatic' : 'on-demand';
96 <% mt("Credit card ([_1])",$autodemand) |h %>
100 <TD ALIGN="right"><% mt('Card number') |h %></TD>
101 <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
104 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
106 %my $date = $cust_main->paydate || '12-2037';
107 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
108 % ( $mon, $year ) = ( $2, $1 );
109 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
110 % ( $mon, $year ) = ( $1, $3 );
112 % warn "unrecognized expiration date format: $date";
113 % ( $mon, $year ) = ( '', '' );
118 <TD ALIGN="right"><% mt('Expiration') |h %></TD>
119 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
121 % if ( $cust_main->paystart_month ) {
124 <TD ALIGN="right"><% mt('Start date') |h %></TD>
125 <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
127 % } elsif ( $cust_main->payissue ) {
130 <TD ALIGN="right"><% mt('Issue #') |h %></TD>
131 <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
137 <TD ALIGN="right"><% mt('Name on card') |h %></TD>
138 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
140 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
141 % my( $account, $aba ) = split('@', $cust_main->paymask );
143 % ($branch,$aba) = split('\.',$aba) if $conf->config('echeck-country') eq 'CA';
146 % my $autodemand = $cust_main->payby eq 'CHEK' ? 'automatic' : 'on-demand';
147 <% mt("Electronic check ([_1])",$autodemand) |h %>
151 % #false laziness w/edit/cust_main/billing.html and misc/payment.cgi
152 % my $routing_label = $conf->config('echeck-country') eq 'US'
153 % ? 'ABA/Routing number'
154 % : 'Routing number';
157 <TD ALIGN="right"><% mt($routing_label) |h %></TD>
158 <TD BGCOLOR="#ffffff"><% $aba %></TD>
161 % if ( $conf->config('echeck-country') eq 'CA' ) {
163 <TD ALIGN="right"><% mt('Branch number') |h %></TD>
164 <TD BGCOLOR="#ffffff"><% $branch %></TD>
168 <TD ALIGN="right"><% mt('Account number') |h %></TD>
169 <TD BGCOLOR="#ffffff"><% $account %></TD>
172 <TD ALIGN="right"><% mt('Account type') |h %></TD>
173 <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
176 <TD ALIGN="right"><% mt('Bank name') |h %></TD>
177 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
179 % if ( $conf->exists('show_bankstate') ) {
181 <TD ALIGN="right"><% $paystate_label %></TD>
182 <TD BGCOLOR="#ffffff"><% $cust_main->paystate || ' ' %></TD>
185 % } elsif ( $cust_main->payby eq 'LECB' ) {
186 % $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
187 % my $payinfo = "$1-$2-$3";
189 <% mt('Phone bill billing') |h %>
193 <TD ALIGN="right"><% mt('Phone number') |h %></TD>
194 <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
196 % } elsif ( $cust_main->payby eq 'BILL' ) {
198 <% mt('Billing') |h %>
201 % if ( $cust_main->payinfo ) {
204 <TD ALIGN="right"><% mt('P.O.') |h %></TD>
205 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
211 <TD ALIGN="right"><% mt('Attention') |h %></TD>
212 <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
214 % } elsif ( $cust_main->payby eq 'COMP' ) {
216 <% mt('Complimentary') |h %>
220 <TD ALIGN="right"><% mt('Authorized by') |h %></TD>
221 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
224 %#false laziness w/above etc.
226 %my $date = $cust_main->paydate || '12-2037';
227 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
228 % ( $mon, $year ) = ( $2, $1 );
229 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
230 % ( $mon, $year ) = ( $1, $3 );
232 % warn "unrecognized expiration date format: $date";
233 % ( $mon, $year ) = ( '', '' );
238 <TD ALIGN="right"><% mt('Expiration') |h %></TD>
239 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
243 % my $yes = emt('yes');
244 % my $no = emt('no');
246 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
248 % unless ( $conf->exists('cust_class-tax_exempt')
249 % || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
253 <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
254 <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
258 % foreach my $exempt_group ( @exempt_groups ) {
259 % my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
261 <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
262 <TD BGCOLOR="#ffffff"><% $cust_main_exemption ? $yes : $no %>
263 <% $cust_main_exemption ? $cust_main_exemption->exempt_number : '' |h %>
268 % if ( $conf->exists('enable_taxproducts') ) {
270 <TD ALIGN="right"><% mt('Tax location') |h %></TD>
271 % my $tax_location = $conf->exists('tax-ship_address')
272 % ? $cust_main->ship_location
273 % : $cust_main->bill_location;
274 <TD BGCOLOR="#ffffff"><% $tax_location->geocode('cch') %></TD>
278 <TD ALIGN="right"><% mt('Postal mail invoices') |h %></TD>
279 <TD BGCOLOR="#ffffff">
280 <% ( grep { $_ eq 'POST' } @invoicing_list ) ? $yes : $no %>
284 <TD ALIGN="right"><% mt('Fax invoices') |h %></TD>
285 <TD BGCOLOR="#ffffff">
286 <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? $yes : $no %>
290 <TD ALIGN="right"><% mt('Email invoices') |h %></TD>
291 <TD BGCOLOR="#ffffff">
292 <% $cust_main->invoice_noemail ? $no : $yes %>
295 % unless ( $conf->exists('cust-email-high-visibility')) {
297 <TD ALIGN="right"><% mt('Email address(es)') |h %></TD>
298 <TD BGCOLOR="#ffffff">
299 <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
300 % if ( $cust_main->message_noemail ) {
302 <SPAN STYLE="font-size: small"><% emt('(do not send notices)') %></SPAN>
308 <TD ALIGN="right"><% mt('Invoice terms') |h %></TD>
309 <TD BGCOLOR="#ffffff">
310 <% $cust_main->invoice_terms
311 || emt('Default').' ('. ( $conf->config('invoice_default_terms', $cust_main->agentnum)
312 || emt('Payable upon receipt')
319 <TD ALIGN="right"><% mt('Credit limit') |h %></TD>
320 <TD BGCOLOR="#ffffff">
321 % my $default_credit_limit = $conf->config('default_credit_limit');
322 <% length($cust_main->credit_limit)
323 ? $money_char. sprintf("%.2f", $cust_main->credit_limit)
324 : $default_credit_limit
325 ? "Default ($money_char". sprintf("%.2f", $default_credit_limit). ")"
328 % if ( $cust_main->num_cust_main_credit_limit ) {
329 <A HREF="<% $p %>search/cust_main_credit_limit.html?custnum=<% $cust_main->custnum %>">(incidents)</A>
334 % if ( $conf->exists('voip-cust_cdr_spools') ) {
336 <TD ALIGN="right"><% mt('Spool CDRs') |h %></TD>
337 <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? $yes : $no %></TD>
341 % if ( $conf->exists('voip-cust_cdr_squelch') ) {
343 <TD ALIGN="right"><% mt($conf->exists('voip-cdr_email') ? 'Print CDRs' : 'Show CDRs') |h %></TD>
344 <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? $no : $yes %></TD>
348 % if ( $conf->exists('voip-cust_accountcode_cdr') ) {
350 <TD ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TD>
351 <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
355 % if ( my $attach = $conf->config('voip-cdr_email_attach') ) {
357 <TD ALIGN="right"><% mt('Email CDRs as '.uc($attach)) |h %></TD>
358 <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
362 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
364 <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
365 <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
369 % if ( $cust_main->locale ) {
370 % my %locale_info = FS::Locales->locale_info($cust_main->locale);
372 <TD ALIGN="right"><% mt('Invoicing locale') |h %></TD>
373 <TD BGCOLOR="#ffffff"><% $locale_info{name} . " (" . $locale_info{country} .")" %></TD>
381 my $paystate_label = FS::Msgcat::_gettext('paystate');
382 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
387 my( $cust_main ) = @_;
388 my @invoicing_list = $cust_main->invoicing_list;
389 my $conf = new FS::Conf;
390 my $money_char = $conf->config('money_char') || '$';
392 #false laziness w/edit/cust_main/billing.html
393 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
394 my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
395 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
396 my $show_term = $term_sth->fetchrow_arrayref->[0];