freeside/FS/FS h_cust_svc.pm,1.2,1.3 h_svc_www.pm,1.3,1.4 h_svc_acct.pm,1.2,1.3
Kristian Hoffmann
khoff at pouncequick.420.am
Fri Apr 1 14:52:14 PST 2005
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory pouncequick:/tmp/cvs-serv32029
Modified Files:
h_cust_svc.pm h_svc_www.pm h_svc_acct.pm
Log Message:
Trap, and attempt to resolve, problems caused by missing history records.
Index: h_svc_www.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/h_svc_www.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- h_svc_www.pm 30 Mar 2005 21:09:05 -0000 1.3
+++ h_svc_www.pm 1 Apr 2005 22:52:11 -0000 1.4
@@ -1,7 +1,8 @@
package FS::h_svc_www;
use strict;
-use vars qw( @ISA );
+use vars qw( @ISA $DEBUG );
+use Carp qw(carp);
use FS::Record qw(qsearchs);
use FS::h_Common;
use FS::svc_www;
@@ -9,6 +10,8 @@
@ISA = qw( FS::h_Common FS::svc_www );
+$DEBUG = 0;
+
sub table { 'h_svc_www' };
=head1 NAME
@@ -27,10 +30,21 @@
sub domain_record {
my $self = shift;
- qsearchs( 'h_domain_record',
- { 'recnum' => $self->recnum },
- FS::h_domain_record->sql_h_searchs(@_),
- );
+
+ carp 'Called FS::h_svc_www->domain_record on svcnum ' . $self->svcnum if $DEBUG;
+
+ my $domain_record = qsearchs(
+ 'h_domain_record',
+ { 'recnum' => $self->recnum },
+ FS::h_domain_record->sql_h_searchs(@_),
+ ) || $self->SUPER::domain_record
+ or die "no history domain_record.recnum for svc_www.recnum ". $self->domsvc;
+
+ carp 'Using FS::svc_acct record in place of missing FS::h_svc_acct record.'
+ if ($domain_record->isa('FS::domain_record') and $DEBUG);
+
+ return $domain_record;
+
}
=back
Index: h_svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/h_svc_acct.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- h_svc_acct.pm 3 Mar 2005 10:25:21 -0000 1.2
+++ h_svc_acct.pm 1 Apr 2005 22:52:11 -0000 1.3
@@ -1,14 +1,18 @@
package FS::h_svc_acct;
use strict;
-use vars qw( @ISA );
+use vars qw( @ISA $DEBUG );
+use Carp qw(carp);
use FS::Record qw(qsearchs);
use FS::h_Common;
use FS::svc_acct;
+use FS::svc_domain;
use FS::h_svc_domain;
@ISA = qw( FS::h_Common FS::svc_acct );
+$DEBUG = 0;
+
sub table { 'h_svc_acct' };
=head1 NAME
@@ -32,6 +36,27 @@
FS::h_svc_domain->sql_h_searchs(@_),
);
}
+
+=item domain
+
+Returns the domain associated with this account.
+
+=cut
+
+sub domain {
+ my $self = shift;
+ die "svc_acct.domsvc is null for svcnum ". $self->svcnum unless $self->domsvc;
+
+ my $svc_domain = $self->svc_domain(@_) || $self->SUPER::svc_domain()
+ or die 'no history svc_domain.svcnum for svc_acct.domsvc ' . $self->domsvc;
+
+ carp 'Using FS::svc_acct record in place of missing FS::h_svc_acct record.'
+ if ($svc_domain->isa('FS::svc_acct') and $DEBUG);
+
+ $svc_domain->domain;
+
+}
+
=back
Index: h_cust_svc.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/h_cust_svc.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- h_cust_svc.pm 3 Mar 2005 10:25:21 -0000 1.2
+++ h_cust_svc.pm 1 Apr 2005 22:52:11 -0000 1.3
@@ -40,9 +40,25 @@
sub label {
my $self = shift;
carp "FS::h_cust_svc::label called on $self" if $DEBUG;
- my $svc_x = $self->h_svc_x(@_)
- or die "can't find h_". $self->part_svc->svcdb. '.svcnum '. $self->svcnum;
- $self->_svc_label($svc_x, @_);
+ my $svc_x = $self->h_svc_x(@_);
+ my $part_svc = $self->part_svc;
+
+ unless ($svc_x) {
+ carp "can't find h_". $self->part_svc->svcdb. '.svcnum '. $self->svcnum if $DEBUG;
+ return $part_svc->svc, 'n/a', $part_svc->svcdb;
+ }
+
+ my @label;
+ eval { @label = $self->_svc_label($svc_x, @_); };
+
+ if ($@) {
+ carp 'while resolving history record for svcdb/svcnum ' .
+ $part_svc->svcdb . '/' . $self->svcnum . ': ' . $@ if $DEBUG;
+ return $part_svc->svc, 'n/a', $part_svc->svcdb;
+ } else {
+ return @label;
+ }
+
}
=item h_svc_x END_TIMESTAMP [ START_TIMESTAMP ]
More information about the freeside-commits
mailing list