/** * the singleton pattern * * @return SoEventManager_Controller_SoEvent */ public static function getInstance() { if (self::$_instance === NULL) { self::$_instance = new self(); } return self::$_instance; }
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); }
public function saveSepaCreditor($recordData) { return $this->_save($recordData, Billing_Controller_SepaCreditor::getInstance(), 'SepaCreditor'); }
private function createNewSepa(&$creditor) { $this->openSepaContainer(); $sepa = \worg\wsf\sepa\app\PaymentSEPA::createDebitTransferCore(); $sepa->setSchemaFiles(array(realpath(CSopen::instance()->getLibPath() . 'wsflib/worg/wsf/sepa/schema/pain.008.002.02.xsd'))); // get sepa creditor $sepaCreditors = Billing_Controller_SepaCreditor::getInstance()->getAll(); $sepaCreditor = $sepaCreditors->getFirstRecord(); $creditor = \worg\wsf\sepa\app\Creditor::create()->setIBAN($sepaCreditor->getIBAN())->setBIC($sepaCreditor->getBIC())->setName(\worg\wsf\util\format\Umlaut::convert($sepaCreditor->getName()))->setSEPAIdent($sepaCreditor->getSepaCreditorIdent()); $sepa->getGroupHeader()->setMessageId(\worg\wsf\sepa\app\PaymentSEPA::getIdProvider()->getNewGroupHeaderMessageId())->setCreationDateTime(strftime("%Y-%m-%dT%H:%M:%S"))->setPartyIdentificationName(\worg\wsf\util\format\Umlaut::convert($creditor->getName())); return $sepa; }