add skip_dcontext_suffix to skip CDRs with dcontext ending in a definable string...
[freeside.git] / FS / FS / cust_pay_refund.pm
index 15e0e53..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 { 
@@ -73,15 +68,26 @@ sub table { 'cust_pay_refund'; }
 Adds this cust_pay_refund to the database.  If there is an error, returns the
 error, otherwise returns false.
 
+=cut
+
+sub insert {
+  my $self = shift;
+  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
 
 =cut
 
 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(@_);
 }
@@ -142,24 +148,10 @@ sub check {
 
 Returns the payment (see L<FS::cust_pay>)
 
-=cut
-
-sub cust_pay {
-  my $self = shift;
-  qsearchs( 'cust_pay', { 'paynum' => $self->paynum } );
-}
-
 =item cust_refund
 
 Returns the refund (see L<FS::cust_refund>)
 
-=cut
-
-sub cust_refund {
-  my $self = shift;
-  qsearchs( 'cust_refund', { 'refundnum' => $self->refundnum } );
-}
-
 =back
 
 =head1 BUGS