示例#1
0
 /**
  * Gets the number of sharers allowed.
  *
  * Method which returns the number of sharers that are permitted
  * given a specified cover amount.
  *
  * @param Zend_Currency $coverAmount
  * The main cover amount on the TCI+ policy.
  *
  * @return integer
  * Returns the number of sharers allowed on the $coverAmount given.
  */
 public function getNoOfSharersAllowed($coverAmount)
 {
     $params = Zend_Registry::get('params');
     //Read in the lower contents bands.
     $bandLower = array();
     $bandLower[] = new Zend_Currency(array('value' => $params->sharers->band0->lower, 'precision' => 0));
     $bandLower[] = new Zend_Currency(array('value' => $params->sharers->band1->lower, 'precision' => 0));
     $bandLower[] = new Zend_Currency(array('value' => $params->sharers->band2->lower, 'precision' => 0));
     $bandLower[] = new Zend_Currency(array('value' => $params->sharers->band3->lower, 'precision' => 0));
     //Read in the upper contents bands.
     $bandUpper = array();
     $bandUpper[] = new Zend_Currency(array('value' => $params->sharers->band0->upper, 'precision' => 0));
     $bandUpper[] = new Zend_Currency(array('value' => $params->sharers->band1->upper, 'precision' => 0));
     $bandUpper[] = new Zend_Currency(array('value' => $params->sharers->band2->upper, 'precision' => 0));
     $bandUpper[] = new Zend_Currency(array('value' => $params->sharers->band3->upper, 'precision' => 0));
     $numberPermitted = array();
     $numberPermitted[] = $params->sharers->numberPermitted->band0;
     $numberPermitted[] = $params->sharers->numberPermitted->band1;
     $numberPermitted[] = $params->sharers->numberPermitted->band2;
     $numberPermitted[] = $params->sharers->numberPermitted->band3;
     //Zero sharers by default until the cover amount is understood.
     $returnVal = 0;
     for ($i = 0; $i < count($bandLower); $i++) {
         $bandFound = false;
         if ($coverAmount->isMore($bandLower[$i]) && $coverAmount->isLess($bandUpper[$i])) {
             $bandFound = true;
         } else {
             if ($coverAmount->equals($bandLower[$i]) || $coverAmount->equals($bandUpper[$i])) {
                 $bandFound = true;
             }
         }
         if ($bandFound) {
             $returnVal = $numberPermitted[$i];
             break;
         }
     }
     return $returnVal;
 }
示例#2
0
 /**
  * Identifies if the previous claims will force a referral.
  * 
  * @param string $refNo
  * The unique legacy customer reference number.
  * 
  * @return mixed
  * Returns an array of referral reasons. If there are no referral reasons,
  * then will return null.
  */
 protected function _checkPreviousClaims($refNo)
 {
     $previousClaimsReferralReasons = array();
     if (empty($this->_previousClaimsModel)) {
         $this->_previousClaimsModel = new Datasource_Insurance_PreviousClaims();
     }
     $previousClaimsArray = $this->_previousClaimsModel->getPreviousClaims($refNo);
     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->portfolio->claimsThreshold, 'precision' => 2));
         if ($claimsTotal->isMore($claimsThreshold)) {
             $previousClaimsReferralReasons[] = $params->uw->rr->portfolio->previousClaims;
         }
     }
     //Return the results consistent with this method's contract.
     if (empty($previousClaimsReferralReasons)) {
         $returnVal = null;
     } else {
         $returnVal = $previousClaimsReferralReasons;
     }
     return $returnVal;
 }
示例#3
0
 /**
  * IsMore values
  */
 public function testIsMoreValues()
 {
     $currency = new Zend_Currency(array('currency' => 'EUR', 'locale' => 'de_AT', 'value' => 100));
     $currency2 = new Zend_Currency(array('currency' => 'EUR', 'locale' => 'de_AT', 'value' => 100));
     $this->assertFalse($currency->isMore($currency2));
     $currency3 = new Zend_Currency(array('currency' => 'EUR', 'locale' => 'de_AT', 'value' => 99));
     $this->assertTrue($currency->isMore($currency3));
 }
