/** * 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; }
/** * Indicates if a matching endorsement exists in the database. * * Attempts to retrieve a specific endorsement recorded against the quote or * policy specified in the Model_Insurance_Endorsement object passed in. * Returns true or false to indicate this. * * @param Model_Insurance_Endorsement $endorsement * A Model_Insurance_Endorsement object containing all the endorsement information. * * @return boolean * Returns true if an endorsement has been applied, false otherwise. */ public function getEndorsement($endorsement) { $select = $this->select(); $select->where('policynumber = ?', $endorsement->getPolicyNumber()); $endorsementType = $endorsement->getEndorsementType(); $endorsementId = $endorsementType->getID(); $select->where('endID = ?', $endorsementId); $result = $this->fetchAll($select); if ($result->count() == 0) { // No warning given as this is a common/normal scenario return false; } return true; }
/** * 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; }