/** * 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. */ public function getEndorsementsRequired($policyNumber) { $params = Zend_Registry::get('params'); $returnArray = array(); $quote = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $policyNumber); if ($quote->getPolicyName() == 'tenantsp') { //As a TCI+ policy, this will automatically require a student sharer endorsement $endorsement = new Model_Insurance_Endorsement(); $endorsement->setPolicyNumber($policyNumber); $endorsementType = new Model_Insurance_EndorsementType(); $endorsementType->setID($params->uw->ed->tenantsp->studentSharer->id); $endorsementType->setName($params->uw->ed->tenantsp->studentSharer->name); $endorsement->setEndorsementType($endorsementType); $endorsement->setEffectiveDate(new Zend_Date($quote->getStartDate(), Zend_Date::ISO_8601)); $returnArray[] = $endorsement; //Check if minimum standards of protection endorsement is required. $mspEndorsementRequired = false; $contentsAmountCovered = $quote->getPolicyOptionAmountCovered('contentstp'); $mspEndorsementThreshold = new Zend_Currency(array('value' => $params->uw->et->tenantsp->mandatory->contents, 'precision' => 0)); if ($contentsAmountCovered->isMore($mspEndorsementThreshold)) { $mspEndorsementRequired = true; } else { //MSP endorsements are also required if the applicant lives in a 'security' postcode. if ($quote->getIsHighRisk() == $params->uw->et->tenantsp->mandatory->highRiskFlag) { $mspEndorsementRequired = true; } } if ($mspEndorsementRequired) { $endorsement = new Model_Insurance_Endorsement(); $endorsement->setPolicyNumber($policyNumber); $endorsementType = new Model_Insurance_EndorsementType(); $endorsementType->setID($params->uw->ed->tenantsp->minStandardProtection->id); $endorsementType->setName($params->uw->ed->tenantsp->minStandardProtection->name); $endorsement->setEndorsementType($endorsementType); $endorsement->setEffectiveDate(new Zend_Date($quote->getStartDate(), Zend_Date::ISO_8601)); $returnArray[] = $endorsement; } } else { //This method has been used on a quote/policy that is not TenantsContentsPlus. Throw //an exception. throw new Zend_Exception(get_class() . '::' . __FUNCTION__ . ': unknown product.'); } //Provide a return value consistent with this methods contract. if (empty($returnArray)) { $returnVal = null; } else { $returnVal = $returnArray; } return $returnVal; }
/** * Returns all the endorsement types. * * This method reads in all the endorsement types recognised by the * system and populates each one into an EndorsementType object. An * array of these objects will then be returned. * * @return array * An array of EndorsementType objects, each one encapsulating a valid endorsement * type. */ public function getEndorsementTypes() { $select = $this->select(); $endorsements = $this->fetchAll($select); if (count($endorsements) > 0) { //Populate the data retrieved into PreviousClaimType objects. $returnArray = array(); foreach ($endorsements as $currentEndorsement) { $endorsementType = new Model_Insurance_EndorsementType(); $endorsementType->setID($currentEndorsement['endID']); $endorsementType->setName($currentEndorsement['name']); $endorsementType->setDescription($currentEndorsement['text']); $returnArray[] = $endorsementType; } return $returnArray; } else { // Can't get previous claim types - log a warning Application_Core_Logger::log("Can't get endorsement types from table {$this->_name}", 'warning'); } }
/** * 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; }