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 % #54: just an arbitrary number i pulled out of my goober. ideally we'd like
27 % # to consider e.g. a histogram of num_ncancelled_packages for the entire
28 % # customer base, and compare it to a graph of the overhead for generating this
29 % # information. (and optimize it better, we could get it more from SQL)
30 % if ( $cust_main->num_ncancelled_pkgs < 54 ) {
31 % foreach my $freq_info ($cust_main->display_recurring) {
33 <TH ALIGN="right"><% emt( ucfirst($freq_info->{'freq_pretty'}). ' recurring' ) %></TH>
34 <TD><% $money_char. sprintf('%.2f', $freq_info->{'amount'}) %></TD>
39 % if ( $conf->exists('cust_main-select-prorate_day') ) {
41 <TD ALIGN="right"><% mt('Prorate day of month') |h %></TD>
42 <TD BGCOLOR="#ffffff"><% $cust_main->prorate_day %>
47 % if ( $conf->exists('cust_main-select-billday')
48 % && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) {
50 <TD ALIGN="right"><% mt('Billing day of month') |h %></TD>
51 <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
57 <TD ALIGN="right"><% mt('Billing type') |h %></TD>
58 <TD BGCOLOR="#ffffff">
59 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) {
61 % my $autodemand = $cust_main->payby eq 'CARD' ? 'automatic' : 'on-demand';
62 <% mt("Credit card ([_1])",$autodemand) |h %>
66 <TD ALIGN="right"><% mt('Card number') |h %></TD>
67 <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
70 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
72 %my $date = $cust_main->paydate || '12-2037';
73 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
74 % ( $mon, $year ) = ( $2, $1 );
75 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
76 % ( $mon, $year ) = ( $1, $3 );
78 % warn "unrecognized expiration date format: $date";
79 % ( $mon, $year ) = ( '', '' );
84 <TD ALIGN="right"><% mt('Expiration') |h %></TD>
85 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
87 % if ( $cust_main->paystart_month ) {
90 <TD ALIGN="right"><% mt('Start date') |h %></TD>
91 <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
93 % } elsif ( $cust_main->payissue ) {
96 <TD ALIGN="right"><% mt('Issue #') |h %></TD>
97 <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
103 <TD ALIGN="right"><% mt('Name on card') |h %></TD>
104 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
106 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
107 % my( $account, $aba ) = split('@', $cust_main->paymask );
109 % ($branch,$aba) = split('\.',$aba) if $conf->config('echeck-country') eq 'CA';
112 % my $autodemand = $cust_main->payby eq 'CHEK' ? 'automatic' : 'on-demand';
113 <% mt("Electronic check ([_1])",$autodemand) |h %>
117 % #false laziness w/edit/cust_main/billing.html and misc/payment.cgi
118 % my $routing_label = $conf->config('echeck-country') eq 'US'
119 % ? 'ABA/Routing number'
120 % : 'Routing number';
123 <TD ALIGN="right"><% mt($routing_label) |h %></TD>
124 <TD BGCOLOR="#ffffff"><% $aba %></TD>
127 % if ( $conf->config('echeck-country') eq 'CA' ) {
129 <TD ALIGN="right"><% mt('Branch number') |h %></TD>
130 <TD BGCOLOR="#ffffff"><% $branch %></TD>
134 <TD ALIGN="right"><% mt('Account number') |h %></TD>
135 <TD BGCOLOR="#ffffff"><% $account %></TD>
138 <TD ALIGN="right"><% mt('Account type') |h %></TD>
139 <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
142 <TD ALIGN="right"><% mt('Bank name') |h %></TD>
143 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
145 % if ( $conf->exists('show_bankstate') ) {
147 <TD ALIGN="right"><% $paystate_label %></TD>
148 <TD BGCOLOR="#ffffff"><% $cust_main->paystate || ' ' %></TD>
151 % } elsif ( $cust_main->payby eq 'LECB' ) {
152 % $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
153 % my $payinfo = "$1-$2-$3";
155 <% mt('Phone bill billing') |h %>
159 <TD ALIGN="right"><% mt('Phone number') |h %></TD>
160 <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
162 % } elsif ( $cust_main->payby eq 'BILL' ) {
164 <% mt('Billing') |h %>
167 % if ( $cust_main->payinfo ) {
170 <TD ALIGN="right"><% mt('P.O.') |h %></TD>
171 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
177 <TD ALIGN="right"><% mt('Attention') |h %></TD>
178 <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
180 % } elsif ( $cust_main->payby eq 'COMP' ) {
182 <% mt('Complimentary') |h %>
186 <TD ALIGN="right"><% mt('Authorized by') |h %></TD>
187 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
190 %#false laziness w/above etc.
192 %my $date = $cust_main->paydate || '12-2037';
193 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
194 % ( $mon, $year ) = ( $2, $1 );
195 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
196 % ( $mon, $year ) = ( $1, $3 );
198 % warn "unrecognized expiration date format: $date";
199 % ( $mon, $year ) = ( '', '' );
204 <TD ALIGN="right"><% mt('Expiration') |h %></TD>
205 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
209 % my $yes = emt('yes');
210 % my $no = emt('no');
212 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
214 % unless ( $conf->exists('cust_class-tax_exempt')
215 % || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
219 <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
220 <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
224 % foreach my $exempt_group ( @exempt_groups ) {
225 % my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
227 <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
228 <TD BGCOLOR="#ffffff"><% $cust_main_exemption ? $yes : $no %>
229 <% $cust_main_exemption ? $cust_main_exemption->exempt_number : '' |h %>
234 % if ( $conf->exists('enable_taxproducts') ) {
236 <TD ALIGN="right"><% mt('Tax location') |h %></TD>
237 % my $tax_location = $conf->exists('tax-ship_address')
238 % ? $cust_main->ship_location
239 % : $cust_main->bill_location;
240 <TD BGCOLOR="#ffffff"><% $tax_location->geocode('cch') %></TD>
244 <TD ALIGN="right"><% mt('Postal mail invoices') |h %></TD>
245 <TD BGCOLOR="#ffffff">
246 <% ( grep { $_ eq 'POST' } @invoicing_list ) ? $yes : $no %>
250 <TD ALIGN="right"><% mt('Fax invoices') |h %></TD>
251 <TD BGCOLOR="#ffffff">
252 <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? $yes : $no %>
256 <TD ALIGN="right"><% mt('Email invoices') |h %></TD>
257 <TD BGCOLOR="#ffffff">
258 <% $cust_main->invoice_noemail ? $no : $yes %>
261 % unless ( $conf->exists('cust-email-high-visibility')) {
263 <TD ALIGN="right"><% mt('Email address(es)') |h %></TD>
264 <TD BGCOLOR="#ffffff">
265 <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
266 % if ( $cust_main->message_noemail ) {
268 <SPAN STYLE="font-size: small"><% emt('(do not send notices)') %></SPAN>
274 <TD ALIGN="right"><% mt('Invoice terms') |h %></TD>
275 <TD BGCOLOR="#ffffff">
276 <% $cust_main->invoice_terms
277 || emt('Default').' ('. ( $conf->config('invoice_default_terms', $cust_main->agentnum)
278 || emt('Payable upon receipt')
285 <TD ALIGN="right"><% mt('Credit limit') |h %></TD>
286 <TD BGCOLOR="#ffffff">
287 % my $default_credit_limit = $conf->config('default_credit_limit');
288 <% length($cust_main->credit_limit)
289 ? $money_char. sprintf("%.2f", $cust_main->credit_limit)
290 : $default_credit_limit
291 ? "Default ($money_char". sprintf("%.2f", $default_credit_limit). ")"
294 % if ( $cust_main->num_cust_main_credit_limit ) {
295 <A HREF="<% $p %>search/cust_main_credit_limit.html?custnum=<% $cust_main->custnum %>">(incidents)</A>
300 % if ( $conf->exists('voip-cust_cdr_spools') ) {
302 <TD ALIGN="right"><% mt('Spool CDRs') |h %></TD>
303 <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? $yes : $no %></TD>
307 % if ( $conf->exists('voip-cust_cdr_squelch') ) {
309 <TD ALIGN="right"><% mt($conf->exists('voip-cdr_email') ? 'Print CDRs' : 'Show CDRs') |h %></TD>
310 <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? $no : $yes %></TD>
314 % if ( $conf->exists('voip-cust_accountcode_cdr') ) {
316 <TD ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TD>
317 <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
321 % if ( my $attach = $conf->config('voip-cdr_email_attach') ) {
323 <TD ALIGN="right"><% mt('Email CDRs as '.uc($attach)) |h %></TD>
324 <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
328 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
330 <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
331 <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
335 % if ( $cust_main->locale ) {
336 % my %locale_info = FS::Locales->locale_info($cust_main->locale);
338 <TD ALIGN="right"><% mt('Invoicing locale') |h %></TD>
339 <TD BGCOLOR="#ffffff"><% $locale_info{name} . " (" . $locale_info{country} .")" %></TD>
347 my $paystate_label = FS::Msgcat::_gettext('paystate');
348 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
353 my( $cust_main ) = @_;
354 my @invoicing_list = $cust_main->invoicing_list;
355 my $conf = new FS::Conf;
356 my $money_char = $conf->config('money_char') || '$';
358 #false laziness w/edit/cust_main/billing.html
359 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
360 my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
361 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
362 my $show_term = $term_sth->fetchrow_arrayref->[0];