X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FClientAPI%2FPrepaidPhone.pm;h=2cea3c23184be09747ea0d3e9e8556d318c2570a;hb=8b8d621a1bb4e9abaa1f0edab5190d302e6a6e99;hp=b05fb4fe4c8ef45b78e9a03375a3cde41c1389e6;hpb=04c1a98c9bcf2b6f0da8f18b627eec703dbafd49;p=freeside.git diff --git a/FS/FS/ClientAPI/PrepaidPhone.pm b/FS/FS/ClientAPI/PrepaidPhone.pm index b05fb4fe4..2cea3c231 100644 --- a/FS/FS/ClientAPI/PrepaidPhone.pm +++ b/FS/FS/ClientAPI/PrepaidPhone.pm @@ -307,14 +307,8 @@ sub prepaid_phone_balance { foreach my $cust_svc ( @cust_svc ) { my $svc_x = $cust_svc->svc_x; - - #XXX optimization: a single SQL query to return the total amount - my $cdr_search = $svc_x->psearch_cdrs(%options); - $cdr_search->limit(1000); - $cdr_search->increment(0); - while ( my $cdr = $cdr_search->fetch ) { - $balance -= $cdr->rated_price; - } + my $sum_cdr = $svc_x->sum_cdrs(%options); + $balance += $sum_cdr->rated_price; }