[freeside-commits] branch master updated. c4c8512adc83e2c6e6640112735e887b71222e1d
Ivan
ivan at 420.am
Thu Jan 28 16:23:39 PST 2016
The branch, master has been updated
via c4c8512adc83e2c6e6640112735e887b71222e1d (commit)
from 5ff16520adf5c564a053875165418fe32abf1a5c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c4c8512adc83e2c6e6640112735e887b71222e1d
Author: Ivan Kohler <ivan at freeside.biz>
Date: Thu Jan 28 16:23:38 2016 -0800
optimize Reports->Customers->List Customers, RT#20173
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index cb7d036..a117b74 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 c507a45..6dcd740 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 d11b99b..b82303c 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 08003dd..612c590 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 ) = ( '', '' );
diff --git a/httemplate/search/cust_main.cgi b/httemplate/search/cust_main.cgi
index 4811407..d2a797c 100755
--- a/httemplate/search/cust_main.cgi
+++ b/httemplate/search/cust_main.cgi
@@ -119,9 +119,11 @@
% foreach my $cust_pkg ( @{$all_pkgs{$custnum}} ) {
% my %cust_svc_by_svcpart;
% my $rows = 0;
-% foreach my $part_svc ( $cust_pkg->part_svc ) {
+% foreach my $part_svc (
+% $cust_pkg->part_svc( summarize_size=>$large_pkg_size )
+% ) {
% my $svcpart = $part_svc->svcpart;
-% my $num_cust_svc = $cust_pkg->num_cust_svc($svcpart);
+% my $num_cust_svc = $part_svc->num_cust_svc;
% if ( $large_pkg_size > 0 and $num_cust_svc >= $large_pkg_size ) {
% # don't retrieve the cust_svc records, just stash the
% # part_svc and num_cust_svc for later
@@ -130,7 +132,7 @@
% $rows += 2;
% }
% elsif ( $num_cust_svc ) {
-% $cust_svc_by_svcpart{$svcpart} = [ $cust_pkg->cust_svc($svcpart) ];
+% $cust_svc_by_svcpart{$svcpart} = $part_svc->cust_pkg_svc;
% $rows += $num_cust_svc;
% } #if summarize
% } #foreach $part_svc
@@ -479,7 +481,7 @@ if ( $cgi->param('browse')
);
}
- @cust_main = grep { $_->ncancelled_pkgs || ! $_->all_pkgs } @cust_main
+ @cust_main = grep { $_->num_ncancelled_pkgs || ! $_->num_pkgs } @cust_main
if ! $cgi->param('cancelled')
&& (
$cgi->param('showcancelledcustomers') eq '0' #see if it was set by me
@@ -491,12 +493,30 @@ if ( $cgi->param('browse')
@cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
}
-my %all_pkgs;
-if ( $conf->exists('hidecancelledpackages' ) ) {
- %all_pkgs = map { $_->custnum => [ $_->ncancelled_pkgs ] } @cust_main;
-} else {
- %all_pkgs = map { $_->custnum => [ $_->all_pkgs ] } @cust_main;
-}
+my $pkgs_method = $conf->exists('hidecancelledpackages')
+ ? 'ncancelled_pkgs'
+ : 'all_pkgs';
+
+#false laziness w/httemplate/view/cust_main/packages.html
+my $select = '*, setup_option.optionvalue AS _opt_setup_fee, '.
+ 'recur_option.optionvalue AS _opt_recur_fee',
+my $addl_from = qq{
+ LEFT JOIN part_pkg USING ( pkgpart )
+ LEFT JOIN part_pkg_option AS setup_option
+ ON ( cust_pkg.pkgpart = setup_option.pkgpart
+ AND setup_option.optionname = 'setup_fee' )
+ LEFT JOIN part_pkg_option AS recur_option
+ ON ( cust_pkg.pkgpart = recur_option.pkgpart
+ AND recur_option.optionname = 'recur_fee' )
+};
+
+my %all_pkgs = map { $_->custnum =>
+ [ $_->$pkgs_method({ select => $select,
+ addl_from => $addl_from,
+ })
+ ];
+ }
+ @cust_main;
sub last_sort {
lc($a->getfield('last')) cmp lc($b->getfield('last'))
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Record.pm | 1 +
FS/FS/cust_pkg.pm | 25 +++++++++++++++---------
FS/FS/part_pkg/flat.pm | 13 ++++++++++---
FS/FS/part_svc.pm | 3 +++
httemplate/search/cust_main.cgi | 40 +++++++++++++++++++++++++++++----------
5 files changed, 60 insertions(+), 22 deletions(-)
More information about the freeside-commits
mailing list