ticket 1443 add account type and bank state for echeck processing
authorjeff <jeff>
Fri, 6 Apr 2007 19:38:09 +0000 (19:38 +0000)
committerjeff <jeff>
Fri, 6 Apr 2007 19:38:09 +0000 (19:38 +0000)
FS/FS/Schema.pm
FS/FS/cust_main.pm
httemplate/edit/cust_main.cgi
httemplate/edit/cust_main/billing.html
httemplate/edit/cust_main/select-state.html

index 2c26ba2..591793b 100644 (file)
@@ -447,6 +447,8 @@ sub tables_hashref {
         'paystart_year',  'int', 'NULL', '', '', '', 
         'payissue', 'varchar', 'NULL', 2, '', '', 
         'payname',  'varchar', 'NULL', $char_d, '', '', 
         'paystart_year',  'int', 'NULL', '', '', '', 
         'payissue', 'varchar', 'NULL', 2, '', '', 
         'payname',  'varchar', 'NULL', $char_d, '', '', 
+        'paystate', 'varchar', 'NULL', $char_d, '', '', 
+        'paytype',  'varchar', 'NULL', $char_d, '', '', 
         'payip',    'varchar', 'NULL', 15, '', '', 
         'tax',      'char', 'NULL', 1, '', '', 
         'otaker',   'varchar', '',    32, '', '', 
         'payip',    'varchar', 'NULL', 15, '', '', 
         'tax',      'char', 'NULL', 1, '', '', 
         'otaker',   'varchar', '',    32, '', '', 
index f686722..e834d59 100644 (file)
@@ -2,7 +2,7 @@ package FS::cust_main;
 
 use strict;
 use vars qw( @ISA @EXPORT_OK $DEBUG $me $conf @encrypted_fields
 
 use strict;
 use vars qw( @ISA @EXPORT_OK $DEBUG $me $conf @encrypted_fields
-             $import $skip_fuzzyfiles $ignore_expired_card );
+             $import $skip_fuzzyfiles $ignore_expired_card @paytypes);
 use vars qw( $realtime_bop_decline_quiet ); #ugh
 use Safe;
 use Carp;
 use vars qw( $realtime_bop_decline_quiet ); #ugh
 use Safe;
 use Carp;
@@ -70,6 +70,7 @@ $skip_fuzzyfiles = 0;
 $ignore_expired_card = 0;
 
 @encrypted_fields = ('payinfo', 'paycvv');
 $ignore_expired_card = 0;
 
 @encrypted_fields = ('payinfo', 'paycvv');
+@paytypes = ('Personal checking', 'Personal savings', 'Business checking', 'Business savings');
 
 #ask FS::UID to run this stuff for us later
 #$FS::UID::callback{'FS::cust_main'} = sub { 
 
 #ask FS::UID to run this stuff for us later
 #$FS::UID::callback{'FS::cust_main'} = sub { 
@@ -1336,6 +1337,7 @@ sub check {
   $error =    $self->ut_numbern('paystart_month')
            || $self->ut_numbern('paystart_year')
            || $self->ut_numbern('payissue')
   $error =    $self->ut_numbern('paystart_month')
            || $self->ut_numbern('paystart_year')
            || $self->ut_numbern('payissue')
+           || $self->ut_textn('paytype')
   ;
   return $error if $error;
 
   ;
   return $error if $error;
 
index 2c3123c..0a7a8c0 100755 (executable)
@@ -17,7 +17,7 @@
 %my $error = '';
 %my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart, $saved_domsvc);
 %my(@invoicing_list);
 %my $error = '';
 %my($custnum, $username, $password, $popnum, $cust_main, $saved_pkgpart, $saved_domsvc);
 %my(@invoicing_list);
-%my $payinfo;
+%my ($ss,$stateid,$payinfo);
 %my $same = '';
 %if ( $cgi->param('error') ) {
 %  $error = $cgi->param('error');
 %my $same = '';
 %if ( $cgi->param('error') ) {
 %  $error = $cgi->param('error');
@@ -43,6 +43,8 @@
 %  @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
 %  $same = $cgi->param('same');
 %  $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid');
 %  @invoicing_list = split( /\s*,\s*/, $cgi->param('invoicing_list') );
 %  $same = $cgi->param('same');
 %  $cust_main->setfield('paid' => $cgi->param('paid')) if $cgi->param('paid');
+%  $ss = $cust_main->ss;           # don't mask an entered value on errors
+%  $stateid = $cust_main->stateid; # don't mask an entered value on errors
 %  $payinfo = $cust_main->payinfo; # don't mask an entered value on errors
 %} elsif ( $cgi->keywords ) { #editing
 %  my( $query ) = $cgi->keywords;
 %  $payinfo = $cust_main->payinfo; # don't mask an entered value on errors
 %} elsif ( $cgi->keywords ) { #editing
 %  my( $query ) = $cgi->keywords;
@@ -61,6 +63,8 @@
 %  $password = '';
 %  $popnum = 0;
 %  @invoicing_list = $cust_main->invoicing_list;
 %  $password = '';
 %  $popnum = 0;
 %  @invoicing_list = $cust_main->invoicing_list;
+%  $ss = $cust_main->masked('ss');
+%  $stateid = $cust_main->masked('stateid');
 %  $payinfo = $cust_main->paymask;
 %} else {
 %  $custnum='';
 %  $payinfo = $cust_main->paymask;
 %} else {
 %  $custnum='';
@@ -75,6 +79,8 @@
 %  @invoicing_list = ();
 %  push @invoicing_list, 'POST'
 %    unless $conf->exists('disablepostalinvoicedefault');
 %  @invoicing_list = ();
 %  push @invoicing_list, 'POST'
 %    unless $conf->exists('disablepostalinvoicedefault');
+%  $ss = '';
+%  $stateid = '';
 %  $payinfo = '';
 %}
 %$cgi->delete_all();
 %  $payinfo = '';
 %}
 %$cgi->delete_all();
 
 <BR><BR>
 Billing address
 
 <BR><BR>
 Billing address
-<% include('cust_main/contact.html', $cust_main, '', 'bill_changed(this)', '' ) %>
+<% include('cust_main/contact.html', $cust_main, '', 'bill_changed(this)', '', 'ss' => $ss, 'stateid' => $stateid ) %>
 
 <!-- service address -->
 % if ( defined $cust_main->dbdef_table->column('ship_last') ) { 
 
 <!-- service address -->
 % if ( defined $cust_main->dbdef_table->column('ship_last') ) { 
@@ -290,6 +296,7 @@ function bottomfixup(what) {
     'address1', 'address2', 'city',
     'county', 'state', 'zip', 'country',
     'daytime', 'night', 'fax',
     'address1', 'address2', 'city',
     'county', 'state', 'zip', 'country',
     'daytime', 'night', 'fax',
+    'stateid', 'stateid_state',
 
     'same',
 
 
     'same',
 
@@ -303,8 +310,8 @@ function bottomfixup(what) {
 
   var layervars = new Array(
     'payauto',
 
   var layervars = new Array(
     'payauto',
-    'payinfo', 'payinfo1', 'payinfo2',
-    'payname', 'exp_month', 'exp_year', 'paycvv',
+    'payinfo', 'payinfo1', 'payinfo2', 'paytype',
+    'payname', 'paystate', 'exp_month', 'exp_year', 'paycvv',
     'paystart_month', 'paystart_year', 'payissue',
     'payip',
     'paid'
     'paystart_month', 'paystart_year', 'payissue',
     'payip',
     'paid'
@@ -374,6 +381,7 @@ function copyelement(from, to) {
 %     'address1', 'address2', 'city',
 %     'county', 'state', 'zip', 'country',
 %     'daytime', 'night', 'fax',
 %     'address1', 'address2', 'city',
 %     'county', 'state', 'zip', 'country',
 %     'daytime', 'night', 'fax',
+%     'stateid', 'stateid_state',
 %     
 %     'same',
 %     
 %     
 %     'same',
 %     
@@ -385,8 +393,8 @@ function copyelement(from, to) {
 %     'select', #XXX key
 %
 %     'payauto',
 %     'select', #XXX key
 %
 %     'payauto',
-%     'payinfo', 'payinfo1', 'payinfo2',
-%     'payname', 'exp_month', 'exp_year', 'paycvv',
+%     'payinfo', 'payinfo1', 'payinfo2', 'paytype',
+%     'payname', 'paystate', 'exp_month', 'exp_year', 'paycvv',
 %     'paystart_month', 'paystart_year', 'payissue',
 %     'payip',
 %     'paid',
 %     'paystart_month', 'paystart_year', 'payissue',
 %     'payip',
 %     'paid',
index 65b4400..1440db4 100644 (file)
@@ -10,7 +10,7 @@
 
     <INPUT TYPE="hidden" NAME="payinfo" VALUE="<% $cust_main->paymask %>">
 
 
     <INPUT TYPE="hidden" NAME="payinfo" VALUE="<% $cust_main->paymask %>">
 
-% foreach my $field (qw( payname paycvv paystart_month paystart_year payissue payip )) { 
+% foreach my $field (qw( payname paycvv paystart_month paystart_year payissue payip paytype paystate )) { 
 
     <INPUT TYPE="hidden" NAME="<% $field %>" VALUE="<% $cust_main->getfield($field) %>">
 
 
     <INPUT TYPE="hidden" NAME="<% $field %>" VALUE="<% $cust_main->getfield($field) %>">
 
   </SCRIPT>
 
 %  my $payby = $cust_main->payby;
   </SCRIPT>
 
 %  my $payby = $cust_main->payby;
+%  my $paytype = $cust_main->paytype;
 %  my( $account, $aba ) = split('@', $payinfo);
 %
 %  my $disabled = 'DISABLED style="background-color: #dddddd"';
 %  my( $account, $aba ) = split('@', $payinfo);
 %
 %  my $disabled = 'DISABLED style="background-color: #dddddd"';
 %      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
 %
 %        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Account number </TD>!.
 %      '<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0 HEIGHT=192>'.
 %
 %        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Account number </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" SIZE=12 NAME="payinfo1" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $account : '' ). '"></TD></TR>'.
+%          qq!<TD><INPUT TYPE="text" SIZE=12 NAME="payinfo1" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $account : '' ). '"></TD>'.
+%          qq!<TD ALIGN="right">Type</TD><TD><SELECT="text" NAME="paytype">!.
+%            join('', map { qq!<OPTION VALUE="$_" !.($paytype eq $_ ? 'SELECTED' : '').">$_</OPTION>" } @FS::cust_main::paytypes).
+%          qq!</SELECT></TD></TR>!.
 %
 %        qq!<TR><TD ALIGN="right" WIDTH="200">${r}ABA/Routing number </TD>!.
 %
 %        qq!<TR><TD ALIGN="right" WIDTH="200">${r}ABA/Routing number </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $aba : '' ). qq!" SIZE=10 MAXLENGTH=9> !.
+%          qq!<TD COLSPAN="3" WIDTH="408"><INPUT TYPE="text" SIZE=10 MAXLENGTH=9 NAME="payinfo2" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $aba : '' ). qq!" SIZE=10 MAXLENGTH=9> !.
 %          qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!.
 %          qq!</TD></TR>!.
 %
 %          qq!(<A HREF="javascript:void(0);" onClick="overlib( OLiframeContent('../docs/ach.html', 380, 240, 'ach_popup' ), CAPTION, 'ACH Help', STICKY, AUTOSTATUSCAP, CLOSECLICK, DRAGGABLE ); return false;">help</A>)!.
 %          qq!</TD></TR>!.
 %
 %        qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!.
 %
 %        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Bank name </TD>!.
 %        qq!<INPUT TYPE="hidden" NAME="exp_year" VALUE="2037">!.
 %
 %        qq!<TR><TD ALIGN="right" WIDTH="200">${r}Bank name </TD>!.
-%          qq!<TD WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!.
+%          qq!<TD COLSPAN="3" WIDTH="408"><INPUT TYPE="text" NAME="payname" VALUE="!. ( $payby =~ /^(CHEK|DCHK)$/ ? $cust_main->payname : '' ). qq!"></TD></TR>!.
+%          qq!<TR><TD ALIGN="right" WIDTH="200">$paystate_label</TD>!.
+%          qq!<TD COLSPAN="3" WIDTH="408">!.
+%          include('select-state.html',
+%                    'empty'   => '(choose)',
+%                    'state'   => $cust_main->paystate,
+%                    'country' => $cust_main->country,
+%                    'prefix' => 'pay',
+%                 ). "</TD></TR>".
 %
 %
-%        qq!<TR><TD COLSPAN=2 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCHK' ? '' : 'CHECKED' ). '> Charge future payments to this electronic check automatically</TD></TR>'.
+%
+%        qq!<TR><TD COLSPAN=4 WIDTH="608"><INPUT TYPE="checkbox" NAME="payauto" !. ( $payby eq 'DCHK' ? '' : 'CHECKED' ). '> Charge future payments to this electronic check automatically</TD></TR>'.
 %
 %        '<TR><TD>&nbsp;</TD></TR>'.
 %        '<TR><TD>&nbsp;</TD></TR>'.
 %
 %        '<TR><TD>&nbsp;</TD></TR>'.
 %        '<TR><TD>&nbsp;</TD></TR>'.
   <% $r %> required fields
 % } 
 
   <% $r %> required fields
 % } 
 
+<%once>
+
+my $paystate_label = FS::Msgcat::_gettext('paystate');
+$paystate_label = 'Bank state' if $paystate_label =~/^paystate$/;
+
+</%once>
 <%init>
 
 my( $cust_main, %options ) = @_;
 <%init>
 
 my( $cust_main, %options ) = @_;
index 87546e5..4f1c056 100644 (file)
@@ -1,5 +1,9 @@
 <SELECT NAME="<% $opt{'prefix'} %>state" onChange="<% $opt{'prefix'} %>state_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
 
 <SELECT NAME="<% $opt{'prefix'} %>state" onChange="<% $opt{'prefix'} %>state_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
 
+% if ($opt{empty}) {
+  <OPTION VALUE=""<% $opt{state} eq '' ? ' SELECTED' : '' %>><% $opt{empty} %>
+% }
+
 % foreach my $state ( keys %states ) { 
 
   <OPTION VALUE="<% $state %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' %>
 % foreach my $state ( keys %states ) { 
 
   <OPTION VALUE="<% $state %>"<% $state eq $opt{'state'} ? ' SELECTED' : '' %>><% $states{$state} || '(n/a)' %>
@@ -11,7 +15,7 @@
 
 <%init>
 my %opt = @_;
 
 <%init>
 my %opt = @_;
-foreach my $opt (qw( county state country prefix onchange disabled )) {
+foreach my $opt (qw( county state country prefix onchange disabled empty )) {
   $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
 }
 
   $opt{$_} = '' unless exists($opt{$_}) && defined($opt{$_});
 }