/**
  * 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;
 }
Exemple #2
0
echo $this->translate('online-shop.back-office.order.order-items');
?>
</th>
        <th></th>
        <th width="100"><?php 
echo $this->translate('online-shop.back-office.order.price.total');
?>
</th>
    </tr>
    </thead>
    <tbody>
    <?php 
$totalSum = new Zend_Currency(OnlineShop_Framework_Factory::getInstance()->getEnvironment()->getCurrencyLocale());
foreach ($paginator as $item) {
    /* @var \OnlineShop\Framework\OrderManager\IOrderListItem $item */
    $totalSum->add($item->getTotalPrice());
    ?>
        <tr>
            <td>
                <?php 
    $urlDetail = $this->url(['action' => 'detail', 'controller' => 'admin-order', 'module' => 'OnlineShop', 'id' => $item->getOrderId()], null, true);
    ?>
                <a href="<?php 
    echo $urlDetail;
    ?>
"><?php 
    echo $item->getOrderNumber();
    ?>
</a>
            </td>
            <td>
 /**
  * Modulo values
  */
 public function testModValues()
 {
     $currency = new Zend_Currency(array('currency' => 'EUR', 'locale' => 'de_AT'));
     $currency->add(801);
     $currency->mod(2);
     $this->assertEquals('€ 1,00', $currency->toCurrency());
 }
 /**
  * Displays the reference summary details page as a popup.
  */
 public function summaryDialogAction()
 {
     $this->_helper->getHelper('layout')->disableLayout();
     $session = new Zend_Session_Namespace('referencing_global');
     $referenceManager = new Manager_Referencing_Reference();
     $reference = $referenceManager->getReference($session->referenceId);
     //Prepare the prospective landlord details.
     $prospectiveLandlord = $reference->propertyLease->prospectiveLandlord;
     $pllArray = array();
     $pllArray['name'] = $prospectiveLandlord->name->firstName . ' ' . $prospectiveLandlord->name->lastName;
     $pllArray['contactName'] = '';
     $pllArray['address'] = $prospectiveLandlord->address->addressLine1 . ' ' . $prospectiveLandlord->address->addressLine2 . ' ' . $prospectiveLandlord->address->town;
     $pllArray['postCode'] = $prospectiveLandlord->address->postCode;
     $pllArray['telephone'] = $prospectiveLandlord->contactDetails->telephone1;
     $pllArray['mobile'] = $prospectiveLandlord->contactDetails->telephone2;
     $pllArray['email'] = $prospectiveLandlord->contactDetails->email1;
     $this->view->prospectiveLandlord = $pllArray;
     //Prepare the property details.
     $propertyArray = array();
     $propertyArray['address'] = $reference->propertyLease->address->addressLine1 . ' ' . $reference->propertyLease->address->addressLine2 . ' ' . $reference->propertyLease->address->town;
     $propertyArray['postCode'] = $reference->propertyLease->address->postCode;
     $propertyArray['rent'] = $reference->propertyLease->rentPerMonth->getValue();
     $propertyArray['startDate'] = $reference->propertyLease->tenancyStartDate->toString();
     $propertyArray['duration'] = $reference->propertyLease->tenancyTerm;
     $propertyArray['noOfTenants'] = $reference->propertyLease->noOfTenants;
     $this->view->property = $propertyArray;
     //Prepare the reference subject details
     $referenceSubject = $reference->referenceSubject;
     $referenceSubjectArray = array();
     $referenceSubjectArray['name'] = $referenceSubject->name->firstName . ' ' . $referenceSubject->name->lastName;
     $referenceSubjectArray['maidenName'] = $referenceSubject->name->maidenName;
     $referenceSubjectArray['dob'] = $referenceSubject->dob->toString();
     if (!empty($referenceSubject->bankAccount)) {
         $referenceSubjectArray['bankAccountNumber'] = $referenceSubject->bankAccount->accountNumber;
         $referenceSubjectArray['bankSortCode'] = $referenceSubject->bankAccount->sortCode;
     } else {
         $referenceSubjectArray['bankAccountNumber'] = '';
         $referenceSubjectArray['bankSortCode'] = '';
     }
     $referenceSubjectArray['telephone'] = $referenceSubject->contactDetails->telephone1;
     $referenceSubjectArray['mobile'] = $referenceSubject->contactDetails->telephone2;
     $referenceSubjectArray['email'] = $referenceSubject->contactDetails->email1;
     $residenceManager = new Manager_Referencing_Residence();
     $residence = $residenceManager->findSpecificResidence($reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::CURRENT);
     $referenceSubjectArray['currentResidentialStatus'] = Model_Referencing_ResidenceStatus::toString($residence->status);
     $occupationManager = new Manager_Referencing_Occupation();
     $occupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::CURRENT, Model_Referencing_OccupationImportance::FIRST);
     //Convert the occupation type to an 'occupation status' for display purposes.
     switch ($occupation->type) {
         case Model_Referencing_OccupationTypes::EMPLOYMENT:
             $occupationStatus = 'Employed';
             break;
         case Model_Referencing_OccupationTypes::CONTRACT:
             $occupationStatus = 'On Contract';
             break;
         case Model_Referencing_OccupationTypes::SELFEMPLOYMENT:
             $occupationStatus = 'Self Employed';
             break;
         case Model_Referencing_OccupationTypes::INDEPENDENT:
             $occupationStatus = 'Financially Independent';
             break;
         case Model_Referencing_OccupationTypes::RETIREMENT:
             $occupationStatus = 'Retired';
             break;
         case Model_Referencing_OccupationTypes::STUDENT:
             $occupationStatus = 'Student';
             break;
         case Model_Referencing_OccupationTypes::UNEMPLOYMENT:
             $occupationStatus = 'Unemployed';
             break;
         case Model_Referencing_OccupationTypes::OTHER:
             $occupationStatus = 'Other';
             break;
         default:
             throw new Zend_Exception(get_class() . '::' . __FUNCTION__ . ': unknonwn type provided.');
     }
     $referenceSubjectArray['currentOccupationStatus'] = $occupationStatus;
     $referenceSubjectArray['isOccupationLikelyToChange'] = $occupation->isPermanent ? 'No' : 'Yes';
     //Calculate the total income.
     $totalIncome = new Zend_Currency(array('value' => 0, 'precision' => 0));
     foreach ($reference->referenceSubject->occupations as $occupation) {
         $totalIncome->add($occupation->income);
     }
     $referenceSubjectArray['income'] = $totalIncome->getValue();
     $referenceSubjectArray['shareOfRent'] = $referenceSubject->shareOfRent->getValue();
     $this->view->referenceSubject = $referenceSubjectArray;
     //Prepare the current landlord details.
     $currentResidence = $residenceManager->findSpecificResidence($reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::CURRENT);
     $currentLandlordArray = array();
     if (!empty($currentResidence->refereeDetails)) {
         $currentLandlordArray['name'] = $currentResidence->refereeDetails->name->firstName . ' ' . $currentResidence->refereeDetails->name->lastName;
         $currentLandlordArray['address'] = $currentResidence->refereeDetails->address->addressLine1 . ' ' . $currentResidence->refereeDetails->address->addressLine2 . ' ' . $currentResidence->refereeDetails->address->town;
         $currentLandlordArray['postCode'] = $currentResidence->refereeDetails->address->postCode;
         $currentLandlordArray['telephoneDay'] = $currentResidence->refereeDetails->contactDetails->telephone1;
         $currentLandlordArray['telephoneEvening'] = $currentResidence->refereeDetails->contactDetails->telephone2;
         $currentLandlordArray['fax'] = $currentResidence->refereeDetails->contactDetails->fax1;
         $currentLandlordArray['email'] = $currentResidence->refereeDetails->contactDetails->email1;
     } else {
         $currentLandlordArray['name'] = '';
         $currentLandlordArray['address'] = '';
         $currentLandlordArray['postCode'] = '';
         $currentLandlordArray['telephoneDay'] = '';
         $currentLandlordArray['telephoneEvening'] = '';
         $currentLandlordArray['fax'] = '';
         $currentLandlordArray['email'] = '';
     }
     $this->view->currentLandlord = $currentLandlordArray;
     //Prepare the occupation details.
     for ($i = 0; $i < 2; $i++) {
         switch ($i) {
             case 0:
                 $thisOccupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::CURRENT, Model_Referencing_OccupationImportance::FIRST);
                 break;
             case 1:
                 $thisOccupation = $occupationManager->findSpecificOccupation($reference->referenceSubject->occupations, Model_Referencing_OccupationChronology::FUTURE, Model_Referencing_OccupationImportance::FIRST);
                 break;
         }
         $thisOccupationArray = array();
         if (empty($thisOccupation)) {
             $thisOccupationArray['organisationName'] = '';
             $thisOccupationArray['contactName'] = '';
             $thisOccupationArray['contactPosition'] = '';
             $thisOccupationArray['oranisationAddress'] = '';
             $thisOccupationArray['postCode'] = '';
             $thisOccupationArray['telephone'] = '';
             $thisOccupationArray['fax'] = '';
             $thisOccupationArray['email'] = '';
             $thisOccupationArray['salary'] = '';
             $thisOccupationArray['positionHeld'] = '';
             $thisOccupationArray['payrollNumber'] = '';
             $thisOccupationArray['startDate'] = '';
             $thisOccupationArray['endDate'] = '';
             $thisOccupationArray['isPermanent'] = '';
         } else {
             if (!empty($thisOccupation->refereeDetails)) {
                 $thisOccupationArray['organisationName'] = $thisOccupation->refereeDetails->organisationName;
                 $thisOccupationArray['contactName'] = $thisOccupation->refereeDetails->name->firstName . ' ' . $thisOccupation->refereeDetails->name->lastName;
                 $thisOccupationArray['contactPosition'] = $thisOccupation->refereeDetails->position;
                 $thisOccupationArray['oranisationAddress'] = $thisOccupation->refereeDetails->address->addressLine1 . ' ' . $thisOccupation->refereeDetails->address->addressLine2 . ' ' . $thisOccupation->refereeDetails->address->town;
                 $thisOccupationArray['postCode'] = $thisOccupation->refereeDetails->address->postCode;
                 $thisOccupationArray['telephone'] = $thisOccupation->refereeDetails->contactDetails->telephone1;
                 $thisOccupationArray['fax'] = $thisOccupation->refereeDetails->contactDetails->fax1;
                 $thisOccupationArray['email'] = $thisOccupation->refereeDetails->contactDetails->email1;
             } else {
                 $thisOccupationArray['organisationName'] = '';
                 $thisOccupationArray['contactName'] = '';
                 $thisOccupationArray['contactPosition'] = '';
                 $thisOccupationArray['oranisationAddress'] = '';
                 $thisOccupationArray['postCode'] = '';
                 $thisOccupationArray['telephone'] = '';
                 $thisOccupationArray['fax'] = '';
                 $thisOccupationArray['email'] = '';
             }
             if (empty($thisOccupation->variables)) {
                 $thisOccupationArray['positionHeld'] = '';
                 $thisOccupationArray['payrollNumber'] = '';
             } else {
                 $thisOccupationArray['positionHeld'] = $thisOccupation->variables[Model_Referencing_OccupationVariables::POSITION];
                 $thisOccupationArray['payrollNumber'] = $thisOccupation->variables[Model_Referencing_OccupationVariables::PAYROLL_NUMBER];
             }
             $thisOccupationArray['salary'] = $thisOccupation->income->getValue();
             $thisOccupationArray['positionHeld'] = '';
             $thisOccupationArray['payrollNumber'] = '';
             $thisOccupationArray['startDate'] = empty($thisOccupation->startDate) ? '' : $thisOccupation->startDate->toString();
             $thisOccupationArray['endDate'] = '';
             $thisOccupationArray['isPermanent'] = $thisOccupation->isPermanent ? 'Yes' : 'No';
         }
         switch ($i) {
             case 0:
                 $this->view->currentOccupation = $thisOccupationArray;
                 break;
             case 1:
                 $this->view->futureOccupation = $thisOccupationArray;
                 break;
         }
     }
     //Prepare the residential details.
     for ($i = 0; $i < 3; $i++) {
         switch ($i) {
             case 0:
                 $thisResidence = $residenceManager->findSpecificResidence($reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::CURRENT);
                 break;
             case 1:
                 $thisResidence = $residenceManager->findSpecificResidence($reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::FIRST_PREVIOUS);
                 break;
             case 2:
                 $thisResidence = $residenceManager->findSpecificResidence($reference->referenceSubject->residences, Model_Referencing_ResidenceChronology::SECOND_PREVIOUS);
                 break;
         }
         $thisResidenceArray = array();
         if (empty($thisResidence)) {
             $thisResidenceArray['address'] = '';
             $thisResidenceArray['postCode'] = '';
             $thisResidenceArray['duration'] = '';
         } else {
             if ($thisResidence->address->isOverseasAddress) {
                 $thisResidenceArray['address'] = 'Overseas';
                 $thisResidenceArray['postCode'] = 'Overseas';
             } else {
                 $thisResidenceArray['address'] = $thisResidence->address->addressLine1 . ' ' . $thisResidence->address->addressLine2 . ' ' . $thisResidence->address->town;
                 $thisResidenceArray['postCode'] = $thisResidence->address->postCode;
             }
             $thisResidenceArray['duration'] = $thisResidence->durationAtAddress;
         }
         switch ($i) {
             case 0:
                 $this->view->firstResidence = $thisResidenceArray;
                 break;
             case 1:
                 $this->view->secondResidence = $thisResidenceArray;
                 break;
             case 2:
                 $this->view->thirdResidence = $thisResidenceArray;
                 break;
         }
     }
 }
 /**
  * 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;
 }
 public function insertReferenceSubject($referenceSubject)
 {
     //Get the bank account details.
     if (!empty($referenceSubject->bankAccount)) {
         $accountNumber = $referenceSubject->bankAccount->accountNumber;
         $sortCode = $referenceSubject->bankAccount->sortCode;
         if ($referenceSubject->bankAccount->isValidated) {
             $isValidated = 'Yes';
         } else {
             $isValidated = 'No';
         }
     } else {
         $accountNumber = '';
         $sortCode = '';
         $isValidated = 'N/A';
     }
     //Get the current residential status.
     if (!empty($referenceSubject->residences)) {
         foreach ($referenceSubject->residences as $residence) {
             if ($residence->chronology == Model_Referencing_ResidenceChronology::CURRENT) {
                 switch ($residence->status) {
                     case Model_Referencing_ResidenceStatus::OWNER:
                         $currentResidentialStatus = 'Owner';
                         break;
                     case Model_Referencing_ResidenceStatus::TENANT:
                         $currentResidentialStatus = 'Tenant';
                         break;
                     case Model_Referencing_ResidenceStatus::LIVING_WITH_RELATIVES:
                         $currentResidentialStatus = 'Living with Relative';
                         break;
                 }
                 break;
             }
         }
     }
     //Get the occupational income.
     $totalIncome = new Zend_Currency(array('value' => 0, 'precision' => 0));
     foreach ($referenceSubject->occupations as $occupation) {
         $totalIncome->add($occupation->income);
     }
     //Get the current occupational status.
     $currentOccupationalStatus = '';
     foreach ($referenceSubject->occupations as $occupation) {
         if ($occupation->chronology == Model_Referencing_OccupationChronology::CURRENT) {
             if ($occupation->importance == Model_Referencing_OccupationImportance::FIRST) {
                 switch ($occupation->type) {
                     case Model_Referencing_OccupationTypes::EMPLOYMENT:
                         $currentOccupationalStatus = 'Employed';
                         break;
                     case Model_Referencing_OccupationTypes::CONTRACT:
                         $currentOccupationalStatus = 'On Contract';
                         break;
                     case Model_Referencing_OccupationTypes::SELFEMPLOYMENT:
                         $currentOccupationalStatus = 'Self Employed';
                         break;
                     case Model_Referencing_OccupationTypes::INDEPENDENT:
                         $currentOccupationalStatus = 'of Independent Means';
                         break;
                     case Model_Referencing_OccupationTypes::RETIREMENT:
                         $currentOccupationalStatus = 'Retired';
                         break;
                     case Model_Referencing_OccupationTypes::STUDENT:
                         $currentOccupationalStatus = 'Student';
                         break;
                     case Model_Referencing_OccupationTypes::UNEMPLOYMENT:
                         $currentOccupationalStatus = 'Unemployed';
                         break;
                 }
                 //Whilst we are here, determine if the occupation is permanent.
                 if ($occupation->isPermanent) {
                     $occupationChange = 'No';
                 } else {
                     $occupationChange = 'Yes';
                 }
                 break;
             }
         }
     }
     if (empty($referenceSubject->shareOfRent)) {
         $shareOfRent = 0;
     } else {
         $shareOfRent = $referenceSubject->shareOfRent->getValue();
     }
     if (empty($referenceSubject->dob)) {
         $dob = '0000-00-00';
     } else {
         $dob = $referenceSubject->dob->toString(Zend_Date::ISO_8601);
     }
     //Finally, push to munt
     $data = array('title' => empty($referenceSubject->name->title) ? '' : $referenceSubject->name->title, 'firstname' => empty($referenceSubject->name->firstName) ? '' : $referenceSubject->name->firstName, 'middlename' => empty($referenceSubject->name->middleName) ? '' : $referenceSubject->name->middleName, 'lastname' => empty($referenceSubject->name->lastName) ? '' : $referenceSubject->name->lastName, 'maidenname' => empty($referenceSubject->name->maidenName) ? '' : $referenceSubject->name->maidenName, 'dob' => $dob, 'tel' => empty($referenceSubject->contactDetails->telephone1) ? '' : $referenceSubject->contactDetails->telephone1, 'mobile' => empty($referenceSubject->contactDetails->telephone2) ? '' : $referenceSubject->contactDetails->telephone2, 'email' => empty($referenceSubject->contactDetails->email1) ? '' : $referenceSubject->contactDetails->email1, 'rstatus' => $currentResidentialStatus, 'estatus' => $currentOccupationalStatus, 'echange' => $occupationChange, 'RentShare' => $shareOfRent, 'income' => $totalIncome->getValue(), 'hasCCJs' => $referenceSubject->hasAdverseCredit == true ? 'Yes' : 'No', 'isForeignNational' => $referenceSubject->isForeignNational == true ? 'yes' : 'no', 'accountNo' => $accountNumber, 'sortcodeNo' => $sortCode, 'bankValidationCheckStatus' => $isValidated);
     return $this->insert($data);
 }
 /**
  * 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;
 }