From 125e4cd2fb42c7b9b1e4262fa03c2ae0c0c8f2af Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 1 Mar 2007 05:24:46 +0000 Subject: dangling cust_credit_refund not allowed --- FS/FS/cust_credit.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm index 7ffb1d178..84ca79dbf 100644 --- a/FS/FS/cust_credit.pm +++ b/FS/FS/cust_credit.pm @@ -164,6 +164,14 @@ sub delete { } } + foreach my $cust_credit_refund ( $self->cust_credit_refund ) { + my $error = $cust_credit_refund->delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + my $error = $self->SUPER::delete(@_); if ( $error ) { $dbh->rollback if $oldAutoCommit; -- cgit v1.2.1 From fb19d4e46a85f34fe22106d783152a0a69b2ac30 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 1 Mar 2007 16:36:07 +0000 Subject: turn off debugging --- FS/FS/cust_bill_ApplicationCommon.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS/FS/cust_bill_ApplicationCommon.pm b/FS/FS/cust_bill_ApplicationCommon.pm index 9f61f5be5..24274e701 100644 --- a/FS/FS/cust_bill_ApplicationCommon.pm +++ b/FS/FS/cust_bill_ApplicationCommon.pm @@ -8,7 +8,7 @@ use FS::Record qw( qsearch qsearchs dbh ); @ISA = qw( FS::Record ); -$DEBUG = 1; +$DEBUG = 0; $me = '[FS::cust_bill_ApplicationCommon]'; =head1 NAME -- cgit v1.2.1 From 965185edd27890ea2fc00c7179dccf137b61320d Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 1 Mar 2007 17:44:14 +0000 Subject: fix weird compliation problem for quis, i hope --- FS/FS/Misc.pm | 104 +++------------------------------------------------------- 1 file changed, 4 insertions(+), 100 deletions(-) diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm index e2143cf80..a1d41e0a4 100644 --- a/FS/FS/Misc.pm +++ b/FS/FS/Misc.pm @@ -4,17 +4,15 @@ use strict; use vars qw ( @ISA @EXPORT_OK $DEBUG ); use Exporter; use Carp; -use FS::Record qw(dbh qsearch); -use FS::cust_credit_refund; -#use FS::cust_credit_bill; -#use FS::cust_bill_pay; -#use FS::cust_pay_refund; use Data::Dumper; +#do NOT depend on any FS:: modules here, causes weird (sometimes unreproducable +#until on client machine) dependancy loops. put them in FS::Misc::Something +#instead @ISA = qw( Exporter ); @EXPORT_OK = qw( send_email send_fax states_hash counties state_label - card_types prune_applications + card_types ); $DEBUG = 0; @@ -473,100 +471,6 @@ sub card_types { \%card_types; } -=item prune_applications OPTION_HASH - -Removes applications of credits to refunds in the event that the database -is corrupt and either the credits or refunds are missing (see -L, L, and L). -If the OPTION_HASH contains the element 'dry_run' then a report of -affected records is returned rather than actually deleting the records. - -=cut - -sub prune_applications { - my $options = shift; - my $dbh = dbh - - local $DEBUG = 1 if exists($options->{debug}); - my $ccr = < { clause => $ccr, - link1 => 'crednum', - link2 => 'refundnum', - }, -# 'cust_credit_bill' => { clause => $ccb, -# link1 => 'crednum', -# link2 => 'refundnum', -# }, -# 'cust_bill_pay' => { clause => $cbp, -# link1 => 'crednum', -# link2 => 'refundnum', -# }, -# 'cust_pay_refund' => { clause => $cpr, -# link1 => 'crednum', -# link2 => 'refundnum', -# }, - ); - - if ( exists($options->{dry_run}) ) { - my @response = (); - foreach my $table (keys %strays) { - my $clause = $strays{$table}->{clause}; - my $link1 = $strays{$table}->{link1}; - my $link2 = $strays{$table}->{link2}; - my @rec = qsearch($table, {}, '', $clause); - my $keyname = $rec[0]->primary_key if $rec[0]; - foreach (@rec) { - push @response, "$table " .$_->$keyname . " claims attachment to ". - "$link1 " . $_->$link1 . " and $link2 " . $_->$link2 . "\n"; - } - } - return (@response); - } else { - foreach (keys %strays) { - my $statement = "DELETE FROM $_ " . $strays{$_}->{clause}; - warn $statement if $DEBUG; - my $sth = $dbh->prepare($statement) - or die $dbh->errstr; - $sth->execute - or die $sth->errstr; - } - return (); - } -} - =back =head1 BUGS -- cgit v1.2.1 From e1d6655b9607b22ab98fb710bf463ed3e2fedf5e Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 1 Mar 2007 17:47:46 +0000 Subject: adding FS::Misc::prune --- FS/FS/Misc/prune.pm | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 FS/FS/Misc/prune.pm diff --git a/FS/FS/Misc/prune.pm b/FS/FS/Misc/prune.pm new file mode 100644 index 000000000..634cd8a6c --- /dev/null +++ b/FS/FS/Misc/prune.pm @@ -0,0 +1,126 @@ +package FS::Misc::prune; + +use strict; +use vars qw ( @ISA @EXPORT_OK $DEBUG ); +use Exporter; +use FS::Record qw(dbh qsearch); +use FS::cust_credit_refund; +#use FS::cust_credit_bill; +#use FS::cust_bill_pay; +#use FS::cust_pay_refund; + +@ISA = qw( Exporter ); +@EXPORT_OK = qw( prune applications ); + +=head1 NAME + +FS::Misc::prune - misc. pruning subroutines + +=head1 SYNOPSIS + +use FS::Misc::prune qw(prune_applications); + +prune_applications(); + +=item prune_applications OPTION_HASH + +Removes applications of credits to refunds in the event that the database +is corrupt and either the credits or refunds are missing (see +L, L, and L). +If the OPTION_HASH contains the element 'dry_run' then a report of +affected records is returned rather than actually deleting the records. + +=cut + +sub prune_applications { + my $options = shift; + my $dbh = dbh + + local $DEBUG = 1 if exists($options->{debug}); + my $ccr = < { clause => $ccr, + link1 => 'crednum', + link2 => 'refundnum', + }, +# 'cust_credit_bill' => { clause => $ccb, +# link1 => 'crednum', +# link2 => 'refundnum', +# }, +# 'cust_bill_pay' => { clause => $cbp, +# link1 => 'crednum', +# link2 => 'refundnum', +# }, +# 'cust_pay_refund' => { clause => $cpr, +# link1 => 'crednum', +# link2 => 'refundnum', +# }, + ); + + if ( exists($options->{dry_run}) ) { + my @response = (); + foreach my $table (keys %strays) { + my $clause = $strays{$table}->{clause}; + my $link1 = $strays{$table}->{link1}; + my $link2 = $strays{$table}->{link2}; + my @rec = qsearch($table, {}, '', $clause); + my $keyname = $rec[0]->primary_key if $rec[0]; + foreach (@rec) { + push @response, "$table " .$_->$keyname . " claims attachment to ". + "$link1 " . $_->$link1 . " and $link2 " . $_->$link2 . "\n"; + } + } + return (@response); + } else { + foreach (keys %strays) { + my $statement = "DELETE FROM $_ " . $strays{$_}->{clause}; + warn $statement if $DEBUG; + my $sth = $dbh->prepare($statement) + or die $dbh->errstr; + $sth->execute + or die $sth->errstr; + } + return (); + } +} + +=back + +=head1 BUGS + +=cut + +1; + -- cgit v1.2.1