/** * Retrieves the specified reference subject. * * @param string $referenceSubjectId * The unique reference subject identifier. * * @param string $enquiryId * The unique external Enquiry identifier. * * @return mixed * The reference subject details encapsulated in a Model_Referencing_ReferenceSubject * object, or null if the reference subject cannot be found. */ public function getReferenceSubject($referenceSubjectId, $enquiryId) { if (empty($referenceSubjectId)) { return null; } $select = $this->select(); $select->where('ID = ?', $referenceSubjectId); $referenceSubjectRow = $this->fetchRow($select); if (empty($referenceSubjectRow)) { $returnVal = null; } else { $referenceSubject = new Model_Referencing_ReferenceSubject(); $referenceSubject->referenceId = $referenceSubjectRow->ID; //Load up the bank account details. $bankAccount = new Model_Referencing_BankAccount(); $bankAccount->referenceId = $referenceSubjectRow->ID; $bankAccount->accountNumber = $referenceSubjectRow->accountNo; $bankAccount->sortCode = $referenceSubjectRow->sortcodeNo; switch ($referenceSubjectRow->bankValidationCheckStatus) { case 'N/A': case 'No': case '': $bankAccount->isValidated = false; break; default: $bankAccount->isValidated = true; } $referenceSubject->bankAccount = $bankAccount; //Load the name details. $name = new Model_Core_Name(); $name->title = $referenceSubjectRow->title; $name->firstName = $referenceSubjectRow->firstname; $name->middleName = $referenceSubjectRow->middlename; $name->lastName = $referenceSubjectRow->lastname; $name->maidenName = $referenceSubjectRow->maidenname; $referenceSubject->name = $name; $contactDetails = new Model_Core_ContactDetails(); $contactDetails->telephone1 = $referenceSubjectRow->tel; $contactDetails->telephone2 = $referenceSubjectRow->mobile; $contactDetails->email1 = $referenceSubjectRow->email; $referenceSubject->contactDetails = $contactDetails; if ($referenceSubjectRow->dob != '0000-00-00') { $referenceSubject->dob = new Zend_Date($referenceSubjectRow->dob, Zend_Date::ISO_8601); } $enquiryDatasource = new Datasource_ReferencingLegacy_Enquiry(); if ($enquiryDatasource->getLegacyReferenceSubjectType($enquiryId) == Model_Referencing_ReferenceSubjectTypes::TENANT) { $referenceSubject->type = Model_Referencing_ReferenceSubjectTypes::TENANT; } else { $referenceSubject->type = Model_Referencing_ReferenceSubjectTypes::GUARANTOR; } $residenceDatasource = new Datasource_ReferencingLegacy_Residences(); $referenceSubject->residences = $residenceDatasource->getByEnquiry($enquiryId); $occupationDatasource = new Datasource_ReferencingLegacy_Occupations(); $referenceSubject->occupations = $occupationDatasource->getAllByEnquiry($enquiryId); if (!empty($referenceSubjectRow->hasCCJs)) { if ($referenceSubjectRow->hasCCJs == 'Yes') { $referenceSubject->hasAdverseCredit = true; } else { $referenceSubject->hasAdverseCredit = false; } } if ($referenceSubjectRow->RentShare >= 0) { $referenceSubject->shareOfRent = new Zend_Currency(array('value' => $referenceSubjectRow->RentShare, 'precision' => 0)); } $returnVal = $referenceSubject; } return $returnVal; }
protected function _pushToEmploymentMunt($reference) { $occupationDatasource = new Datasource_ReferencingLegacy_Occupations(); //If the reference subject is self employed and has a future employer, then the Munt only //recognizes the future employer and does not record the current.... $occupationManager = new Manager_Referencing_Occupation(); $currentOccupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::CURRENT, Model_Referencing_OccupationImportance::FIRST); $futureOccupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::FUTURE, Model_Referencing_OccupationImportance::FIRST); if ($currentOccupation->type == Model_Referencing_OccupationTypes::SELFEMPLOYMENT) { if (!empty($futureOccupation)) { if ($futureOccupation->type == Model_Referencing_OccupationTypes::EMPLOYMENT) { $occupationDatasource->insertOccupation($futureOccupation, $reference->externalId); return; } } } // Loop round the occupations. If the occupation is insertable, then // insert it. foreach ($reference->referenceSubject->occupations as $occupation) { switch ($occupation->type) { case Model_Referencing_OccupationTypes::EMPLOYMENT: case Model_Referencing_OccupationTypes::CONTRACT: case Model_Referencing_OccupationTypes::SELFEMPLOYMENT: case Model_Referencing_OccupationTypes::INDEPENDENT: case Model_Referencing_OccupationTypes::RETIREMENT: //Insert the occupation $occupationDatasource->insertOccupation($occupation, $reference->externalId); break; } } }