[freeside-commits]
freeside/FS/FS AccessRight.pm, 1.15, 1.16 Conf.pm,
1.174, 1.175 cust_credit_refund.pm, 1.12,
1.13 cust_pay_refund.pm, 1.3, 1.4 cust_refund.pm, 1.28, 1.29
Jeff Finucane,420,,
jeff at wavetail.420.am
Mon Jan 8 09:36:55 PST 2007
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv31164/FS/FS
Modified Files:
AccessRight.pm Conf.pm cust_credit_refund.pm
cust_pay_refund.pm cust_refund.pm
Log Message:
refund deletion
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.174
retrieving revision 1.175
diff -u -d -r1.174 -r1.175
--- Conf.pm 15 Dec 2006 12:43:44 -0000 1.174
+++ Conf.pm 8 Jan 2007 17:36:52 -0000 1.175
@@ -496,6 +496,13 @@
},
{
+ 'key' => 'deleterefunds',
+ 'section' => 'billing',
+ 'description' => 'Enable deletion of unclosed refunds. Be very careful! Only delete refunds that were data-entry errors, not adjustments.',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'unapplypayments',
'section' => 'deprecated',
'description' => '<B>DEPRECATED</B>, now controlled by ACLs. Used to enable "unapplication" of unclosed payments.',
Index: cust_refund.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_refund.pm,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- cust_refund.pm 24 Dec 2006 01:28:37 -0000 1.28
+++ cust_refund.pm 8 Jan 2007 17:36:52 -0000 1.29
@@ -166,14 +166,52 @@
=item delete
-Currently unimplemented (accounting reasons).
+Unless the closed flag is set, deletes this refund and all associated
+applications (see L<FS::cust_credit_refund> and L<FS::cust_pay_refund>).
=cut
sub delete {
my $self = shift;
return "Can't delete closed refund" if $self->closed =~ /^Y/i;
- $self->SUPER::delete(@_);
+
+ 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;
+
+ foreach my $cust_credit_refund ( $self->cust_credit_refund ) {
+ my $error = $cust_credit_refund->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ foreach my $cust_pay_refund ( $self->cust_pay_refund ) {
+ my $error = $cust_pay_refund->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ my $error = $self->SUPER::delete(@_);
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+ '';
+
}
=item replace OLD_RECORD
Index: cust_pay_refund.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pay_refund.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cust_pay_refund.pm 6 Oct 2005 07:34:58 -0000 1.3
+++ cust_pay_refund.pm 8 Jan 2007 17:36:52 -0000 1.4
@@ -73,15 +73,26 @@
Adds this cust_pay_refund to the database. If there is an error, returns the
error, otherwise returns false.
+=cut
+
+sub insert {
+ my $self = shift;
+ return "Can't apply refund to closed payment"
+ if $self->cust_pay->closed =~ /^Y/i;
+ return "Can't apply payment to closed refund"
+ if $self->cust_refund->closed =~ /^Y/i;
+ $self->SUPER::insert(@_);
+}
+
=item delete
=cut
sub delete {
my $self = shift;
- return "Can't apply refund to closed payment"
+ return "Can't remove refund from closed payment"
if $self->cust_pay->closed =~ /^Y/i;
- return "Can't apply closed refund"
+ return "Can't remove payment from closed refund"
if $self->cust_refund->closed =~ /^Y/i;
$self->SUPER::delete(@_);
}
Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- AccessRight.pm 7 Dec 2006 02:40:30 -0000 1.15
+++ AccessRight.pm 8 Jan 2007 17:36:52 -0000 1.16
@@ -138,6 +138,8 @@
'Delete payment', #aka. deletepayments - Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments. Optionally specify one or more comma-separated email addresses to be notified when a payment is deleted.
+ 'Delete refund',
+
###
# customer credit rights
###
Index: cust_credit_refund.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_credit_refund.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- cust_credit_refund.pm 26 Nov 2004 09:39:52 -0000 1.12
+++ cust_credit_refund.pm 8 Jan 2007 17:36:52 -0000 1.13
@@ -70,20 +70,27 @@
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
-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 {
- 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
More information about the freeside-commits
mailing list