summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2016-01-28 16:23:38 -0800
committerIvan Kohler <ivan@freeside.biz>2016-01-28 16:23:38 -0800
commitc4c8512adc83e2c6e6640112735e887b71222e1d (patch)
treea040a16d0525af77c47408b6f16f694464dffd75 /FS
parent5ff16520adf5c564a053875165418fe32abf1a5c (diff)
optimize Reports->Customers->List Customers, RT#20173
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Record.pm1
-rw-r--r--FS/FS/cust_pkg.pm25
-rw-r--r--FS/FS/part_pkg/flat.pm13
-rw-r--r--FS/FS/part_svc.pm3
4 files changed, 30 insertions, 12 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index cb7d03694..a117b7477 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -199,6 +199,7 @@ sub new {
$self->{'modified'} = 0;
+ $self->_simplecache($self->{'Hash'}) if $self->can('_simplecache');
$self->_cache($self->{'Hash'}, shift) if $self->can('_cache') && @_;
$self;
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index c507a457b..6dcd74018 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -56,18 +56,25 @@ our ($disable_agentcheck, $DEBUG, $me, $import) = (0, 0, '[FS::cust_pkg]', 0);
our $upgrade = 0; #go away after setup+start dates cleaned up for old customers
-sub _cache {
- my $self = shift;
- my ( $hashref, $cache ) = @_;
- #if ( $hashref->{'pkgpart'} ) {
+sub _simplecache {
+ my( $self, $hashref ) = @_;
if ( $hashref->{'pkg'} ) {
- # #@{ $self->{'_pkgnum'} } = ();
- # my $subcache = $cache->subcache('pkgpart', 'part_pkg');
- # $self->{'_pkgpart'} = $subcache;
- # #push @{ $self->{'_pkgnum'} },
- # FS::part_pkg->new_or_cached($hashref, $subcache);
$self->{'_pkgpart'} = FS::part_pkg->new($hashref);
}
+}
+
+sub _cache {
+ my $self = shift;
+ my ( $hashref, $cache ) = @_;
+# #if ( $hashref->{'pkgpart'} ) {
+# if ( $hashref->{'pkg'} ) {
+# # #@{ $self->{'_pkgnum'} } = ();
+# # my $subcache = $cache->subcache('pkgpart', 'part_pkg');
+# # $self->{'_pkgpart'} = $subcache;
+# # #push @{ $self->{'_pkgnum'} },
+# # FS::part_pkg->new_or_cached($hashref, $subcache);
+# $self->{'_pkgpart'} = FS::part_pkg->new($hashref);
+# }
if ( exists $hashref->{'svcnum'} ) {
#@{ $self->{'_pkgnum'} } = ();
my $subcache = $cache->subcache('svcnum', 'cust_svc', $hashref->{pkgnum});
diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm
index d11b99b1a..b82303c1e 100644
--- a/FS/FS/part_pkg/flat.pm
+++ b/FS/FS/part_pkg/flat.pm
@@ -127,8 +127,11 @@ sub calc_setup {
sub base_setup {
my($self, $cust_pkg, $sdate, $details ) = @_;
-
- $self->option('setup_fee') || 0;
+ ( exists( $self->{'Hash'}{'_opt_setup_fee'} )
+ ? $self->{'Hash'}{'_opt_setup_fee'}
+ : $self->option('setup_fee', 1)
+ )
+ || 0;
}
sub calc_recur {
@@ -181,7 +184,11 @@ sub cutoff_day {
sub base_recur {
my($self, $cust_pkg, $sdate) = @_;
- $self->option('recur_fee', 1) || 0;
+ ( exists( $self->{'Hash'}{'_opt_recur_fee'} )
+ ? $self->{'Hash'}{'_opt_recur_fee'}
+ : $self->option('recur_fee', 1)
+ )
+ || 0;
}
sub base_recur_permonth {
diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm
index 08003dd42..612c59013 100644
--- a/FS/FS/part_svc.pm
+++ b/FS/FS/part_svc.pm
@@ -565,6 +565,9 @@ is specified as B<0>, returns the number of unlinked customer services.
sub num_cust_svc {
my $self = shift;
+ return $self->{Hash}{num_cust_svc}
+ if !@_ && exists($self->{Hash}{num_cust_svc});
+
my @param = ( $self->svcpart );
my( $join, $and ) = ( '', '' );