-package cust_credit_refund;
+package FS::cust_credit_refund;
use strict;
use vars qw( @ISA );
use FS::Record qw( qsearch qsearchs dbh );
#use FS::UID qw(getotaker);
-#use FS::cust_credit
+use FS::cust_credit;
+use FS::cust_refund;
@ISA = qw( FS::Record );
Creates a new record. To add the record to the database, see L<"insert">.
+=cut
+
sub table { 'cust_credit_refund'; }
=item insert
my $error =
$self->ut_numbern('creditrefundnum')
|| $self->ut_number('crednum')
- || $self->ut_numner('refundnum')
+ || $self->ut_number('refundnum')
|| $self->ut_money('amount')
|| $self->ut_numbern('_date')
;
return $error if $error;
+ return "amount must be > 0" if $self->amount <= 0;
+
$self->_date(time) unless $self->_date;
return "unknown cust_credit.crednum: ". $self->crednum
unless qsearchs( 'cust_credit', { 'crednum' => $self->crednum } );
- ''; #no error
+ $self->SUPER::check;
+}
+
+=item cust_refund
+
+Returns the refund (see L<FS::cust_refund>)
+
+=cut
+
+sub cust_refund {
+ my $self = shift;
+ qsearchs( 'cust_refund', { 'refundnum' => $self->refundnum } );
+}
+
+=item cust_credit
+
+Returns the credit (see L<FS::cust_credit>)
+
+=cut
+
+sub cust_credit {
+ my $self = shift;
+ qsearchs( 'cust_credit', { 'crednum' => $self->crednum } );
}
=back
=head1 VERSION
-$Id: cust_credit_refund.pm,v 1.1 2001-09-01 20:11:07 ivan Exp $
+$Id: cust_credit_refund.pm,v 1.10 2003-08-05 00:20:41 khoff Exp $
=head1 BUGS
Delete and replace methods.
+the checks for over-applied refunds could be better done like the ones in
+cust_bill_credit
+
=head1 SEE ALSO
L<FS::cust_credit>, L<FS::cust_refund>, L<FS::Record>, schema.html from the