[freeside-commits] freeside/FS/FS Conf.pm, 1.319, 1.320 Setup.pm, 1.18, 1.19 cust_bill.pm, 1.255, 1.256 cust_bill_pkg.pm, 1.39, 1.40 AccessRight.pm, 1.43, 1.44
Ivan,,,
ivan at wavetail.420.am
Sat Oct 3 19:04:51 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv21487/FS/FS
Modified Files:
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.319
retrieving revision 1.320
diff -u -d -r1.319 -r1.320
--- Conf.pm 1 Oct 2009 00:29:06 -0000 1.319
+++ Conf.pm 4 Oct 2009 02:04:49 -0000 1.320
@@ -728,7 +728,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.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- Setup.pm 24 Feb 2009 10:15:05 -0000 1.18
+++ Setup.pm 4 Oct 2009 02:04:49 -0000 1.19
@@ -364,7 +364,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.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- cust_bill_pkg.pm 11 Sep 2009 15:51:38 -0000 1.39
+++ cust_bill_pkg.pm 4 Oct 2009 02:04:49 -0000 1.40
@@ -1,7 +1,7 @@
package FS::cust_bill_pkg;
use strict;
-use vars qw( @ISA $DEBUG );
+use vars qw( @ISA $DEBUG $me );
use FS::Record qw( qsearch qsearchs dbdef dbh );
use FS::cust_main_Mixin;
use FS::cust_pkg;
@@ -12,10 +12,14 @@
use FS::cust_bill_pay_pkg;
use FS::cust_credit_bill_pkg;
use FS::cust_tax_exempt_pkg;
+use FS::cust_bill_pkg_tax_location;
+use FS::cust_bill_pkg_tax_rate_location;
+use FS::cust_tax_adjustment;
@ISA = qw( FS::cust_main_Mixin FS::Record );
-$DEBUG = 0;
+$DEBUG = 2;
+$me = '[FS::cust_bill_pkg]';
=head1 NAME
@@ -40,30 +44,57 @@
=over 4
-=item billpkgnum - primary key
+=item billpkgnum
-=item invnum - invoice (see L<FS::cust_bill>)
+primary key
-=item pkgnum - package (see L<FS::cust_pkg>) or 0 for the special virtual sales tax package, or -1 for the virtual line item (itemdesc is used for the line)
+=item invnum
-=item pkgpart_override - optional package definition (see L<FS::part_pkg>) override
-=item setup - setup fee
+invoice (see L<FS::cust_bill>)
-=item recur - recurring fee
+=item pkgnum
-=item sdate - starting date of recurring fee
+package (see L<FS::cust_pkg>) or 0 for the special virtual sales tax package, or -1 for the virtual line item (itemdesc is used for the line)
-=item edate - ending date of recurring fee
+=item pkgpart_override
-=item itemdesc - Line item description (overrides normal package description)
+optional package definition (see L<FS::part_pkg>) override
-=item quantity - If not set, defaults to 1
+=item setup
-=item unitsetup - If not set, defaults to setup
+setup fee
-=item unitrecur - If not set, defaults to recur
+=item recur
-=item hidden - If set to Y, indicates data should not appear as separate line item on invoice
+recurring fee
+
+=item sdate
+
+starting date of recurring fee
+
+=item edate
+
+ending date of recurring fee
+
+=item itemdesc
+
+Line item description (overrides normal package description)
+
+=item quantity
+
+If not set, defaults to 1
+
+=item unitsetup
+
+If not set, defaults to setup
+
+=item unitrecur
+
+If not set, defaults to recur
+
+=item hidden
+
+If set to Y, indicates data should not appear as separate line item on invoice
=back
@@ -196,13 +227,65 @@
=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_bill_pkg_display
+ cust_bill_pkg_tax_location
+ cust_bill_pkg_tax_rate_location
+ 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;
+ }
+ }
+
+ }
+
+ foreach my $cust_tax_adjustment (
+ qsearch('cust_tax_adjustment', { billpkgnum=>$self->billpkgnum })
+ ) {
+ $cust_tax_adjustment->billpkgnum(''); #NULL
+ my $error = $cust_tax_adjustment->replace;
+ 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;
+
+ '';
+
}
#alas, bin/follow-tax-rename
@@ -263,6 +346,7 @@
sub cust_pkg {
my $self = shift;
+ warn "$me $self -> cust_pkg";
qsearchs( 'cust_pkg', { 'pkgnum' => $self->pkgnum } );
}
Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- AccessRight.pm 14 Aug 2009 17:24:18 -0000 1.43
+++ AccessRight.pm 4 Oct 2009 02:04:49 -0000 1.44
@@ -150,6 +150,7 @@
'Customer invoice / financial info rights' => [
'View invoices',
'Resend invoices', #NEWNEW
+ 'Delete invoices', #new, but no need to phase in
'View customer tax exemptions', #yow
'Add customer tax adjustment', #new, but no need to phase in
'View customer batched payments', #NEW
@@ -285,14 +286,38 @@
=item rights
-Returns a list of right names.
+Returns the full list of right names.
=cut
- sub rights {
+sub rights {
#my $class = shift;
map { ref($_) ? $_->{'rightname'} : $_ } map @{ $rights{$_} }, keys %rights;
- }
+}
+
+=item default_superuser_rights
+
+Most (but not all) right names.
+
+=cut
+
+sub default_superuser_rights {
+ my $class = shift;
+ my %omit = map { $_=>1 } (
+ 'Delete customer',
+ 'Delete invoices',
+ 'Delete payment',
+ 'Delete credit', #?
+ 'Delete refund', #?
+ 'Time queue',
+ 'Redownload resolved batches',
+ 'Raw SQL',
+ 'Configuration download',
+ );
+
+ no warnings 'uninitialized';
+ grep { ! $omit{$_} } $class->rights;
+}
=item rights_info
Index: cust_bill.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill.pm,v
retrieving revision 1.255
retrieving revision 1.256
diff -u -d -r1.255 -r1.256
--- cust_bill.pm 21 Sep 2009 20:48:49 -0000 1.255
+++ cust_bill.pm 4 Oct 2009 02:04:49 -0000 1.256
@@ -160,7 +160,50 @@
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_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
@@ -460,6 +503,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.
@@ -474,6 +527,8 @@
=item cust_credited
+=item cust_credit_bill
+
Returns all applied credits (see L<FS::cust_credit_bill>) for this invoice.
=cut
@@ -485,6 +540,10 @@
;
}
+sub cust_credit_bill {
+ shift->cust_credited(@_);
+}
+
=item cust_bill_pay_pkgnum PKGNUM
Returns all payment applications (see L<FS::cust_bill_pay>) for this invoice
More information about the freeside-commits
mailing list