summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Conf.pm7
-rw-r--r--FS/FS/cust_bill_pay.pm10
-rw-r--r--FS/FS/cust_pay.pm36
3 files changed, 47 insertions, 6 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index cc91e8292..873ee75a9 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -268,6 +268,13 @@ httemplate/docs/config.html
},
{
+ 'key' => 'deletepayments',
+ 'section' => 'UI',
+ 'description' => 'Enable deletion of unclosed payments. Be very careful! Only delete payments that were data-entry errors, not adjustments.',
+ 'type' => 'checkbox',
+ },
+
+ {
'key' => 'dirhash',
'section' => 'shell',
'description' => 'Optional numeric value to control directory hashing. If positive, hashes directories for the specified number of levels from the front of the username. If negative, hashes directories for the specified number of levels from the end of the username. Some examples: <ul><li>1: user -> <a href="#home">/home</a>/u/user<li>2: user -> <a href="#home">/home</a>/u/s/user<li>-1: user -> <a href="#home">/home</a>/r/user<li>-2: user -> <a href="#home">home</a>/r/e/user</ul>',
diff --git a/FS/FS/cust_bill_pay.pm b/FS/FS/cust_bill_pay.pm
index 1c838b932..913704bef 100644
--- a/FS/FS/cust_bill_pay.pm
+++ b/FS/FS/cust_bill_pay.pm
@@ -125,12 +125,16 @@ sub insert {
=item delete
-Currently unimplemented (accounting reasons).
+Deletes this payment application, unless the closed flag for the parent payment
+(see L<FS::cust_pay>) is set.
=cut
sub delete {
- return "Can't (yet?) delete cust_bill_pay records!";
+ my $self = shift;
+ return "Can't delete application for closed payment"
+ if $self->cust_pay->closed =~ /^Y/i;
+ $self->SUPER::delete(@_);
}
=item replace OLD_RECORD
@@ -195,7 +199,7 @@ sub cust_bill {
=head1 VERSION
-$Id: cust_bill_pay.pm,v 1.11 2002-01-24 16:58:47 ivan Exp $
+$Id: cust_bill_pay.pm,v 1.12 2002-02-07 22:29:34 ivan Exp $
=head1 BUGS
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index 51c7b29e1..839571a95 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -211,14 +211,44 @@ sub upgrade_replace { #1.3.x->1.4.x
=item delete
-Currently unimplemented (accounting reasons).
+Deletes this payment and all associated applications (see L<FS::cust_bill_pay>),
+unless the closed flag is set.
=cut
sub delete {
my $self = shift;
return "Can't delete closed payment" 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_bill_pay ( $self->cust_bill_pay ) {
+ my $error = $cust_bill_pay->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
@@ -318,7 +348,7 @@ sub unapplied {
=head1 VERSION
-$Id: cust_pay.pm,v 1.15 2002-01-29 16:33:15 ivan Exp $
+$Id: cust_pay.pm,v 1.16 2002-02-07 22:29:34 ivan Exp $
=head1 BUGS