[freeside-commits] freeside/FS/FS cust_bill_pkg.pm, 1.56.2.5, 1.56.2.6
Ivan,,,
ivan at wavetail.420.am
Mon Nov 14 12:36:05 PST 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv6433
Modified Files:
Tag: FREESIDE_2_3_BRANCH
cust_bill_pkg.pm
Log Message:
optimize invoice rendering with lots of CDRs, RT#15155
Index: cust_bill_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg.pm,v
retrieving revision 1.56.2.5
retrieving revision 1.56.2.6
diff -u -w -d -r1.56.2.5 -r1.56.2.6
--- cust_bill_pkg.pm 14 Nov 2011 04:46:35 -0000 1.56.2.5
+++ cust_bill_pkg.pm 14 Nov 2011 20:36:03 -0000 1.56.2.6
@@ -826,11 +826,10 @@
sub usage {
my( $self, $classnum ) = @_;
my $sum = 0;
- my @values = ();
if ( $self->get('details') ) {
- @values =
+ foreach my $value (
map { ref($_) eq 'HASH'
? $_->{'amount'}
: $_->[2]
@@ -843,20 +842,26 @@
: 1
)
}
- @{ $self->get('details') };
+ @{ $self->get('details') }
+ ) {
+ $sum += $value if $value;
+ }
+
+ return $sum;
} else {
- my $hashref = { 'billpkgnum' => $self->billpkgnum };
- $hashref->{ 'classnum' } = $classnum if defined($classnum);
- @values = map { $_->amount } qsearch('cust_bill_pkg_detail', $hashref);
+ my $sql = 'SELECT SUM(COALESCE(amount,0)) FROM cust_bill_pkg_detail '.
+ ' WHERE billpkgnum = '. $self->billpkgnum;
+ $sql .= " AND classnum = $classnum" if defined($classnum);
- }
+ my $sth = dbh->prepare($sql) or die dbh->errstr;
+ $sth->execute or die $sth->errstr;
+
+ return $sth->fetchrow_arrayref->[0];
- foreach ( @values ) {
- $sum += $_ if $_;
}
- $sum;
+
}
=item usage_classes
More information about the freeside-commits
mailing list