/** * Helper function for generating view breakdown HTML fragment * * @param bool $showAdminFees Optional switch to include admin fees, defaults to false * * @return string */ public function viewBreakdown($includeAdminFees = true) { // Get customer ref no and policy number $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); $this->_customerReferenceNumber = $pageSession->CustomerRefNo; $this->_policyNumber = $pageSession->PolicyNumber; // Get premium values for quote $quoteManager = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $this->_policyNumber); $premiums = $quoteManager->calculatePremiums(); $this->view->premiums = $premiums; // Get cover amounts $this->view->contentsCoverAmount = $quoteManager->getCoverAmount(Manager_Insurance_TenantsContentsPlus_Quote::CONTENTS); $this->view->bicyclesCoverAmount = $quoteManager->getCoverAmount(Manager_Insurance_TenantsContentsPlus_Quote::PEDALCYCLES); $this->view->specifiedPossessionsCoverAmount = $quoteManager->getCoverAmount(Manager_Insurance_TenantsContentsPlus_Quote::SPECIFIEDPOSSESSIONS); $this->view->unspecifiedPossessionsCoverAmount = $quoteManager->getCoverAmount(Manager_Insurance_TenantsContentsPlus_Quote::UNSPECIFIEDPOSSESSIONS); // Get any sharer occupation details $sharersManager = new Manager_Insurance_TenantsContentsPlus_Sharers(); $sharerData = $sharersManager->getSharers($this->_policyNumber); $this->view->sharer1 = !is_null($sharerData) ? $sharerData->getSharerOccupation(1) : ''; $this->view->sharer2 = !is_null($sharerData) ? $sharerData->getSharerOccupation(2) : ''; // Get specified possessions info $possession = new Datasource_Insurance_Policy_SpecPossessions($this->_policyNumber); $this->view->possessions = $possession->listPossessions(); // Get bicycle info $bike = new Datasource_Insurance_Policy_Cycles($this->_customerReferenceNumber, $this->_policyNumber); $this->view->bicycles = $bike->listBikes(); // Get Current IPT percentage $quote = $quoteManager->getQuoteObject(); $postcode = $quote->propertyPostcode; $taxDatasource = new Datasource_Core_Tax(); $tax = $taxDatasource->getTaxbyTypeAndPostcode('ipt', $postcode); $ipt = 1 + $tax['rate']; // Get admin fees, if required if ($includeAdminFees) { $fees = $quoteManager->getFees(); $this->view->feeMonthly = $fees->tenantspMonthlyFee; $this->view->feeAnnual = 0; // TODO: parameterise? Legacy DB and fee object currently don't handle annual fees } else { $this->view->feeMonthly = 0; $this->view->feeAnnual = 0; } $this->view->includeAdminFees = $includeAdminFees; // Return partial view HTML return $this->view->partial('partials/view-breakdown.phtml', $this->view); }
/** * 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; }
/** * @todo Remove the hardcoded UW question numbers from this method. */ protected function _processUnderwriting($pageForm) { $returnVal = true; //First, store the underwriting answers. $declaration1 = $pageForm->subform_importantinformation->getElement('declaration1')->getValue(); $declaration2 = $pageForm->subform_importantinformation->getElement('declaration2')->getValue(); $declaration3 = $pageForm->subform_importantinformation->getElement('declaration3')->getValue(); $declaration4 = $pageForm->subform_importantinformation->getElement('declaration4')->getValue(); $underwritingAnswersArray = array(); $underwritingAnswersArray[0] = new Model_Insurance_Answer(); $underwritingAnswersArray[0]->setPolicyNumber($this->_policyNumber); $underwritingAnswersArray[0]->setQuestionNumber(49); $underwritingAnswersArray[0]->setAnswer($declaration1); $underwritingAnswersArray[0]->setDateAnswered(Zend_Date::now()); $underwritingAnswersArray[1] = new Model_Insurance_Answer(); $underwritingAnswersArray[1]->setPolicyNumber($this->_policyNumber); $underwritingAnswersArray[1]->setQuestionNumber(50); $underwritingAnswersArray[1]->setAnswer($declaration2); $underwritingAnswersArray[1]->setDateAnswered(Zend_Date::now()); $underwritingAnswersArray[2] = new Model_Insurance_Answer(); $underwritingAnswersArray[2]->setPolicyNumber($this->_policyNumber); $underwritingAnswersArray[2]->setQuestionNumber(51); $underwritingAnswersArray[2]->setAnswer($declaration3); $underwritingAnswersArray[2]->setDateAnswered(Zend_Date::now()); $underwritingAnswersArray[3] = new Model_Insurance_Answer(); $underwritingAnswersArray[3]->setPolicyNumber($this->_policyNumber); $underwritingAnswersArray[3]->setQuestionNumber(52); $underwritingAnswersArray[3]->setAnswer($declaration4); $underwritingAnswersArray[3]->setDateAnswered(Zend_Date::now()); $answersManager = new Manager_Insurance_Answers(); for ($i = 0; $i < count($underwritingAnswersArray); $i++) { if (!$answersManager->getIsAnswerAlreadyStored($underwritingAnswersArray[$i])) { $answersManager->insertUnderwritingAnswer($underwritingAnswersArray[$i]); } } //Next apply any necessary endorsements. $endorsementsManager = new Manager_Insurance_TenantsContentsPlus_Endorsement(); $endorsements = $endorsementsManager->getEndorsementsRequired($this->_policyNumber); if (!empty($endorsements)) { foreach ($endorsements as $currentEndorsement) { if (!$endorsementsManager->getIsEndorsementAlreadyApplied($currentEndorsement)) { $endorsementsManager->insertEndorsement($currentEndorsement); } } } //Next store any extra information provided by the user. $additionalInfoProvided = array(); $infoSubmitted = $pageForm->subform_importantinformation->getElement('declaration1_details')->getValue(); if (!empty($infoSubmitted)) { $additionalInfoProvided[] = $infoSubmitted; } $infoSubmitted = $pageForm->subform_importantinformation->getElement('declaration3_details')->getValue(); if (!empty($infoSubmitted)) { $additionalInfoProvided[] = $infoSubmitted; } $infoSubmitted = $pageForm->subform_importantinformation->getElement('declaration4_details')->getValue(); if (!empty($infoSubmitted)) { $additionalInfoProvided[] = $infoSubmitted; } if (!empty($additionalInfoProvided)) { //Compile the extra information, if any, into a single string. $compiledInformation = ''; foreach ($additionalInfoProvided as $currentInformation) { if (empty($compiledInformation)) { $compiledInformation = $currentInformation; } else { $compiledInformation .= " {$currentInformation}"; } } $additionalInformationManager = new Manager_Insurance_AdditionalInformation(); if (!$additionalInformationManager->getIsAdditionalInformationAlreadyStored($this->_policyNumber)) { $additionalInformation = new Model_Insurance_AdditionalInformation(); $additionalInformation->setPolicyNumber($this->_policyNumber); $additionalInformation->setAdditionalInformation($compiledInformation); $additionalInformationManager->insertAdditionalInformation($additionalInformation); } } //Update the quote object so that the underwritingQuestionSetID is appropriately set. $quoteManager = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $this->_policyNumber); $quoteManager->setUnderwritingQuestionSetID(2); //Previous claims are managed on the fly. //Check if a referral is required. $referralsManager = new Manager_Insurance_TenantsContentsPlus_Referral(); if ($referralsManager->getRequiresReferral($this->_policyNumber)) { //Display the referred screen. $returnVal = false; //Update the quote/policy notes. $notesManager = new Manager_Core_Notes(); $notesManager->save($this->_policyNumber, Model_Core_NoteLabels::REFERRED_BY_CUSTOMER); } return $returnVal; }
public function sendquoteAction() { $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); $postdata = $this->getRequest()->getPost(); if (isset($postdata)) { $sendBy = $postdata['how_send']; $request = $this->getRequest(); $quoteManager = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $pageSession->PolicyNumber); $quoteManager->sendQuote($pageSession->PolicyNumber, $sendBy); } }
/** * Implements abstract method from superclass - refer to superclass for description. */ public function setToRefer($policyNumber) { $quote = new Manager_Insurance_TenantsContentsPlus_Quote(null, null, $policyNumber); return $quote->setPayStatus('Referred'); }