示例#4
0
 /**
  * Identifies if the previous claims will force a referral.
  * 
  * @param string $refNo
  * The unique legacy customer reference number.
  * 
  * @return mixed
  * Returns an array of referral reasons. If there are no referral reasons,
  * then will return null.
  */
 protected function _checkPreviousClaims($quoteId)
 {
     $params = Zend_Registry::get('params');
     $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($quoteId);
     $refNo = $quoteManager->getLegacyCustomerReference();
     //Identify if buildings/contents cover is applicable for this policy, and if yes then
     //retrieve the excess values.
     $productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER);
     if (!empty($productMeta)) {
         $isBuildingsCoverApplicable = true;
         $buildingsExcess = new Zend_Currency(array('value' => $productMeta['excess'], 'precision' => 2));
     } else {
         $isBuildingsCoverApplicable = false;
     }
     $productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER);
     if (!empty($productMeta)) {
         $isContentsCoverApplicable = true;
         $contentsExcess = new Zend_Currency(array('value' => $productMeta['excess'], 'precision' => 2));
     } else {
         $isContentsCoverApplicable = false;
     }
     $previousClaimsReferralReasons = array();
     //Retrieve the previous claims details, if any.
     if (empty($this->_previousClaimsModel)) {
         $this->_previousClaimsModel = new Datasource_Insurance_PreviousClaims();
     }
     $previousClaimsArray = $this->_previousClaimsModel->getPreviousClaims($refNo);
     if (empty($previousClaimsArray)) {
         return null;
     }
     //First test to see if the total value of previous claims exceed the threshold.
     $claimsTotal = new Zend_Currency(array('value' => 0, 'precision' => 2));
     foreach ($previousClaimsArray as $previousClaim) {
         $claimsTotal->add($previousClaim->getClaimValue());
     }
     $claimsThreshold = new Zend_Currency(array('value' => $params->uw->rt->landlordsp->claimsThreshold, 'precision' => 2));
     if ($claimsTotal->isMore($claimsThreshold)) {
         $previousClaimsReferralReasons[] = $params->uw->rr->landlordsp->claimsThreshold;
     }
     //Next text for multiple claims of the same type.
     $claimTypeIds = array();
     $matchFound = false;
     foreach ($previousClaimsArray as $previousClaim) {
         if (empty($claimTypeIds)) {
             $claimTypeIds[] = $previousClaim->getClaimType()->getClaimTypeID();
             continue;
         }
         //Compare the current ID against the other ids.
         foreach ($claimTypeIds as $currentId) {
             if ($currentId == $previousClaim->getClaimType()->getClaimTypeID()) {
                 $matchFound = true;
                 break;
             }
         }
         if ($matchFound) {
             //More than one type of claim of the same loss, so this will need referral.
             $previousClaimsReferralReasons[] = $params->uw->rr->landlordsp->multipleSameTypeClaim;
             break;
         }
     }
     //Next test for more than one claim, and £0 or £100 excess requested.
     $excessAmountsWhichRefer = $params->uw->rt->landlordsp->excessAmounts->toArray();
     if (count($previousClaimsArray) > 1) {
         if ($isBuildingsCoverApplicable) {
             foreach ($excessAmountsWhichRefer as $excessAmount) {
                 if ($buildingsExcess->compare($excessAmount) == 0) {
                     $previousClaimsReferralReasons[] = $params->uw->rr->landlordsp->buildings->excessReduction;
                     break;
                 }
             }
         }
         if ($isContentsCoverApplicable) {
             foreach ($excessAmountsWhichRefer as $excessAmount) {
                 if ($contentsExcess->compare($excessAmount) == 0) {
                     $previousClaimsReferralReasons[] = $params->uw->rr->landlordsp->contents->excessReduction;
                     break;
                 }
             }
         }
     }
     //Return the results consistent with this method's contract.
     if (empty($previousClaimsReferralReasons)) {
         $returnVal = null;
     } else {
         $returnVal = $previousClaimsReferralReasons;
     }
     return $returnVal;
 }
示例#5
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;
 }