summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2016-01-28 16:23:42 -0800
committerIvan Kohler <ivan@freeside.biz>2016-01-28 16:23:42 -0800
commitaea97dbd5c5ac96c4610b112e55f64da66028ef6 (patch)
tree8fdd372bb73f17e722b1b41ca5f9169c87f18918 /FS
parentbbdb9bc8f7fe69bb9b4fe4445f65479ef77f144e (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 671d16c92..18624e6c7 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -204,6 +204,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 abbbc8d13..6a5580a1d 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -56,18 +56,25 @@ $disable_agentcheck = 0;
$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 3192f2f16..da1f0ad33 100644
--- a/FS/FS/part_pkg/flat.pm
+++ b/FS/FS/part_pkg/flat.pm
@@ -134,8 +134,11 @@ sub calc_setup {
sub unit_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 {
@@ -185,7 +188,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 8a5fc35c9..aba3ead40 100644
--- a/FS/FS/part_svc.pm
+++ b/FS/FS/part_svc.pm
@@ -561,6 +561,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 ) = ( '', '' );