/** * method to retrieve the subscriber instance * * @return Billrun_Subscriber */ public static function subscriber() { if (!self::$subscriber) { $subscriberSettings = self::config()->getConfigValue('subscriber', array()); self::$subscriber = Billrun_Subscriber::getInstance($subscriberSettings); } return self::$subscriber; }
/** * Updates the billrun costs, lines & breakdown with the input line if the line is not already included in it * @param string $billrun_key the billrun_key to insert into the billrun * @param array $counters keys - usage type. values - amount of usage. Currently supports only arrays of one element * @param array $pricingData the output array from updateSubscriberBalance function * @param Mongodloid_Entity $row the input line * @param boolean $vatable is the line vatable or not * @return Mongodloid_Entity the billrun doc of the line, false if no such billrun exists */ public function updateBillrun($billrun_key, $counters, $pricingData, $row, $vatable) { $sid = $row['sid']; $sraw = $this->getSubRawData($sid); if ($sraw) { // it could be that this sid hasn't been returned on active_subscribers... $this->addLineToSubscriber($counters, $row, $pricingData, $vatable, $billrun_key, $sraw); $this->updateCosts($pricingData, $row, $vatable, $sraw); $this->setSubRawData($sraw); } else { Billrun_Factory::log("Subscriber {$sid} is not active, yet has lines", Zend_log::ALERT); $subscriber_general_settings = Billrun_Config::getInstance()->getConfigValue('subscriber', array()); $null_subscriber_params = array('data' => array('aid' => $row['aid'], 'sid' => $sid, 'plan' => null, 'next_plan' => null)); $subscriber_settings = array_merge($subscriber_general_settings, $null_subscriber_params); $subscriber = Billrun_Subscriber::getInstance($subscriber_settings); $this->addSubscriber($subscriber, "closed"); $this->updateBillrun($billrun_key, $counters, $pricingData, $row, $vatable); } }