projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
RT# 80898 - added config option to allow for the changing of the name for credit...
[freeside.git]
/
FS
/
FS
/
cust_credit_refund.pm
diff --git
a/FS/FS/cust_credit_refund.pm
b/FS/FS/cust_credit_refund.pm
index
ff2454d
..
a0aeca7
100644
(file)
--- a/
FS/FS/cust_credit_refund.pm
+++ b/
FS/FS/cust_credit_refund.pm
@@
-1,13
+1,7
@@
package FS::cust_credit_refund;
package FS::cust_credit_refund;
+use base qw( FS::cust_main_Mixin FS::Record );
use strict;
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_refund;
-
-@ISA = qw( FS::Record );
=head1 NAME
=head1 NAME
@@
-70,20
+64,27
@@
otherwise returns false.
sub insert {
my $self = shift;
sub insert {
my $self = shift;
- my $error = $self->SUPER::insert;
- return $error if $error;
-
- '';
+ return "Can't apply refund to closed credit"
+ if $self->cust_credit->closed =~ /^Y/i;
+ return "Can't apply credit to closed refund"
+ if $self->cust_refund->closed =~ /^Y/i;
+ $self->SUPER::insert(@_);
}
=item delete
}
=item delete
-Currently unimplemented (accounting reasons).
+Remove this cust_credit_refund from the database. If there is an error,
+returns the error, otherwise returns false.
=cut
sub delete {
=cut
sub delete {
- return "Can't (yet?) delete cust_credit_refund records!";
+ my $self = shift;
+ return "Can't remove refund from closed credit"
+ if $self->cust_credit->closed =~ /^Y/i;
+ return "Can't remove credit from closed refund"
+ if $self->cust_refund->closed =~ /^Y/i;
+ $self->SUPER::delete(@_);
}
=item replace OLD_RECORD
}
=item replace OLD_RECORD
@@
-119,12
+120,10
@@
sub check {
return "amount must be > 0" if $self->amount <= 0;
return "unknown cust_credit.crednum: ". $self->crednum
return "amount must be > 0" if $self->amount <= 0;
return "unknown cust_credit.crednum: ". $self->crednum
- unless my $cust_credit =
- qsearchs( 'cust_credit', { 'crednum' => $self->crednum } );
+ unless my $cust_credit = $self->cust_credit;
return "Unknown refund"
return "Unknown refund"
- unless my $cust_refund =
- qsearchs( 'cust_refund', { 'refundnum' => $self->refundnum } );
+ unless my $cust_refund = $self->cust_refund;
$self->_date(time) unless $self->_date;
$self->_date(time) unless $self->_date;
@@
-141,30
+140,12
@@
sub check {
Returns the refund (see L<FS::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>)
=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
=back
-=head1 VERSION
-
-$Id: cust_credit_refund.pm,v 1.11 2004-06-29 04:02:44 ivan Exp $
-
=head1 BUGS
Delete and replace methods.
=head1 BUGS
Delete and replace methods.