backup the schema for tables we don't need the data from. RT#85959
[freeside.git] / FS / FS / cust_pay_refund.pm
index 55a5eb7..28f757d 100644 (file)
@@ -1,14 +1,9 @@
 package FS::cust_pay_refund;
+use base qw(FS::Record);
 
 use strict;
-use vars qw( @ISA ); #$conf );
-use FS::UID qw( getotaker );
 use FS::Record qw( qsearchs ); # qsearch );
 use FS::cust_main;
-use FS::cust_pay;
-use FS::cust_refund;
-
-@ISA = qw( FS::Record );
 
 #ask FS::UID to run this stuff for us later
 #FS::UID->install_callback( sub { 
@@ -77,10 +72,11 @@ error, otherwise returns false.
 
 sub insert {
   my $self = shift;
-  my $error = $self->SUPER::insert(@_);
-  return $error if $error;
-
-  '';
+  return "Can't apply refund to closed payment"
+    if $self->cust_pay->closed =~ /^Y/i;
+  return "Can't apply payment to closed refund"
+    if $self->cust_refund->closed =~ /^Y/i;
+  $self->SUPER::insert(@_);
 }
 
 =item delete
@@ -89,9 +85,9 @@ sub insert {
 
 sub delete {
   my $self = shift;
-  return "Can't apply refund to closed payment"
+  return "Can't remove refund from closed payment"
     if $self->cust_pay->closed =~ /^Y/i;
-  return "Can't apply closed refund"
+  return "Can't remove payment from closed refund"
     if $self->cust_refund->closed =~ /^Y/i;
   $self->SUPER::delete(@_);
 }
@@ -148,27 +144,13 @@ sub check {
   $self->SUPER::check;
 }
 
-=item sub cust_credit
+=item sub cust_pay
 
-Returns the credit (see L<FS::cust_credit>)
+Returns the payment (see L<FS::cust_pay>)
 
-=cut
+=item cust_refund
 
-sub cust_credit {
-  my $self = shift;
-  qsearchs( 'cust_credit', { 'crednum' => $self->crednum } );
-}
-
-=item cust_bill 
-
-Returns the invoice (see L<FS::cust_bill>)
-
-=cut
-
-sub cust_bill {
-  my $self = shift;
-  qsearchs( 'cust_bill', { 'invnum' => $self->invnum } );
-}
+Returns the refund (see L<FS::cust_refund>)
 
 =back