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 % if ( $conf->exists('cust_main-select-prorate_day') ) {
28 <TD ALIGN="right"><% mt('Prorate day of month') |h %></TD>
29 <TD BGCOLOR="#ffffff"><% $cust_main->prorate_day %>
34 % if ( $conf->exists('cust_main-select-billday')
35 % && ($cust_main->payby eq 'CARD' || $cust_main->payby eq 'CHEK') ) {
37 <TD ALIGN="right"><% mt('Billing day of month') |h %></TD>
38 <TD BGCOLOR="#ffffff"><% $cust_main->billday %>
44 <TD ALIGN="right"><% mt('Billing type') |h %></TD>
45 <TD BGCOLOR="#ffffff">
46 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) {
48 % my $autodemand = $cust_main->payby eq 'CARD' ? 'automatic' : 'on-demand';
49 <% mt("Credit card ([_1])",$autodemand) |h %>
53 <TD ALIGN="right"><% mt('Card number') |h %></TD>
54 <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
57 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
59 %my $date = $cust_main->paydate || '12-2037';
60 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
61 % ( $mon, $year ) = ( $2, $1 );
62 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
63 % ( $mon, $year ) = ( $1, $3 );
65 % warn "unrecognized expiration date format: $date";
66 % ( $mon, $year ) = ( '', '' );
71 <TD ALIGN="right"><% mt('Expiration') |h %></TD>
72 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
74 % if ( $cust_main->paystart_month ) {
77 <TD ALIGN="right"><% mt('Start date') |h %></TD>
78 <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
80 % } elsif ( $cust_main->payissue ) {
83 <TD ALIGN="right"><% mt('Issue #') |h %></TD>
84 <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
90 <TD ALIGN="right"><% mt('Name on card') |h %></TD>
91 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
93 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
94 % my( $account, $aba ) = split('@', $cust_main->paymask );
96 % ($branch,$aba) = split('\.',$aba) if $conf->config('echeck-country') eq 'CA';
99 % my $autodemand = $cust_main->payby eq 'CHEK' ? 'automatic' : 'on-demand';
100 <% mt("Electronic check ([_1])",$autodemand) |h %>
104 % #false laziness w/edit/cust_main/billing.html and misc/payment.cgi
105 % my $routing_label = $conf->config('echeck-country') eq 'US'
106 % ? 'ABA/Routing number'
107 % : 'Routing number';
110 <TD ALIGN="right"><% mt($routing_label) |h %></TD>
111 <TD BGCOLOR="#ffffff"><% $aba %></TD>
114 % if ( $conf->config('echeck-country') eq 'CA' ) {
116 <TD ALIGN="right"><% mt('Branch number') |h %></TD>
117 <TD BGCOLOR="#ffffff"><% $branch %></TD>
121 <TD ALIGN="right"><% mt('Account number') |h %></TD>
122 <TD BGCOLOR="#ffffff"><% $account %></TD>
125 <TD ALIGN="right"><% mt('Account type') |h %></TD>
126 <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
129 <TD ALIGN="right"><% mt('Bank name') |h %></TD>
130 <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
132 % if ( $conf->exists('show_bankstate') ) {
134 <TD ALIGN="right"><% $paystate_label %></TD>
135 <TD BGCOLOR="#ffffff"><% $cust_main->paystate || ' ' %></TD>
138 % } elsif ( $cust_main->payby eq 'LECB' ) {
139 % $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
140 % my $payinfo = "$1-$2-$3";
142 <% mt('Phone bill billing') |h %>
146 <TD ALIGN="right"><% mt('Phone number') |h %></TD>
147 <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
149 % } elsif ( $cust_main->payby eq 'BILL' ) {
151 <% mt('Billing') |h %>
154 % if ( $cust_main->payinfo ) {
157 <TD ALIGN="right"><% mt('P.O.') |h %></TD>
158 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
164 <TD ALIGN="right"><% mt('Attention') |h %></TD>
165 <TD BGCOLOR="#ffffff"><% $cust_main->payname |h %></TD>
167 % } elsif ( $cust_main->payby eq 'COMP' ) {
169 <% mt('Complimentary') |h %>
173 <TD ALIGN="right"><% mt('Authorized by') |h %></TD>
174 <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
177 %#false laziness w/above etc.
179 %my $date = $cust_main->paydate || '12-2037';
180 %if ( $date =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
181 % ( $mon, $year ) = ( $2, $1 );
182 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
183 % ( $mon, $year ) = ( $1, $3 );
185 % warn "unrecognized expiration date format: $date";
186 % ( $mon, $year ) = ( '', '' );
191 <TD ALIGN="right"><% mt('Expiration') |h %></TD>
192 <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
196 % my $yes = emt('yes');
197 % my $no = emt('no');
199 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
201 % unless ( $conf->exists('cust_class-tax_exempt')
202 % || $conf->exists('tax-cust_exempt-groups-require_individual_nums')
206 <TD ALIGN="right"><% mt('Tax exempt') |h %><% @exempt_groups ? ' ('.emt('all taxes').')' : '' %></TD>
207 <TD BGCOLOR="#ffffff"><% $cust_main->tax ? $yes : $no %></TD>
211 % foreach my $exempt_group ( @exempt_groups ) {
212 % my $cust_main_exemption = $cust_main->tax_exemption($exempt_group);
214 <TD ALIGN="right"><% mt('Tax exempt') |h %> (<% $exempt_group %> taxes)</TD>
215 <TD BGCOLOR="#ffffff"><% $cust_main_exemption ? $yes : $no %>
216 <% $cust_main_exemption ? $cust_main_exemption->exempt_number : '' |h %>
221 % if ( $conf->exists('enable_taxproducts') ) {
223 <TD ALIGN="right"><% mt('Tax location') |h %></TD>
224 % my $tax_location = $conf->exists('tax-ship_address')
225 % ? $cust_main->ship_location
226 % : $cust_main->bill_location;
227 <TD BGCOLOR="#ffffff"><% $tax_location->geocode('cch') %></TD>
231 <TD ALIGN="right"><% mt('Postal mail invoices') |h %></TD>
232 <TD BGCOLOR="#ffffff">
233 <% ( grep { $_ eq 'POST' } @invoicing_list ) ? $yes : $no %>
237 <TD ALIGN="right"><% mt('Fax invoices') |h %></TD>
238 <TD BGCOLOR="#ffffff">
239 <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? $yes : $no %>
243 <TD ALIGN="right"><% mt('Email invoices') |h %></TD>
244 <TD BGCOLOR="#ffffff">
245 <% $cust_main->invoice_noemail ? $no : $yes %>
248 % unless ( $conf->exists('cust-email-high-visibility')) {
250 <TD ALIGN="right"><% mt('Email address(es)') |h %></TD>
251 <TD BGCOLOR="#ffffff">
252 <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || $no %>
253 % if ( $cust_main->message_noemail ) {
255 <SPAN STYLE="font-size: small"><% emt('(do not send notices)') %></SPAN>
261 <TD ALIGN="right"><% mt('Invoice terms') |h %></TD>
262 <TD BGCOLOR="#ffffff">
263 <% $cust_main->invoice_terms
264 || emt('Default').' ('. ( $conf->config('invoice_default_terms', $cust_main->agentnum)
265 || emt('Payable upon receipt')
272 <TD ALIGN="right"><% mt('Credit limit') |h %></TD>
273 <TD BGCOLOR="#ffffff">
274 % my $default_credit_limit = $conf->config('default_credit_limit');
275 <% length($cust_main->credit_limit)
276 ? $money_char. sprintf("%.2f", $cust_main->credit_limit)
277 : $default_credit_limit
278 ? "Default ($money_char". sprintf("%.2f", $default_credit_limit). ")"
281 % if ( $cust_main->num_cust_main_credit_limit ) {
282 <A HREF="<% $p %>search/cust_main_credit_limit.html?custnum=<% $cust_main->custnum %>">(incidents)</A>
287 % if ( $conf->exists('voip-cust_cdr_spools') ) {
289 <TD ALIGN="right"><% mt('Spool CDRs') |h %></TD>
290 <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? $yes : $no %></TD>
294 % if ( $conf->exists('voip-cust_cdr_squelch') ) {
296 <TD ALIGN="right"><% mt($conf->exists('voip-cdr_email') ? 'Print CDRs' : 'Show CDRs') |h %></TD>
297 <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? $no : $yes %></TD>
301 % if ( $conf->exists('voip-cust_accountcode_cdr') ) {
303 <TD ALIGN="right"><% mt('Breakdown CDRs by accountcode') |h %></TD>
304 <TD BGCOLOR="#ffffff"><% $cust_main->accountcode_cdr ? $yes : $no %></TD>
308 % if ( $conf->exists('voip-cust_email_csv_cdr') ) {
310 <TD ALIGN="right"><% mt('Email CDRs as CSV') |h %></TD>
311 <TD BGCOLOR="#ffffff"><% $cust_main->email_csv_cdr ? $yes : $no %></TD>
315 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
317 <TD ALIGN="right"><% mt('CDR termination settlement') |h %></TD>
318 <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
322 % if ( $cust_main->currency ) {
324 <TD ALIGN="right"><% mt('Invoicing currency') |h %></TD>
325 <TD BGCOLOR="#ffffff"><% $cust_main->currency. ': '. code2currency($cust_main->currency) %></TD>
329 % if ( $cust_main->locale ) {
330 % my %locale_info = FS::Locales->locale_info($cust_main->locale);
332 <TD ALIGN="right"><% mt('Invoicing locale') |h %></TD>
333 <TD BGCOLOR="#ffffff"><% $locale_info{name} . " (" . $locale_info{country} .")" %></TD>
341 my $paystate_label = FS::Msgcat::_gettext('paystate');
342 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
347 my( $cust_main ) = @_;
348 my @invoicing_list = $cust_main->invoicing_list;
349 my $conf = new FS::Conf;
350 my $money_char = $conf->config('money_char') || '$';
352 #false laziness w/edit/cust_main/billing.html
353 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
354 my $term_sth = dbh->prepare($term_sql) or die dbh->errstr;
355 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
356 my $show_term = $term_sth->fetchrow_arrayref->[0];