[freeside-commits]
freeside/FS/FS cust_pay_void.pm, 1.3, 1.4 Conf.pm,
1.146, 1.147 Record.pm, 1.109, 1.110
Ivan,,,
ivan at wavetail.420.am
Wed Dec 14 20:04:53 PST 2005
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv6117/FS/FS
Modified Files:
cust_pay_void.pm Conf.pm Record.pm
Log Message:
payment "un-void"ing
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -d -r1.146 -r1.147
--- Conf.pm 22 Nov 2005 18:29:38 -0000 1.146
+++ Conf.pm 15 Dec 2005 04:04:50 -0000 1.147
@@ -1569,6 +1569,13 @@
},
{
+ 'key' => 'unvoid',
+ 'section' => 'billing',
+ 'description' => 'Enable unvoiding of voided payments',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'address2-search',
'section' => 'UI',
'description' => 'Enable a "Unit" search box which searches the second address field',
Index: cust_pay_void.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pay_void.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cust_pay_void.pm 21 Nov 2005 10:47:11 -0000 1.3
+++ cust_pay_void.pm 15 Dec 2005 04:04:50 -0000 1.4
@@ -3,7 +3,8 @@
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 @@
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.
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- Record.pm 7 Dec 2005 23:48:57 -0000 1.109
+++ Record.pm 15 Dec 2005 04:04:51 -0000 1.110
@@ -745,9 +745,12 @@
$sth->execute or return $sth->errstr;
- my $insertid = '';
- if ( $db_seq ) { # get inserted id from the database, if applicable
+ # get inserted id from the database, if applicable & needed
+ if ( $db_seq && ! $self->getfield($primary_key) ) {
warn "[debug]$me retreiving sequence from database\n" if $DEBUG;
+
+ my $insertid = '';
+
if ( driver_name eq 'Pg' ) {
#my $oid = $sth->{'pg_oid_status'};
@@ -793,11 +796,15 @@
}
} else {
+
dbh->rollback if $FS::UID::AutoCommit;
return "don't know how to retreive inserted ids from ". driver_name.
", try using counterfiles (maybe run dbdef-create?)";
+
}
+
$self->setfield($primary_key, $insertid);
+
}
my @virtual_fields =
More information about the freeside-commits
mailing list