private function _calculateTax() { $policyDisb = new Datasource_Insurance_LegacyPolicies(); $policy = $policyDisb->getByPolicyNumber($this->_policynumber); $postcode = $policy->propertyPostcode; $taxInfo = new Datasource_Core_Tax(); $tax = $taxInfo->getTaxbyTypeAndPostcode('IPT', $postcode, $this->_startdate); $taxrate = $tax['rate']; $this->_iptOption = round($this->_premOption * ($taxrate / 100), 4); }
/** * Get policy details of a rent guarantee policy * * @param string $policynumber Rent guarantee policy number * @return Model_Insurance_Quote Quote object, representing the policy, populated with data */ public function getPolicyDetails($policynumber) { return $this->_policyModel->getByPolicyNumber($policynumber); }
/** * Policy list action * * @return void */ public function policiesAction() { $this->_setMetaTitle('My HomeLet | Policies'); $this->_setBreadcrumbs(array('/' => 'Home', '/my-homelet' => 'My HomeLet', '/my-homelet/policies' => 'My Policies')); $request = $this->getRequest(); // Get the customer session $customerSession = $this->auth->getStorage()->read(); // Search and ordering $filteredOrderBy = array(); $orderBy = $request->getParam('order'); $quoteNumberSearch = $request->getParam('id'); // Validate order by to restricted fields to those displayed on the front end if (is_array($orderBy)) { foreach ($orderBy as $orderByField => $orderByDirection) { if (in_array($orderByField, array('policynumber', 'policyname', 'startdate', 'premium', 'renewaldate', 'paystatus'))) { // Copy field into new array $filteredOrderBy[$orderByField] = $orderByDirection; } } } // Get list of linked customer reference numbers $policyCoverDatasource = new Datasource_Insurance_LegacyPolicyCovers(); $legacyCustomerMap = new Datasource_Core_CustomerMaps(); $legacyIDs = $legacyCustomerMap->getLegacyIDs($customerSession->id); // Retrieve all quotes for the linked customer reference numbers $quoteDatasource = new Datasource_Insurance_LegacyPolicies(); $policies = $quoteDatasource->getActivePolicies($legacyIDs, $quoteNumberSearch, $filteredOrderBy); // Build the list of policy covers. // Should be done in a manager, but the quote manager has been written with the row data gateway // design pattern in mind. foreach ($policies as $policy) { // Create list of policy covers $policyCoverList = array(); $policyOptionsplit = explode('|', $policy->policyOptions); $sumInsuredSplit = explode('|', $policy->amountsCovered); for ($i = 0; $i < count($policyOptionsplit); $i++) { if ($sumInsuredSplit[$i] == 'yes' || floatval($sumInsuredSplit[$i]) > 0) { // A sum insured value has been set so assume cover is in force $policyCover = $policyCoverDatasource->getPolicyCoverByLabel($policyOptionsplit[$i]); if ($policyCover) { array_push($policyCoverList, $policyCover->getName()); } } } $policy->policyCovers = $policyCoverList; } $this->view->policies = $policies; }
/** * Retrieve the document * * @param string $policyNumber Policy number * @param string $documentId Unique document request hash * @return string null or PDF contents */ private function _fetchDocument($policyNumber, $documentId) { // Get the customer session $customerSession = $this->auth->getStorage()->read(); // Get the request policy if ($policyNumber[0] == 'Q') { // Quotes $legacyPolicies = new Datasource_Insurance_LegacyQuotes(); } else { // Policies $legacyPolicies = new Datasource_Insurance_LegacyPolicies(); } $policy = $legacyPolicies->getByPolicyNumber($policyNumber); if (!$policy) { return null; } // Check the policy customer refno is linked to the customer id through mapping $customerMaps = new Datasource_Core_CustomerMaps(); $customerMap = $customerMaps->getMap(Model_Core_Customer::LEGACY_IDENTIFIER, $policy->refNo); // Confirm the policy number belongs to the logged in customer if ($customerMap == false || $customerMap->getIdentifier() != $customerSession->id) { // Customer map not found or customer is not mapped to refno, render error message return null; } // Get all document details $documentHistory = new Datasource_Insurance_DocumentHistory(); $document = $documentHistory->getDocument($documentId, $policyNumber); if (!$document) { return null; } // Retrieve document from store $documentFulfillmentService = new Service_Insurance_Document(); return $documentFulfillmentService->retrieveDocumentFromStore($documentId, $document->template_name, Service_Insurance_Document::DOCUMENT_AND_ATTACHMENTS); }