start of settlement CDR processing, RT#5495
[freeside.git] / httemplate / view / cust_main / billing.html
1 Billing information
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
4 %# machine, anyway)
5 %if (  $FS::CurrentUser::CurrentUser->access_right('Bill customer now')
6 %      && ! $cust_main->is_encrypted($cust_main->payinfo)
7 %   ) { 
8   (<A HREF="<% $p %>misc/bill.cgi?<% $cust_main->custnum %>">Bill now</A>)
9 % } 
10
11 <% ntable("#cccccc") %><TR><TD><% ntable("#cccccc",2) %>
12
13 %( my $balance = $cust_main->balance )
14 %  =~ s/^(\-?)(.*)$/<FONT SIZE=+1>$1<\/FONT>$money_char$2/;
15
16 <TR>
17   <TD ALIGN="right">Balance due</TD>
18   <TD BGCOLOR="#ffffff"><B><% $balance %></B></TD>
19 </TR>
20
21 <TR>
22   <TD ALIGN="right">Billing&nbsp;type</TD>
23   <TD BGCOLOR="#ffffff">
24 % if ( $cust_main->payby eq 'CARD' || $cust_main->payby eq 'DCRD' ) { 
25
26
27     Credit&nbsp;card&nbsp;<% $cust_main->payby eq 'CARD' ? '(automatic)' : '(on-demand)' %>
28   </TD>
29 </TR>
30 <TR>
31   <TD ALIGN="right">Card number</TD>
32   <TD BGCOLOR="#ffffff"><% $cust_main->paymask %></TD>
33 </TR>
34 %
35 %#false laziness w/elements/select-month_year.html & edit/cust_main/billing.html
36 %my( $mon, $year );
37 %my $date = $cust_main->paydate || '12-2037';
38 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
39 %  ( $mon, $year ) = ( $2, $1 );
40 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
41 %  ( $mon, $year ) = ( $1, $3 );
42 %} else {
43 %  warn "unrecognized expiration date format: $date";
44 %  ( $mon, $year ) = ( '', '' );
45 %}
46 %
47
48 <TR>
49   <TD ALIGN="right">Expiration</TD>
50   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
51 </TR>
52 % if ( $cust_main->paystart_month ) { 
53
54   <TR>
55     <TD ALIGN="right">Start date</TD>
56     <TD BGCOLOR="#ffffff"><% $cust_main->paystart_month. '/'. $cust_main->paystart_year %>
57   </TR>
58 % } elsif ( $cust_main->payissue ) { 
59
60   <TR>
61     <TD ALIGN="right">Issue #</TD>
62     <TD BGCOLOR="#ffffff"><% $cust_main->payissue %>
63   </TR>
64 % } 
65
66
67 <TR>
68   <TD ALIGN="right">Name on card</TD>
69   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
70 </TR>
71 % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') {
72 %     my( $account, $aba ) = split('@', $cust_main->paymask );
73
74
75     Electronic&nbsp;check&nbsp;<% $cust_main->payby eq 'CHEK' ? '(automatic)' : '(on-demand)' %>
76   </TD>
77 </TR>
78 <TR>
79   <TD ALIGN="right">ABA/Routing code</TD>
80   <TD BGCOLOR="#ffffff"><% $aba %></TD>
81 </TR>
82 <TR>
83   <TD ALIGN="right">Account number</TD>
84   <TD BGCOLOR="#ffffff"><% $account %></TD>
85 </TR>
86 <TR>
87   <TD ALIGN="right">Account type</TD>
88   <TD BGCOLOR="#ffffff"><% $cust_main->paytype %></TD>
89 </TR>
90 <TR>
91   <TD ALIGN="right">Bank name</TD>
92   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
93 </TR>
94 % if ( $conf->exists('show_bankstate') ) {
95 <TR>
96   <TD ALIGN="right"><% $paystate_label %></TD>
97   <TD BGCOLOR="#ffffff"><% $cust_main->paystate || '&nbsp;&nbsp;&nbsp;' %></TD>
98 </TR>
99 % }
100 % } elsif ( $cust_main->payby eq 'LECB' ) {
101 %     $cust_main->payinfo =~ /^(\d{3})(\d{3})(\d{4})$/;
102 %     my $payinfo = "$1-$2-$3";
103 %
104
105
106     Phone&nbsp;bill&nbsp;billing
107   </TD>
108 </TR>
109 <TR>
110   <TD ALIGN="right">Phone number</TD>
111   <TD BGCOLOR="#ffffff"><% $payinfo %></TD>
112 </TR>
113 % } elsif ( $cust_main->payby eq 'BILL' ) { 
114
115
116     Billing
117   </TD>
118 </TR>
119 % if ( $cust_main->payinfo ) { 
120
121 <TR>
122   <TD ALIGN="right">P.O. </TD>
123   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
124 </TR>
125 % } 
126
127
128 <TR>
129   <TD ALIGN="right">Attention</TD>
130   <TD BGCOLOR="#ffffff"><% $cust_main->payname %></TD>
131 </TR>
132 % } elsif ( $cust_main->payby eq 'COMP' ) { 
133
134
135     Complimentary
136   </TD>
137 </TR>
138 <TR>
139   <TD ALIGN="right">Authorized&nbsp;by</TD>
140   <TD BGCOLOR="#ffffff"><% $cust_main->payinfo %></TD>
141 </TR>
142 %
143 %#false laziness w/above etc.
144 %my( $mon, $year );
145 %my $date = $cust_main->paydate || '12-2037';
146 %if ( $date  =~ /^(\d{4})-(\d{1,2})-\d{1,2}$/ ) { #PostgreSQL date format
147 %  ( $mon, $year ) = ( $2, $1 );
148 %} elsif ( $date =~ /^(\d{1,2})-(\d{1,2}-)?(\d{4}$)/ ) {
149 %  ( $mon, $year ) = ( $1, $3 );
150 %} else {
151 %  warn "unrecognized expiration date format: $date";
152 %  ( $mon, $year ) = ( '', '' );
153 %}
154 %
155
156 <TR>
157   <TD ALIGN="right">Expiration</TD>
158   <TD BGCOLOR="#ffffff"><% "$mon/$year" %></TD>
159 </TR>
160 % } 
161
162 % my @exempt_groups = grep /\S/, $conf->config('tax-cust_exempt-groups');
163 <TR>
164   <TD ALIGN="right">Tax&nbsp;exempt<% @exempt_groups ? ' (all taxes)' : '' %></TD>
165   <TD BGCOLOR="#ffffff"><% $cust_main->tax ? 'yes' : 'no' %></TD>
166 </TR>
167 % foreach my $exempt_group ( @exempt_groups ) {
168 <TR>
169   <TD ALIGN="right">Tax&nbsp;exempt (<% $exempt_group %> taxes)</TD>
170   <TD BGCOLOR="#ffffff"><% $cust_main->tax_exemption($exempt_group) ? 'yes' : 'no' %></TD>
171 </TR>
172 % }
173
174 % if ( $conf->exists('enable_taxproducts') ) {
175 <TR>
176   <TD ALIGN="right">Tax&nbsp;location</TD>
177   <TD BGCOLOR="#ffffff"><% $cust_main->geocode('cch') %></TD>
178 </TR>
179 % }
180 <TR>
181   <TD ALIGN="right">Postal&nbsp;invoices</TD>
182   <TD BGCOLOR="#ffffff">
183     <% ( grep { $_ eq 'POST' } @invoicing_list ) ? 'yes' : 'no' %>
184   </TD>
185 </TR>
186 <TR>
187   <TD ALIGN="right">FAX&nbsp;invoices</TD>
188   <TD BGCOLOR="#ffffff">
189     <% ( grep { $_ eq 'FAX' } @invoicing_list ) ? 'yes' : 'no' %>
190   </TD>
191 </TR>
192 <TR>
193   <TD ALIGN="right">Email&nbsp;invoices</TD>
194   <TD BGCOLOR="#ffffff">
195     <% join(', ', grep { $_ !~ /^(POST|FAX)$/ } @invoicing_list ) || 'no' %>
196   </TD>
197 </TR>
198 <TR>
199   <TD ALIGN="right">Invoice&nbsp;terms</TD>
200   <TD BGCOLOR="#ffffff">
201     <% $cust_main->invoice_terms || 'Default ('. ( $conf->config('invoice_default_terms') || 'Payable upon receipt' ). ')' %>
202   </TD>
203 </TR>
204
205 % if ( $conf->exists('voip-cust_cdr_spools') ) { 
206   <TR>
207     <TD ALIGN="right">Spool&nbsp;CDRs</TD>
208     <TD BGCOLOR="#ffffff"><% $cust_main->spool_cdr ? 'yes' : 'no' %></TD>
209   </TR>
210 % } 
211
212 % if ( $conf->exists('voip-cust_cdr_squelch') ) { 
213   <TR>
214     <TD ALIGN="right">Print&nbsp;CDRs</TD>
215     <TD BGCOLOR="#ffffff"><% $cust_main->squelch_cdr ? 'no' : 'yes' %></TD>
216   </TR>
217 % } 
218
219 % if ( $show_term || $cust_main->cdr_termination_percentage ) {
220   <TR>
221     <TD ALIGN="right">CDR termination settlement</TD>
222     <TD BGCOLOR="#ffffff"><% $cust_main->cdr_termination_percentage %><% $cust_main->cdr_termination_percentage =~ /\d/ ? '%' : '' %></TD>
223   </TR>
224 % }
225
226 </TABLE></TD></TR></TABLE>
227 <%once>
228
229 my $paystate_label = FS::Msgcat::_gettext('paystate');
230 $paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
231
232 </%once>
233 <%init>
234
235 my( $cust_main ) = @_;
236 my @invoicing_list = $cust_main->invoicing_list;
237 my $conf = new FS::Conf;
238 my $money_char = $conf->config('money_char') || '$';
239
240 #false laziness w/edit/cust_main/billing.html
241 my $term_sql = "SELECT COUNT(*) FROM cust_pkg LEFT JOIN part_pkg USING ( pkgpart ) WHERE custnum = ? AND plan = 'cdr_termination' LIMIT 1";
242 my $term_sth = dbh->prepare($term_sql)  or die dbh->errstr;
243 $term_sth->execute($cust_main->custnum) or die $term_sth->errstr;
244 my $show_term = $term_sth->fetchrow_arrayref->[0];
245
246 </%init>