diff options
author | ivan <ivan> | 2005-12-15 04:04:51 +0000 |
---|---|---|
committer | ivan <ivan> | 2005-12-15 04:04:51 +0000 |
commit | 0f37b9c32e41fd94a0d5ea2f895a737cf674f310 (patch) | |
tree | 2e0a6702cf3147004349922b498f85c2b7f491c6 /FS/FS/cust_pay_void.pm | |
parent | 25f896a67adbd71fe7436271b90460a39d513bea (diff) |
payment "un-void"ing
Diffstat (limited to 'FS/FS/cust_pay_void.pm')
-rw-r--r-- | FS/FS/cust_pay_void.pm | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/FS/FS/cust_pay_void.pm b/FS/FS/cust_pay_void.pm index 71fe88b6f..946d69fe1 100644 --- a/FS/FS/cust_pay_void.pm +++ b/FS/FS/cust_pay_void.pm @@ -3,7 +3,8 @@ use strict; use vars qw( @ISA ); use Business::CreditCard; use FS::UID qw(getotaker); -use FS::Record qw(qsearchs); # dbh qsearch ); +use FS::Record qw(qsearchs dbh fields); # qsearch ); +use FS::cust_pay; #use FS::cust_bill; #use FS::cust_bill_pay; #use FS::cust_pay_refund; @@ -78,16 +79,53 @@ sub table { 'cust_pay_void'; } Adds this voided payment to the database. -=item delete +=item unvoid -Currently unimplemented. +"Un-void"s this payment: Deletes the voided payment from the database and adds +back a normal payment. =cut -sub delete { - return "Can't delete voided payments!"; +sub unvoid { + my $self = shift; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + my $cust_pay = new FS::cust_pay ( { + map { $_ => $self->get($_) } fields('cust_pay') + } ); + my $error = $cust_pay->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $error = $self->delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + + ''; + } +=item delete + +Deletes this voided payment. You probably don't want to use this directly; see +the B<unvoid> method to add the original payment back. + =item replace OLD_RECORD Currently unimplemented. |