Пример #1
0
 /**
  * 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;
 }
Пример #2
0
 /**
  * Implements abstract method from superclass - refer to superclass for description.
  */
 public function getReferralReasons($policyNumber)
 {
     $referralReasons = array();
     $params = Zend_Registry::get('params');
     $quote = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $policyNumber);
     if ($quote->getPolicyName() == 'tenantsp') {
         //Test 1: If the cover is greater than the threshold, then refer.
         $contentsAmount = $quote->getPolicyOptionAmountCovered('contentstp');
         $contentsThreshold = new Zend_Currency(array('value' => $params->uw->rt->tenantsp->contents, 'precision' => 0));
         if ($contentsAmount >= $contentsThreshold) {
             $referralReasons[] = $params->uw->rr->tenantsp->cover;
         }
         //Test 2: If claim values are greater than 1000 then refer.
         if (empty($this->_previousClaimsModel)) {
             $this->_previousClaimsModel = new Datasource_Insurance_PreviousClaims();
         }
         $previousClaimsArray = $this->_previousClaimsModel->getPreviousClaims($quote->getRefno());
         if (!empty($previousClaimsArray)) {
             //Tenant has one or more claims. Add the totals together to see if they exceed
             //the threshold.
             $claimsTotal = new Zend_Currency(array('value' => 0, 'precision' => 2));
             foreach ($previousClaimsArray as $previousClaim) {
                 $claimsTotal->add($previousClaim->getClaimValue());
             }
             //Test against the previous claims threshold
             $claimsThreshold = new Zend_Currency(array('value' => $params->uw->rt->tenantsp->claimsThreshold, 'precision' => 2));
             if ($claimsTotal->isMore($claimsThreshold)) {
                 $referralReasons[] = $params->uw->rr->tenantsp->previousClaims;
             }
         }
         //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.");
         }
         foreach ($answersArray as $currentAnswer) {
             //Identify if the current answer is one that should be checked.
             if (in_array($currentAnswer->getQuestionNumber(), $params->uw->rt->tenantsp->checkAnswer->toArray())) {
                 $answer = $currentAnswer->getAnswer();
                 if ($answer == Model_Insurance_Answer::YES) {
                     $referralReasons[] = $params->uw->rr->tenantsp->answer;
                 }
             }
         }
         //Test 4: pedal cycles over 1500
         $pedalCyclesModel = new Datasource_Insurance_Policy_Cycles($quote->getRefno(), $policyNumber);
         $pedalCyclesArray = $pedalCyclesModel->listBikes();
         if (!empty($pedalCyclesArray)) {
             $pedalCycleThreshold = new Zend_Currency(array('value' => $params->uw->rt->tenantsp->pedalCycle, 'precision' => 2));
             foreach ($pedalCyclesArray as $currentPedalCycle) {
                 //Compare the pedal cycle values in Zend_Currency format for simplity.
                 $currentCycleValue = new Zend_Currency(array('value' => $currentPedalCycle['value'], 'precision' => 2));
                 if ($currentCycleValue->isMore($pedalCycleThreshold)) {
                     $referralReasons[] = $params->uw->rr->tenantsp->pedalCycle;
                 }
             }
         }
         //Test 5: specified possessions greater than threshold
         $specPossessionsModel = new Datasource_Insurance_Policy_SpecPossessions($policyNumber);
         $specPossessionsArray = $specPossessionsModel->listPossessions();
         if (!empty($specPossessionsArray)) {
             //Wrap the threshold parameter in a Zend_Currency object for easier comparisons.
             $specPossessionThreshold = new Zend_Currency(array('value' => $params->uw->rt->tenantsp->specPossession, 'precision' => 2));
             //Cycle through each specpossession...
             foreach ($specPossessionsArray as $currentSpecPossession) {
                 //Wrap the current specpossession value in a Zend_Currency for easier comparision.
                 $currentSpecPossessionValue = new Zend_Currency(array('value' => $currentSpecPossession['value'], 'precision' => 2));
                 //Determine if the threshold is exceeded:
                 if ($currentSpecPossessionValue->isMore($specPossessionThreshold)) {
                     $referralReasons[] = $params->uw->rr->tenantsp->specPossession;
                 }
             }
         }
     } else {
         throw new Zend_Exception("Invalid product.");
     }
     return $referralReasons;
 }