X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay_refund.pm;h=28f757d6660c3649be9fc5e55b09751fad1f05f1;hb=368ed08e24400e9d1faf401a1e4e23ea54d2c969;hp=af25f177402f38f9766783fec9aadfda53400e49;hpb=b8cfd0780aa40bb07f3215bf9cb58011f5e32a35;p=freeside.git diff --git a/FS/FS/cust_pay_refund.pm b/FS/FS/cust_pay_refund.pm index af25f1774..28f757d66 100644 --- a/FS/FS/cust_pay_refund.pm +++ b/FS/FS/cust_pay_refund.pm @@ -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(@_); } @@ -138,27 +144,13 @@ sub check { $self->SUPER::check; } -=item sub cust_credit +=item sub cust_pay -Returns the credit (see L) +Returns the payment (see L) -=cut - -sub cust_credit { - my $self = shift; - qsearchs( 'cust_credit', { 'crednum' => $self->crednum } ); -} - -=item cust_bill +=item cust_refund -Returns the invoice (see L) - -=cut - -sub cust_bill { - my $self = shift; - qsearchs( 'cust_bill', { 'invnum' => $self->invnum } ); -} +Returns the refund (see L) =back