[freeside-commits] freeside/FS/FS Conf.pm, 1.180.2.51, 1.180.2.52 Setup.pm, 1.8.2.4, 1.8.2.5 cust_bill.pm, 1.163.2.45, 1.163.2.46 cust_bill_pkg.pm, 1.12.2.4, 1.12.2.5 AccessRight.pm, 1.18.2.9, 1.18.2.10
Ivan,,,
ivan at wavetail.420.am
Sat Oct 3 19:05:34 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv21569/FS/FS
Modified Files:
Tag: FREESIDE_1_7_BRANCH
Conf.pm Setup.pm cust_bill.pm cust_bill_pkg.pm AccessRight.pm
Log Message:
delete invoices, RT#4048
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.180.2.51
retrieving revision 1.180.2.52
diff -u -d -r1.180.2.51 -r1.180.2.52
--- Conf.pm 1 Oct 2009 00:29:15 -0000 1.180.2.51
+++ Conf.pm 4 Oct 2009 02:05:31 -0000 1.180.2.52
@@ -482,7 +482,14 @@
{
'key' => 'deletecustomers',
'section' => 'UI',
- 'description' => 'Enable customer deletions. Be very careful! Deleting a customer will remove all traces that this customer ever existed! It should probably only be used when auditing a legacy database. Normally, you cancel all of a customers\' packages if they cancel service.',
+ 'description' => 'Enable customer deletions. Be very careful! Deleting a customer will remove all traces that the customer ever existed! It should probably only be used when auditing a legacy database. Normally, you cancel all of a customers\' packages if they cancel service.',
+ 'type' => 'checkbox',
+ },
+
+ {
+ 'key' => 'deleteinvoices',
+ 'section' => 'UI',
+ 'description' => 'Enable invoices deletions. Be very careful! Deleting an invoice will remove all traces that the invoice ever existed! Normally, you would apply a credit against the invoice instead.', #invoice voiding?
'type' => 'checkbox',
},
Index: Setup.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Setup.pm,v
retrieving revision 1.8.2.4
retrieving revision 1.8.2.5
diff -u -d -r1.8.2.4 -r1.8.2.5
--- Setup.pm 12 Dec 2007 05:58:15 -0000 1.8.2.4
+++ Setup.pm 4 Oct 2009 02:05:31 -0000 1.8.2.5
@@ -352,7 +352,7 @@
use FS::AccessRight;
use FS::access_right;
- foreach my $rightname ( FS::AccessRight->rights ) {
+ foreach my $rightname ( FS::AccessRight->default_superuser_rights ) {
my $access_right = new FS::access_right {
'righttype' => 'FS::access_group',
'rightobjnum' => 1, #$supergroup->groupnum,
Index: cust_bill_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg.pm,v
retrieving revision 1.12.2.4
retrieving revision 1.12.2.5
diff -u -d -r1.12.2.4 -r1.12.2.5
--- cust_bill_pkg.pm 4 Jun 2008 17:57:43 -0000 1.12.2.4
+++ cust_bill_pkg.pm 4 Oct 2009 02:05:32 -0000 1.12.2.5
@@ -1,7 +1,7 @@
package FS::cust_bill_pkg;
use strict;
-use vars qw( @ISA );
+use vars qw( @ISA $DEBUG $me );
use FS::Record qw( qsearch qsearchs dbdef dbh );
use FS::cust_main_Mixin;
use FS::cust_pkg;
@@ -12,6 +12,9 @@
@ISA = qw( FS::cust_main_Mixin FS::Record );
+$DEBUG = 0;
+$me = '[FS::cust_bill_pkg]';
+
=head1 NAME
FS::cust_bill_pkg - Object methods for cust_bill_pkg records
@@ -133,13 +136,51 @@
=item delete
-Currently unimplemented. I don't remove line items because there would then be
-no record the items ever existed (which is bad, no?)
+Not recommended.
=cut
sub delete {
- return "Can't delete cust_bill_pkg records!";
+ 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;
+
+ foreach my $table (qw(
+ cust_bill_pkg_detail
+ cust_tax_exempt_pkg
+ cust_bill_pay_pkg
+ cust_credit_bill_pkg
+ )) {
+
+ foreach my $linked ( qsearch($table, { billpkgnum=>$self->billpkgnum }) ) {
+ my $error = $linked->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
@@ -196,6 +237,7 @@
sub cust_pkg {
my $self = shift;
+ warn "$me $self -> cust_pkg" if $DEBUG;
qsearchs( 'cust_pkg', { 'pkgnum' => $self->pkgnum } );
}
Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.18.2.9
retrieving revision 1.18.2.10
diff -u -d -r1.18.2.9 -r1.18.2.10
--- AccessRight.pm 26 Sep 2008 03:56:40 -0000 1.18.2.9
+++ AccessRight.pm 4 Oct 2009 02:05:32 -0000 1.18.2.10
@@ -139,6 +139,7 @@
###
'View invoices',
'Resend invoices', #NEWNEW
+ 'Delete invoices', #new, but no need to phase in
'View customer tax exemptions', #yow
'View customer batched payments', #NEW
@@ -216,3 +217,19 @@
@rights;
}
+sub default_superuser_rights {
+ my $class = shift;
+ my %omit = map { $_=>1 } (
+ 'Delete customer',
+ 'Delete invoices',
+ 'Delete payment',
+ 'Delete credit', #?
+ 'Delete refund', #?
+ 'Raw SQL',
+ );
+
+ no warnings 'uninitialized';
+ grep { ! $omit{$_} } $class->rights;
+}
+
+1;
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.163.2.45
retrieving revision 1.163.2.46
diff -u -d -r1.163.2.45 -r1.163.2.46
--- cust_bill.pm 17 Apr 2009 07:21:34 -0000 1.163.2.45
+++ cust_bill.pm 4 Oct 2009 02:05:31 -0000 1.163.2.46
@@ -139,7 +139,49 @@
sub delete {
my $self = shift;
return "Can't delete closed invoice" 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 $table (qw(
+ cust_bill_event
+ cust_credit_bill
+ cust_bill_pay
+ cust_bill_pay
+ cust_credit_bill
+ cust_pay_batch
+ cust_bill_pay_batch
+ cust_bill_pkg
+ )) {
+
+ foreach my $linked ( $self->$table() ) {
+ my $error = $linked->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
@@ -353,6 +395,16 @@
#;
}
+sub cust_pay_batch {
+ my $self = shift;
+ qsearch('cust_pay_batch', { 'invnum' => $self->invnum } );
+}
+
+sub cust_bill_pay_batch {
+ my $self = shift;
+ qsearch('cust_bill_pay_batch', { 'invnum' => $self->invnum } );
+}
+
=item cust_bill_pay
Returns all payment applications (see L<FS::cust_bill_pay>) for this invoice.
@@ -367,6 +419,8 @@
=item cust_credited
+=item cust_credit_bill
+
Returns all applied credits (see L<FS::cust_credit_bill>) for this invoice.
=cut
@@ -378,6 +432,10 @@
;
}
+sub cust_credit_bill {
+ shift->cust_credited(@_);
+}
+
=item tax
Returns the tax amount (see L<FS::cust_bill_pkg>) for this invoice.
More information about the freeside-commits
mailing list