/** * Creates and saves a flat line to the db * @param Billrun_Subscriber $subscriber the subscriber to create a flat line to * @param string $billrun_key the billrun for which to add the flat line * @return array the inserted line or the old one if it already exists */ protected function saveFlatLine($subscriber, $billrun_key) { $flat_entry = $subscriber->getFlatEntry($billrun_key); try { $this->lines->insert($flat_entry, array("w" => 1)); } catch (Exception $e) { if ($e->getCode() == 11000) { Billrun_Factory::log("Flat line already exists for subscriber " . $subscriber->sid . " for billrun " . $billrun_key, Zend_log::ALERT); } else { Billrun_Factory::log("Problem inserting flat line for subscriber " . $subscriber->sid . " for billrun " . $billrun_key . ". error message: " . $e->getMessage() . ". error code: " . $e->getCode(), Zend_log::ALERT); } } return new Mongodloid_Entity($flat_entry); }
/** * create and save credit lines * @param type $subscriber * @param type $billrun_key * @return array of inserted lines */ protected function saveCreditLines($subscriber, $billrun_key) { $credits = $subscriber->getCredits($billrun_key, true); $ret = array(); foreach ($credits as $credit) { $rawData = $credit->getRawData(); try { $this->lines->insert($rawData, array("w" => 1)); } catch (Exception $e) { if ($e->getCode() == 11000) { Billrun_Factory::log("Credit already exists for subscriber " . $subscriber->sid . " for billrun " . $billrun_key . " credit details: " . print_R($rawData, 1), Zend_log::ALERT); } else { Billrun_Factory::log("Problem inserting credit for subscriber " . $subscriber->sid . " for billrun " . $billrun_key . ". error message: " . $e->getMessage() . ". error code: " . $e->getCode() . ". credit details:" . print_R($rawData, 1), Zend_log::ALERT); Billrun_Util::logFailedCreditRow($rawData); } } $ret[$credit['stamp']] = $credit; } return $ret; }