X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-cdrrated;h=1333240ec9938962fbbc8726b07e417e2abda804;hb=58323c34f3dd367739d9b3c4c67e5b147f9fc882;hp=99ea675947e8bbfae2fcfa628c76f4fb7138e94f;hpb=c6782ab85ea83e0c78d85b8975985aac9d467f9d;p=freeside.git diff --git a/FS/bin/freeside-cdrrated b/FS/bin/freeside-cdrrated index 99ea67594..1333240ec 100644 --- a/FS/bin/freeside-cdrrated +++ b/FS/bin/freeside-cdrrated @@ -37,7 +37,7 @@ our %svcnum = (); # phonenum => svcnum our %pkgnum = (); # phonenum => pkgnum our %cust_pkg = (); # pkgnum => cust_pkg (NOT phonenum => cust_pkg!) our %pkgpart = (); # phonenum => pkgpart -our %part_pkg = (); # phonenum => part_pkg +our %part_pkg = (); # pkgpart => part_pkg #some false laziness w/freeside-cdrrewrited @@ -127,10 +127,12 @@ while (1) { } - #unless ( $part_pkg{$pkgpart{$number}} ) { - #} - - #XXX if $part_pkg->option('min_included') then we can't prerate this CDR + if ( $part_pkg{ $pkgpart{$number} }->option('min_included') ) { + #then we can't prerate this CDR + #some sort of warning? + # (sucks if you're depending on credit limit fraud warnings) + next; + } my $error = $cdr->rate( 'part_pkg' => $part_pkg{ $pkgpart{$number} }, @@ -141,6 +143,21 @@ while (1) { #XXX ??? warn $error; sleep 30; + } else { + + #this could get expensive on a per-call basis + # trigger in a separate process with less frequency? + + my $cust_main = $cust_pkg{ $pkgnum{$number} }->cust_main; + + my $error = $cust_main->check_credit_limit; + if ( $error ) { + #"should never happen" normally, but as a daemon, better to survive + # e.g. database going away and coming back and resume doing our thing + warn $error; + sleep 30; + } + } last if sigterm() || sigint();