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 function set_display_recurring (xmlresult) {
37 var recurring = JSON.parse(xmlresult);
38 var rlabel = document.getElementById('recurring_label');
39 var rvalue = document.getElementById('recurring_value');
40 var rrow = document.getElementById('recurring_row');
41 if (recurring['error']) {
42 rvalue.innerHTML = '<SPAN STYLE="color: red">Error</SPAN>';
43 console.log('display_recurring error: ' + recurring['error']);
44 } else if (recurring['display_recurring'].length) {
45 for (var ri = 0; ri < recurring['display_recurring'].length; ri++) {
46 var robj = recurring['display_recurring'][ri];
47 var freq_pretty = robj['freq_pretty'].charAt(0).toUpperCase()+robj['freq_pretty'].slice(1)+' recurring';
48 var amount = '<% $money_char %>'+parseFloat(robj['amount']).toFixed(2);
49 if (ri + 1 < recurring['display_recurring'].length) {
50 var rr = document.createElement('TR');
51 var rl = document.createElement('TD');
52 rl.style.textAlign = 'right';
53 rl.innerHTML = freq_pretty;
55 var rv = document.createElement('TD');
56 rv.style.backgroundColor = '#ffffff';
57 rv.innerHTML = amount;
59 rrow.parentNode.insertBefore(rr,rrow);
61 rlabel.innerHTML = freq_pretty;
62 rvalue.innerHTML = amount;
66 rrow.parentNode.removeChild(rrow);
71 % # 10 is an arbitrary number, use ajax for customers with many packages
72 % if ( $cust_main->num_billing_pkgs > 10 ) {
73 <& '/elements/xmlhttp.html',
74 'url' => $fsurl.'misc/xmlhttp-cust_main-display_recurring.html',
75 'subs' => [ 'get_display_recurring'] &>
77 get_display_recurring('custnum',<% $cust_main->custnum %>,set_display_recurring);
81 set_display_recurring(<% encode_json({'display_recurring' => [ $cust_main->display_recurring ]}) |js_string %>);
85 % if ( $conf->exists('cust_main-select-prorate_day') ) {
87 <TD ALIGN="right"><% mt('Prorate day of month') |h %></TD>
88 <TD BGCOLOR="#ffffff"><% $cust_main->prorate_day %>
93 % if ( $conf->exists('cust_main-select-billday')
94 % && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) {
96 <TD ALIGN="right"><% mt('Billing day of month') |h %></TD>
97 <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
103 <TD ALIGN="right"><% mt('Billing type') |h %></TD>
104 <TD BGCOLOR="#ffffff">
105 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) {
107 % my $autodemand = $cust_main->payby eq 'CARD' ? 'automatic' : 'on-demand';
108 <% mt("Credit card ([_1])",$autodemand) |h %>
112 <TD ALIGN="right"><% mt('Card number') |h %></TD>
113 <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
116 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
118 %my $date = $cust_main->paydate || '12-2037';
119 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
120 % ( $mon, $year ) = ( $2, $1 );
121 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
122 % ( $mon, $year ) = ( $1, $3 );
124 % warn "unrecognized expiration date format: $date";
125 % ( $mon, $year ) = ( '', '' );
130 <TD ALIGN="right"><% mt('Expiration') |h %></TD>
131 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
133 % if ( $cust_main->paystart_month ) {
136 <TD ALIGN="right"><% mt('Start date') |h %></TD>
137 <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
139 % } elsif ( $cust_main->payissue ) {
142 <TD ALIGN="right"><% mt('Issue #') |h %></TD>
143 <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
149 <TD ALIGN="right"><% mt('Name on card') |h %></TD>
150 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
152 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
153 % my( $account, $aba ) = split('@', $cust_main->paymask );
155 % ($branch,$aba) = split('\.',$aba) if $conf->config('echeck-country') eq 'CA';
158 % my $autodemand = $cust_main->payby eq 'CHEK' ? 'automatic' : 'on-demand';
159 <% mt("Electronic check ([_1])",$autodemand) |h %>
163 % #false laziness w/edit/cust_main/billing.html and misc/payment.cgi
164 % my $routing_label = $conf->config('echeck-country') eq 'US'
165 % ? 'ABA/Routing number'
166 % : 'Routing number';
169 <TD ALIGN="right"><% mt($routing_label) |h %></TD>
170 <TD BGCOLOR="#ffffff"><% $aba %></TD>
173 % if ( $conf->config('echeck-country') eq 'CA' ) {
175 <TD ALIGN="right"><% mt('Branch number') |h %></TD>
176 <TD BGCOLOR="#ffffff"><% $branch %></TD>
180 <TD ALIGN="right"><% mt('Account number') |h %></TD>
181 <TD BGCOLOR="#ffffff"><% $account %></TD>
184 <TD ALIGN="right"><% mt('Account type') |h %></TD>
185 <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
188 <TD ALIGN="right"><% mt('Bank name') |h %></TD>
189 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
191 % if ( $conf->exists('show_bankstate') ) {
193 <TD ALIGN="right"><% $paystate_label %></TD>
194 <TD BGCOLOR="#ffffff"><% $cust_main->paystate || ' ' %></TD>
197 % } elsif ( $cust_main->payby eq 'LECB' ) {
198 % $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
199 % my $payinfo = "$1-$2-$3";
201 <% mt('Phone bill billing') |h %>
205 <TD ALIGN="right"><% mt('Phone number') |h %></TD>
206 <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
208 % } elsif ( $cust_main->payby eq 'BILL' ) {
210 <% mt('Billing') |h %>
213 % if ( $cust_main->payinfo ) {
216 <TD ALIGN="right"><% mt('P.O.') |h %></TD>
217 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
223 <TD ALIGN="right"><% mt('Attention') |h %></TD>
224 <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
226 % } elsif ( $cust_main->payby eq 'COMP' ) {
228 <% mt('Complimentary') |h %>
232 <TD ALIGN="right"><% mt('Authorized by') |h %></TD>
233 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
236 %#false laziness w/above etc.
238 %my $date = $cust_main->paydate || '12-2037';
239 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
240 % ( $mon, $year ) = ( $2, $1 );
241 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
242 % ( $mon, $year ) = ( $1, $3 );
244 % warn "unrecognized expiration date format: $date";
245 % ( $mon, $year ) = ( '', '' );
250 <TD ALIGN="right"><% mt('Expiration') |h %></TD>
251 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
255 % my $yes = emt('yes');
256 % my $no = emt('no');
258 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
260 % unless ( $conf->exists('cust_class-tax_exempt')
261 % || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
265 <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
266 <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
270 % foreach my $exempt_group ( @exempt_groups ) {
271 % my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
273 <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
274 <TD BGCOLOR="#ffffff"><% $cust_main_exemption ? $yes : $no %>
275 <% $cust_main_exemption ? $cust_main_exemption->exempt_number : '' |h %>
280 % if ( $conf->exists('enable_taxproducts') ) {
282 <TD ALIGN="right"><% mt('Tax location') |h %></TD>
283 % my $tax_location = $conf->exists('tax-ship_address')
284 % ? $cust_main->ship_location
285 % : $cust_main->bill_location;
286 <TD BGCOLOR="#ffffff"><% $tax_location->geocode('cch') %></TD>
290 <TD ALIGN="right"><% mt('Postal mail invoices') |h %></TD>
291 <TD BGCOLOR="#ffffff">
292 <% ( grep { $_ eq 'POST' } @invoicing_list ) ? $yes : $no %>
296 <TD ALIGN="right"><% mt('Fax invoices') |h %></TD>
297 <TD BGCOLOR="#ffffff">
298 <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? $yes : $no %>
302 <TD ALIGN="right"><% mt('Email invoices') |h %></TD>
303 <TD BGCOLOR="#ffffff">
304 <% $cust_main->invoice_noemail ? $no : $yes %>
307 % unless ( $conf->exists('cust-email-high-visibility')) {
309 <TD ALIGN="right"><% mt('Email address(es)') |h %></TD>
310 <TD BGCOLOR="#ffffff">
311 <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
312 % if ( $cust_main->message_noemail ) {
314 <SPAN STYLE="font-size: small"><% emt('(do not send notices)') %></SPAN>
320 <TD ALIGN="right"><% mt('Invoice terms') |h %></TD>
321 <TD BGCOLOR="#ffffff">
322 <% $cust_main->invoice_terms
323 || emt('Default').' ('. ( $conf->config('invoice_default_terms', $cust_main->agentnum)
324 || emt('Payable upon receipt')
331 <TD ALIGN="right"><% mt('Credit limit') |h %></TD>
332 <TD BGCOLOR="#ffffff">
333 % my $default_credit_limit = $conf->config('default_credit_limit');
334 <% length($cust_main->credit_limit)
335 ? $money_char. sprintf("%.2f", $cust_main->credit_limit)
336 : $default_credit_limit
337 ? "Default ($money_char". sprintf("%.2f", $default_credit_limit). ")"
340 % if ( $cust_main->num_cust_main_credit_limit ) {
341 <A HREF="<% $p %>search/cust_main_credit_limit.html?custnum=<% $cust_main->custnum %>">(incidents)</A>
346 % if ( $conf->exists('voip-cust_cdr_spools') ) {
348 <TD ALIGN="right"><% mt('Spool CDRs') |h %></TD>
349 <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? $yes : $no %></TD>
353 % if ( $conf->exists('voip-cust_cdr_squelch') ) {
355 <TD ALIGN="right"><% mt($conf->exists('voip-cdr_email') ? 'Print CDRs' : 'Show CDRs') |h %></TD>
356 <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? $no : $yes %></TD>
360 % if ( $conf->exists('voip-cust_accountcode_cdr') ) {
362 <TD ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TD>
363 <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
367 % if ( my $attach = $conf->config('voip-cdr_email_attach') ) {
369 <TD ALIGN="right"><% mt('Email CDRs as '.uc($attach)) |h %></TD>
370 <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
374 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
376 <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
377 <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
381 % if ( $cust_main->locale ) {
382 % my %locale_info = FS::Locales->locale_info($cust_main->locale);
384 <TD ALIGN="right"><% mt('Invoicing locale') |h %></TD>
385 <TD BGCOLOR="#ffffff"><% $locale_info{name} . " (" . $locale_info{country} .")" %></TD>
393 my $paystate_label = FS::Msgcat::_gettext('paystate');
394 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
399 my( $cust_main ) = @_;
400 my @invoicing_list = $cust_main->invoicing_list;
401 my $conf = new FS::Conf;
402 my $money_char = $conf->config('money_char') || '$';
404 #false laziness w/edit/cust_main/billing.html
405 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
406 my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
407 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
408 my $show_term = $term_sth->fetchrow_arrayref->[0];