book closing schema changes
[freeside.git] / FS / FS / cust_pay.pm
index 21365c1..3f81135 100644 (file)
@@ -57,10 +57,12 @@ L<Time::Local> and L<Date::Parse> for conversion functions.
 
 =item payby - `CARD' (credit cards), `BILL' (billing), or `COMP' (free)
 
-=item payinfo - card number, P.O.#, or comp issuer (4-8 lowercase alphanumerics; think username)
+=item payinfo - card number, check #, or comp issuer (4-8 lowercase alphanumerics; think username), respectively
 
 =item paybatch - text field for tracking card processing
 
+=item closed - books closed flag, empty or `Y'
+
 =back
 
 =head1 METHODS
@@ -208,7 +210,9 @@ Currently unimplemented (accounting reasons).
 =cut
 
 sub delete {
-  return "Can't (yet?) delete cust_pay records!";
+  my $self = shift;
+  return "Can't delete closed payment" if $self->closed =~ /^Y/i;
+  $self->SUPER::delete(@_);
 }
 
 =item replace OLD_RECORD
@@ -237,9 +241,12 @@ sub check {
     || $self->ut_money('paid')
     || $self->ut_numbern('_date')
     || $self->ut_textn('paybatch')
+    || $self->ut_enum('closed', [ '', 'Y' ])
   ;
   return $error if $error;
 
+  return "paid must be > 0 " if $self->paid <= 0;
+
   return "unknown cust_main.custnum: ". $self->custnum
     unless $self->invnum
            || qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
@@ -249,6 +256,7 @@ sub check {
   $self->payby =~ /^(CARD|BILL|COMP)$/ or return "Illegal payby";
   $self->payby($1);
 
+  #false laziness with cust_refund::check
   if ( $self->payby eq 'CARD' ) {
     my $payinfo = $self->payinfo;
     $payinfo =~ s/\D//g;
@@ -304,7 +312,7 @@ sub unapplied {
 
 =head1 VERSION
 
-$Id: cust_pay.pm,v 1.9 2001-12-08 10:07:27 ivan Exp $
+$Id: cust_pay.pm,v 1.14 2002-01-28 06:57:23 ivan Exp $
 
 =head1 BUGS