/** * Returns the endorsements required by a quote or policy. * * This method will identify the endorsements that should be applied to * the quote or policy identified by $policyNumber. If any endorsements are * identified, they will be detailed in one or more Model_Insurance_Endorsement * objects, which will then be returned in an array. If the quote / policy does * not merit any endorsements, then null will be returned. * * @param string $policyNumber * The quote or policy number. * * @return mixed * Returns an array of Model_Insurance_Endorsement objects, * or null if no endorsements are applicable. * * @todo * Not yet complete. */ public function getEndorsementsRequired($quoteID) { //Create a quote object from the $policyNumber $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($quoteID); $legacyQuoteId = $quoteManager->getModel()->legacyID; //Extract the postcode from the policyNumber $properties = $quoteManager->getProperties(); $postCode = $properties[0]['postcode']; //Extract the contents cover, if applicable. if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) { $contentsMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER); $contentsCover = $contentsMeta['cover_amount']; } else { $contentsCover = 0; } $params = Zend_Registry::get('params'); $returnArray = array(); //First check for flood endorsements. $termsDatasource = new Datasource_Insurance_LandlordsPlus_Terms(); $floodRiskScore = $termsDatasource->getFloodRiskScore($postCode); if ($floodRiskScore > 0) { //Mandatory/optional endorsement $endorsement = new Model_Insurance_Endorsement(); $endorsement->setPolicyNumber($legacyQuoteId); $endorsementType = new Model_Insurance_EndorsementType(); $endorsementType->setID($params->uw->ed->landlordsp->floodExclusion->id); $endorsementType->setName($params->uw->ed->landlordsp->floodExclusion->name); $endorsement->setEndorsementType($endorsementType); $endorsement->setEffectiveDate(new Zend_Date($quoteManager->getStartDate(), Zend_Date::ISO_8601)); $returnArray[] = $endorsement; } //Next check for subsidence endorsements. $subsidenceRiskScore = $termsDatasource->getSubsidenceRiskScore($postCode); if ($subsidenceRiskScore > 0) { //Mandatory endorsement $endorsement = new Model_Insurance_Endorsement(); $endorsement->setPolicyNumber($legacyQuoteId); $endorsementType = new Model_Insurance_EndorsementType(); $endorsementType->setID($params->uw->ed->landlordsp->subsidence->id); $endorsementType->setName($params->uw->ed->landlordsp->subsidence->name); $endorsement->setEndorsementType($endorsementType); $endorsement->setEffectiveDate(new Zend_Date($quoteManager->getStartDate(), Zend_Date::ISO_8601)); $returnArray[] = $endorsement; } //Next check for minimum standards of security. if ($contentsCover >= $params->uw->et->landlordsp->mandatory->contents) { //Mandatory endorsement $endorsement = new Model_Insurance_Endorsement(); $endorsement->setPolicyNumber($legacyQuoteId); $endorsementType = new Model_Insurance_EndorsementType(); $endorsementType->setID($params->uw->ed->landlordsp->minStandardProtection->id); $endorsementType->setName($params->uw->ed->landlordsp->minStandardProtection->name); $endorsement->setEndorsementType($endorsementType); $endorsement->setEffectiveDate(new Zend_Date($quoteManager->getStartDate(), Zend_Date::ISO_8601)); $returnArray[] = $endorsement; } //Provide a return value consistent with this methods contract. if (empty($returnArray)) { $returnVal = null; } else { $returnVal = $returnArray; } return $returnVal; }
/** * Checks the underwriting answers. */ protected function _checkAnswers($quoteId) { $params = Zend_Registry::get('params'); $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($quoteId); $policyNumber = $quoteManager->getLegacyID(); $property = $quoteManager->getProperties(); $postCode = $property[0]['postcode']; $referralReasons = array(); //Test 3: Answering the underwriting questions. $answersManager = new Manager_Insurance_Answers(); $answersArray = $answersManager->getUnderwritingAnswers($policyNumber); if (empty($answersArray)) { //You can't process for referral if no underwriting answers have first been provided. throw new Zend_Exception(get_class() . __FUNCTION__ . ": no underwriting answers provided."); } for ($i = 0; $i < count($answersArray); $i++) { $answerGiven = $answersArray[$i]->getAnswer(); $expectedAnswer = $answersArray[$i]->getExpectedAnswer(); $questionNumber = $answersArray[$i]->getQuestionNumber(); //Process questions 53, 60, 61 specially. if ($questionNumber == '53') { continue; } //Question 6 is dealt with specially. if ($questionNumber == '60') { if ($answerGiven == Model_Insurance_Answer::YES) { //Check the extra args. $underwritingTerms = new Datasource_Insurance_LandlordsPlus_Terms(); $subsidenceScore = $underwritingTerms->getSubsidenceRiskScore($postCode); if ($subsidenceScore == 0) { $referralReasons[] = $params->uw->rr->landlordsp->answer; } } continue; } if ($questionNumber == '61') { //Question 7 is the previous claims answer. The outcome of this is determiend by the //previous claims logic in the checkUwReferralState() method. continue; } //This is the referencing question. Some calls to this method may want this answer to //be ignored. if ($questionNumber == '64' && $this->_ignoreReferencingQuestion) { continue; } //All other questions should be processed here. if ($expectedAnswer == Model_Insurance_Answer::YES || $expectedAnswer == Model_Insurance_Answer::NO) { if ($answerGiven != $expectedAnswer) { print "HERE2 {$questionNumber}<BR>"; $referralReasons[] = $params->uw->rr->landlordsp->answer; } } } //Return the results consistent with this method's contract. if (empty($referralReasons)) { $returnVal = null; } else { $returnVal = $referralReasons; } return $returnVal; }