additional fields for cash payments, #16821
authorMark Wells <mark@freeside.biz>
Thu, 29 Mar 2012 21:27:55 +0000 (14:27 -0700)
committerMark Wells <mark@freeside.biz>
Thu, 29 Mar 2012 21:32:13 +0000 (14:32 -0700)
FS/FS/Conf.pm
FS/FS/Schema.pm
FS/FS/cust_pay.pm
httemplate/edit/cust_pay.cgi
httemplate/edit/process/cust_pay.cgi
httemplate/view/cust_main/payment_history.html
httemplate/view/cust_pay.html

index ee7f2b4..9c7710b 100644 (file)
@@ -2291,6 +2291,13 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'require_cash_deposit_info',
+    'section'     => 'billing',
+    'description' => 'When recording cash payments, display bank deposit information fields.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'paymentforcedtobatch',
     'section'     => 'deprecated',
     'description' => 'See batch-enable_payby and realtime-disable_payby.  Used to (for CHEK): Cause per customer payment entry to be forced to a batch processor rather than performed realtime.',
index 9b21dfc..5147432 100644 (file)
@@ -1343,12 +1343,17 @@ sub tables_hashref {
                                                  # index into payby table
                                                  # eventually
         'payinfo',  'varchar',   'NULL', 512, '', '', #see cust_main above
-       'paymask', 'varchar', 'NULL', $char_d, '', '', 
+        'paymask', 'varchar', 'NULL', $char_d, '', '', 
         'paydate',  'varchar', 'NULL', 10, '', '', 
         'paybatch', 'varchar',   'NULL', $char_d, '', '', #for auditing purposes.
         'payunique', 'varchar', 'NULL', $char_d, '', '', #separate paybatch "unique" functions from current usage
         'closed',    'char', 'NULL', 1, '', '', 
         'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
+        # cash/check deposit info fields
+        'bank',       'varchar', 'NULL', $char_d, '', '',
+        'depositor',  'varchar', 'NULL', $char_d, '', '',
+        'account',    'varchar', 'NULL', 20,      '', '',
+        'teller',     'varchar', 'NULL', 20,      '', '',
       ],
       'primary_key' => 'paynum',
       #i guess not now, with cust_pay_pending, if we actually make it here, we _do_ want to record it# 'unique' => [ [ 'payunique' ] ],
