use strict;
use vars qw( @ISA );
use Business::CreditCard;
-use FS::Record qw( dbh );
+use FS::Record qw( qsearchs dbh );
use FS::UID qw(getotaker);
use FS::cust_credit;
use FS::cust_credit_refund;
=item _date - specified as a UNIX timestamp; see L<perlfunc/"time">. Also see
L<Time::Local> and L<Date::Parse> for conversion functions.
-=item payby - `CARD' (credit cards), `BILL' (billing), or `COMP' (free)
+=item payby - `CARD' (credit cards), `CHEK' (electronic check/ACH),
+`LECB' (Phone bill billing), `BILL' (billing), or `COMP' (free)
=item payinfo - card number, P.O.#, or comp issuer (4-8 lowercase alphanumerics; think username)
=item otaker - order taker (assigned automatically, see L<FS::UID>)
+=item closed - books closed flag, empty or `Y'
+
=back
=head1 METHODS
my $dbh = dbh;
if ( $self->crednum ) {
- my $cust_credit = qsearchs('cust_bill', { 'invnum' => $self->invnum } )
+ my $cust_credit = qsearchs('cust_credit', { 'crednum' => $self->crednum } )
or do {
$dbh->rollback if $oldAutoCommit;
return "Unknown cust_credit.crednum: ". $self->crednum;
=cut
sub delete {
- return "Can't (yet?) delete cust_refund records!";
+ my $self = shift;
+ return "Can't delete closed refund" if $self->closed =~ /^Y/i;
+ $self->SUPER::delete(@_);
}
=item replace OLD_RECORD
my $self = shift;
my $error =
- $self->ut_number('refundnum')
+ $self->ut_numbern('refundnum')
|| $self->ut_numbern('custnum')
|| $self->ut_money('refund')
|| $self->ut_numbern('_date')
|| $self->ut_textn('paybatch')
+ || $self->ut_enum('closed', [ '', 'Y' ])
;
return $error if $error;
- return "refund must be > 0 " if $self->refund == 0;
+ return "refund must be > 0 " if $self->refund <= 0;
$self->_date(time) unless $self->_date;
unless $self->crednum
|| qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
- $self->payby =~ /^(CARD|BILL|COMP)$/ or return "Illegal payby";
+ $self->payby =~ /^(CARD|CHEK|LECB|BILL|COMP)$/ or return "Illegal payby";
$self->payby($1);
#false laziness with cust_pay::check
=head1 VERSION
-$Id: cust_refund.pm,v 1.13 2002-01-24 11:52:02 ivan Exp $
+$Id: cust_refund.pm,v 1.20 2002-11-19 09:51:58 ivan Exp $
=head1 BUGS