예제 #1
0
 /**
  * the singleton pattern
  *
  * @return SoEventManager_Controller_SoEvent
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
예제 #2
0
 public function getBanksByBankCode($bankCode)
 {
     try {
         $recordSet = Billing_Controller_Bank::getInstance()->getBanksByBankCode($bankCode);
         if (count($recordSet) == 0) {
             throw new Tinebase_Exception_Record_RecordNotFound('No bank accounts found for given code', 'NO_RESULT');
         }
         return array('state' => 'success', 'data' => $recordSet->toArray(), 'count' => count($data));
     } catch (Exception $e) {
         return array('state' => 'failure', 'errorcode' => $e->getCode(), 'data' => array(), 'count' => 0);
     }
 }
예제 #3
0
 public function isValid()
 {
     //return true;
     try {
         $bankCodeValid = Billing_Controller_Bank::getInstance()->isExistingBankCode($this->getBankCode());
         if (strlen($this->getBankCode()) == 8 && ctype_digit($this->getBankCode()) && strlen($this->getNumber()) > 0 && strlen($this->getNumber()) <= 10 && ctype_digit($this->getNumber())) {
             return true;
         }
     } catch (Exception $e) {
         return false;
     }
     return false;
 }
예제 #4
0
 public function generateSepaMandateForBankAccountUsage(Billing_Model_BankAccountUsage $usage)
 {
     // read full featured record from backend
     $usage = Billing_Controller_BankAccountUsage::getInstance()->get($usage->getId());
     $sepaMandate = $usage->getForeignRecordBreakNull('sepa_mandate_id', $this);
     if (!$sepaMandate || is_object($sepaMandate && $sepaMandate->__get('is_deleted'))) {
         $bank = $usage->getForeignRecord('bank_id', Billing_Controller_Bank::getInstance());
         $bankAccount = $usage->getForeignRecord('bank_account_id', Billing_Controller_BankAccount::getInstance());
         $sepaMandateIdent = $bankAccount->getForeignId('contact_id');
         $sepaMandate = $this->getByMandateIDBreakNull($sepaMandateIdent);
         //var_dump($sepaMandate);
         if (is_null($sepaMandate)) {
             //echo "create new...";
             $sepaMandate = new Billing_Model_SepaMandate();
             $sepaMandate->__set('contact_id', $bankAccount->getForeignId('contact_id'));
             $sepaMandate->__set('bank_account_id', $bankAccount->getId());
             $sepaCreditors = Billing_Controller_SepaCreditor::getInstance()->getAll();
             $sepaCreditor = $sepaCreditors->getFirstRecord();
             $sepaMandate->__set('sepa_creditor_id', $sepaCreditor->getId());
             $sepaMandate->__set('mandate_ident', $sepaMandateIdent);
             $sepaMandate->__set('is_single', false);
             $sepaMandate = $this->create($sepaMandate);
         } else {
             //echo "double...";
             if ($sepaMandate->getForeignId('bank_account_id') != $bankAccount->getId()) {
                 //echo "create...";
                 $sepaMandateIdent .= '-BA' . $bankAccount->getId();
                 $sepaMandate = new Billing_Model_SepaMandate();
                 $sepaMandate->__set('contact_id', $bankAccount->getForeignId('contact_id'));
                 $sepaMandate->__set('bank_account_id', $bankAccount->getId());
                 $sepaCreditors = Billing_Controller_SepaCreditor::getInstance()->getAll();
                 $sepaCreditor = $sepaCreditors->getFirstRecord();
                 $sepaMandate->__set('sepa_creditor_id', $sepaCreditor->getId());
                 $sepaMandate->__set('mandate_ident', $sepaMandateIdent);
                 $sepaMandate->__set('is_single', false);
                 $sepaMandate = $this->create($sepaMandate);
             }
         }
     }
     $usage->__set('sepa_mandate_id', $sepaMandate->getId());
     //echo "set usage sepa mandate:". $sepaMandate->getId();
     Billing_Controller_BankAccountUsage::getInstance()->update($usage);
 }
예제 #5
0
 /**
  * import contacts
  *
  * @param Zend_Console_Getopt $_opts
  */
 public function importBanks($_opts)
 {
     set_time_limit(0);
     parent::_import($_opts, Billing_Controller_Bank::getInstance());
 }