index d98d11e..ef30809 100644 (file)
@@ -113,6 +113,22 @@ books closed flag, empty or `Y'
 
 Desired pkgnum when using experimental package balances.
 
+=item bank
+
+The bank where the payment was deposited.
+
+=item depositor
+
+The name of the depositor.
+
+=item account
+
+The deposit account number.
+
+=item teller
+
+The teller number.
+
 =back
 
 =head1 METHODS
@@ -493,8 +509,11 @@ sub check {
     || $self->ut_textn('payunique')
     || $self->ut_enum('closed', [ '', 'Y' ])
     || $self->ut_foreign_keyn('pkgnum', 'cust_pkg', 'pkgnum')
+    || $self->ut_textn('bank')
+    || $self->ut_alphan('depositor')
+    || $self->ut_numbern('account')
+    || $self->ut_numbern('teller')
     || $self->payinfo_check()
-    || $self->ut_numbern('discount_term')
   ;
   return $error if $error;
 
@@ -509,6 +528,12 @@ sub check {
   return "invalid discount_term"
    if ($self->discount_term && $self->discount_term < 2);
 
+  if ( $self->payby eq 'CASH' and $conf->exists('require_cash_deposit_info') ) {
+    foreach (qw(bank depositor account teller)) {
+      return "$_ required" if $self->get($_) eq '';
+    }
+  }
+
 #i guess not now, with cust_pay_pending, if we actually make it here, we _do_ want to record it
 #  # UNIQUE index should catch this too, without race conditions, but this
 #  # should give a better error message the other 99.9% of the time...
index 3fd9c79..7a1bb00 100755 (executable)
@@ -18,7 +18,7 @@
 <INPUT TYPE="hidden" NAME="payby" VALUE="<% $payby %>">
 <INPUT TYPE="hidden" NAME="paybatch" VALUE="<% $paybatch %>">
 
-<BR><BR>
+<BR>
 
 <% mt('Payment') |h %> 
 <% ntable("#cccccc", 2) %>
     <TD ALIGN="right"><% mt('Check #') |h %></TD>
     <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
   </TR>
-% } 
+% }
+% elsif ( $payby eq 'CASH' and $conf->exists('require_cash_deposit_info') ) {
+  <TR>
+    <TD ALIGN="right"><% mt('Bank') |h %></TD>
+    <TD COLSPAN=3><INPUT TYPE="text" NAME="bank" VALUE="<% $cgi->param('bank') %>"></TD>
+  </TR>
+  <TR>
+    <TD ALIGN="right"><% mt('Check #') |h %></TD>
+    <TD COLSPAN=2><INPUT TYPE="text" NAME="payinfo" VALUE="<% $payinfo %>" SIZE=10></TD>
+  </TR>
+  <TR>
+    <TD ALIGN="right"><% mt('Teller #') |h %></TD>
+    <TD COLSPAN=2><INPUT TYPE="text" NAME="teller" VALUE="<% $cgi->param('teller') %>" SIZE=10></TD>
+  </TR>
+  <TR>
+    <TD ALIGN="right"><% mt('Depositor') |h %></TD>
+    <TD COLSPAN=3><INPUT TYPE="text" NAME="depositor" VALUE="<% $cgi->param('depositor') %>"></TD>
+  </TR>
+  <TR>
+    <TD ALIGN="right"><% mt('Account #') |h %></TD>
+    <TD COLSPAN=2><INPUT TYPE="text" NAME="account" VALUE="<% $cgi->param('account') %>" SIZE=18></TD>
+  </TR>
+% }
 
 <TR>
 % if ( $link eq 'custnum' || $link eq 'popup' ) { 
index e74f902..06f5e64 100755 (executable)
@@ -28,6 +28,8 @@
 %}
 <%init>
 
+my $conf = FS::Conf->new;
+
 $cgi->param('linknum') =~ /^(\d+)$/
   or die "Illegal linknum: ". $cgi->param('linknum');
 my $linknum = $1;
@@ -46,6 +48,7 @@ my $new = new FS::cust_pay ( {
     $_, scalar($cgi->param($_));
   } qw( paid payby payinfo paybatch
         pkgnum discount_term
+        bank depositor account teller
       )
   #} fields('cust_pay')
 } );
@@ -57,6 +60,6 @@ push @rights, 'Post cash payment'  if $new->payby eq 'CASH';
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right(\@rights);
 
-my $error = $new->insert( 'manual' => 1 );
+my $error ||= $new->insert( 'manual' => 1 );
 
 </%init>
index b5b7161..c453ffa 100644 (file)
@@ -13,6 +13,7 @@
                'cust_main'   => $cust_main,
                'actionlabel' => emt('Enter check payment'),
                'width'       => 392,
+               'height'      => 392,
   &>
 % } 
 
@@ -24,6 +25,7 @@
                'cust_main'   => $cust_main,
                'actionlabel' => emt('Enter cash payment'),
                'width'       => 392,
+               'height'      => 392,
   &>
 % } 
 
index d02f154..f9c8bc1 100644 (file)
 
 % }
 
+% if ( $cust_pay->payby eq 'CASH' && $cust_pay->payinfo ) {
+    <TR>
+      <TD ALIGN="right"><% mt('Bank') |h %></TD>
+      <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->bank %></B></TD>
+    </TR>
+
+    <TR>
+      <TD ALIGN="right"><% mt('Teller #') |h %></TD>
+      <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->teller %></B></TD>
+    </TR>
+
+    <TR>
+      <TD ALIGN="right"><% mt('Depositor') |h %></TD>
+      <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->depositor %></B></TD>
+    </TR>
+
+    <TR>
+      <TD ALIGN="right"><% mt('Account #') |h %></TD>
+      <TD BGCOLOR="#FFFFFF"><B><% $cust_pay->account %></B></TD>
+    </TR>
+% }
+
 % if ( $conf->exists('pkg-balances') && $cust_pay->pkgnum ) {
 %   my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $cust_pay->pkgnum } );
     <TR>