/**
  * Compare values
  */
 public function testCompareValues()
 {
     $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->assertEquals(0, $currency->compare($currency2));
     $currency3 = new Zend_Currency(array('currency' => 'EUR', 'locale' => 'de_AT', 'value' => 101));
     $this->assertEquals(-1, $currency->compare($currency3));
     $currency4 = new Zend_Currency(array('currency' => 'EUR', 'locale' => 'de_AT', 'value' => 99));
     $this->assertEquals(1, $currency->compare($currency4));
 }
 /**
  * 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;
 }