X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=daf5b5263d00a99887684426ecd0cd8aa1f3ca99;hb=b7cdcea59f34c12f7d181c41014e0d2559bf983c;hp=42ca0b0a55ea2d59492dc83f359393e3a6dea052;hpb=fbcb45dfe5a1bce7981fe4527176b9fdf2ec54b7;p=freeside.git diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 42ca0b0a5..daf5b5263 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -1,15 +1,24 @@ package FS::cust_pay; use strict; -use vars qw( @ISA ); +use vars qw( @ISA $conf $unsuspendauto ); use Business::CreditCard; -use FS::Record qw( dbh qsearch qsearchs ); +use FS::UID qw( dbh ); +use FS::Record qw( dbh qsearch qsearchs dbh ); use FS::cust_bill; use FS::cust_bill_pay; use FS::cust_main; @ISA = qw( FS::Record ); +#ask FS::UID to run this stuff for us later +$FS::UID::callback{'FS::cust_pay'} = sub { + + $conf = new FS::Conf; + $unsuspendauto = $conf->exists('unsuspendauto'); + +}; + =head1 NAME FS::cust_pay - Object methods for cust_pay objects @@ -90,6 +99,9 @@ sub insert { local $FS::UID::AutoCommit = 0; my $dbh = dbh; + my $cust_main = qsearchs( 'cust_main', { 'custnum' => $self->custnum } ); + my $old_balance = $cust_main->balance; + my $error = $self->check; return $error if $error; @@ -124,6 +136,17 @@ sub insert { $dbh->commit or die $dbh->errstr if $oldAutoCommit; + #false laziness w/ cust_credit::insert + if ( $unsuspendauto && $old_balance && $cust_main->balance <= 0 ) { + my @errors = $cust_main->unsuspend; + #return + # side-fx with nested transactions? upstack rolls back? + warn "WARNING:Errors unsuspending customer ". $cust_main->custnum. ": ". + join(' / ', @errors) + if @errors; + } + #eslaf + ''; } @@ -281,7 +304,7 @@ sub unapplied { =head1 VERSION -$Id: cust_pay.pm,v 1.7 2001-09-03 22:07:38 ivan Exp $ +$Id: cust_pay.pm,v 1.8 2001-10-09 23:10:16 ivan Exp $ =head1 BUGS