Пример #1
0
 public function getOptions()
 {
     $type = 'T';
     // We just want Tenants options from the datasource
     $optionsDatasource = new Datasource_Insurance_Policy_Options($type);
     $options = $optionsDatasource->fetchOptions();
     $returnArray = array();
     foreach ($options as $option) {
         // Filter for just the options which are relevant to tenants contents PLUS product
         if (substr($option->policyOption, -1) == "p") {
             $returnArray[] = $option->policyOption;
             //$returnArray[]['minimumSumInsured'] =  $option->minimumSumInsured;
         }
     }
     return $returnArray;
 }
Пример #2
0
 /**
  * Populate the policyCover table using old pipe-seperated values :(
  * 
  * @munt 7
  */
 public function populateFromLegacy($policyNumber, $policyOptions, $amountsCovered, $optionPremiums)
 {
     if ($policyOptions != '') {
         $policyOptionsArray = explode('|', $policyOptions);
         $coverArray = explode('|', $amountsCovered);
         $premiumsArray = explode('|', $optionPremiums);
         // First we need to remove any policy cover items for this policy/quote
         $where = $this->quoteInto('policyNumber = ?', $policyNumber);
         $this->delete($where);
         $optionsLookup = new Datasource_Insurance_Policy_Options();
         $i = 0;
         foreach ($policyOptionsArray as $policyOptionName) {
             $optionID = $optionsLookup->fetchOptionsByName($policyOptionName);
             $data = array('policyOptionID' => $optionID, 'sumInsured' => $coverArray[$i], 'premium' => $premiumsArray[$i], 'policyNumber' => $policyNumber);
             $this->insert($data);
             $i++;
         }
     }
 }
 /**
  * Renew a policy from the 'temporary' insight_rrp_policy to the policy table
  *
  * @param string $rrpPolicyNumber
  * @param string $newPolicyNumber
  * @param string $termNumber
  * @return bool
  * @throws \RuntimeException
  */
 public function migratePolicy($rrpPolicyNumber, $newPolicyNumber, $termNumber)
 {
     if ($this->policyNumberManager->isRentRecoveryPlusInsightPolicy($rrpPolicyNumber)) {
         $this->setPolicyNumber($newPolicyNumber);
         $disbData = $this->disbursement->getDisbursement($this->appData->getWhiteLabelID(), $this->appData->getRateSetID());
         if (!$disbData) {
             $message = sprintf('Disbursement data not found (WhiteLabelId = %s, RateSetID = %d)', $this->appData->getWhiteLabelID(), $this->appData->getRateSetID());
             throw new \RuntimeException($message);
         }
         $getter = sprintf('getRrpi%s%dm', ReferenceTypes::isFullReference($this->rrpData->getReferenceType()) ? 'FullRef' : 'CreditCheck', $this->appData->getPolicyLength());
         if (PolicyOptionsManager::isOptionSet($this->appData->getPolicyOptions(), $this->container->get('rrp.legacy.const.policy_option_rrp-nilexcess'), $this->appData->getAmountsCovered())) {
             $getter .= '0xs';
         }
         if (!method_exists($disbData, $getter)) {
             $message = sprintf('Unknown disbursement type (%s)', $getter);
             throw new \RuntimeException($message);
         }
         $disbursement = $disbData->{$getter}();
         if (empty($disbursement)) {
             $message = sprintf('Disbursement data not set (WhiteLabelId = %s, RateSetID = %d, %s)', $this->appData->getWhiteLabelID(), $this->appData->getRateSetID(), $getter);
             throw new \RuntimeException($message);
         }
         $propertyRental = PolicyOptionsManager::getOption($this->appData->getPolicyOptions(), $this->getContainer()->get('rrp.legacy.const.policy_option_rrp'), $this->appData->getAmountsCovered());
         if ($propertyRental < RentRecoveryPlus::BAND_A_LIMIT) {
             $band = $disbData::BAND_A;
         } else {
             $band = $disbData::BAND_B;
         }
         $insuranceNetAmount = $disbData->extractBandDisbursement($disbursement, $band);
         // Policy Term
         $termId = $this->policyTerm->updatePolicyTerm($this->appData, $termNumber, array('netPremium' => $insuranceNetAmount, 'collectedPremium' => $this->appData->premium));
         if ($termId) {
             // Write the policy to the datasource
             $this->getAppData()->setStatus($this->container->get('rrp.legacy.const.status_policy'))->setTermId($termId);
             $legacyPolicy = $this->container->get('rrp.legacy.datasource.policy');
             $legacyPolicy->save($this->appData);
             // Delete the legacy insight record.
             $policyConstType = $this->container->get('rrp.legacy.const.quote_policy_number');
             $this->application->remove(array($policyConstType => $rrpPolicyNumber));
             $insightStatusIas = $this->container->get('rrp.legacy.const.insight_status_ias');
             // Now move the RRP / LL Interest parts
             if ($this->rrp->accept($rrpPolicyNumber, $newPolicyNumber, $insightStatusIas)) {
                 if ($this->llInterest->accept($rrpPolicyNumber, $newPolicyNumber)) {
                     /** @var RentRecoveryPlusAnswers $underwriting */
                     $underwriting = UnderwritingDecoratorFactory::getDecorator(UnderwritingDecoratorFactory::UNDERWRITING_RENT_RECOVERY_PLUS, $this->container->get('rrp.config.underwriting_question_set_id'), $this->appData->getIssueDate(), $rrpPolicyNumber);
                     $answers = $underwriting->getAllAnswers();
                     $answers[RentRecoveryPlusAnswers::QUESTION_ID_RENT_IN_ADVANCE] = true;
                     $answers[RentRecoveryPlusAnswers::QUESTION_ID_PRIOR_CLAIMS] = false;
                     $answers[RentRecoveryPlusAnswers::QUESTION_ID_DEPOSIT_SUFFICIENT] = true;
                     $underwriting->setAnswers($answers)->saveAnswers()->changeQuoteToPolicy($newPolicyNumber);
                     $coverOptions = array();
                     foreach ($this->appData->getValidPolicyOptionNames() as $optionName) {
                         if (PolicyOptionsManager::isOptionSet($this->appData->getPolicyOptions(), $optionName, $this->appData->getAmountsCovered())) {
                             $optionId = $this->policyOptions->fetchOptionsByName($optionName);
                             $sumInsured = PolicyOptionsManager::getOption($this->appData->getPolicyOptions(), $optionName, $this->appData->getAmountsCovered());
                             $premium = PolicyOptionsManager::getOption($this->appData->getPolicyOptions(), $optionName, $this->appData->getOptionPremiums());
                             $coverOptions[] = array('policyNumber' => $newPolicyNumber, 'policyOptionID' => $optionId, 'sumInsured' => $sumInsured, 'premium' => $premium);
                         }
                     }
                     $this->policyCover->setCover($newPolicyNumber, $coverOptions);
                     return $newPolicyNumber;
                 }
             }
         }
     }
     return false;
 }
Пример #4
0
 /**
  * Member function to set banked value
  * @param Double  
  * return void
  */
 public function createTermImage($policynumber)
 {
     /**
      * prepair data to build TermImage
      */
     $this->_policynumber = $policynumber;
     $this->_amount = 0;
     $this->_months = 12;
     $policyDisb = new Datasource_Insurance_LegacyPolicies();
     $policy = $policyDisb->getByPolicyNumber($policynumber);
     $this->_policyname = $policy->policyName;
     $termDisb = new Datasource_Insurance_Policy_Term();
     $term = $termDisb->getPolicyTerm($policynumber, $policy->startDate);
     $this->_startdate = $policy->startDate;
     $policy->termid = $term['id'];
     $this->_getMult($policy);
     $policyOptionsArray = explode("|", $policy->policyOptions);
     $pItemHist = new Datasource_Insurance_Policy_PolicyTermItemHist();
     foreach ($policyOptionsArray as $key => $value) {
         $this->_initialise();
         $option = new Datasource_Insurance_Policy_Options($policy->policyType);
         $this->_optionID = $option->fetchOptionsByName($value);
         $this->_sumInsOption = $policyDisb->getPolicyOptionMatch($policy->policyOptions, $value, $policy->amountsCovered);
         $cover->sumInsured = $this->_sumInsOption;
         if ($this->_sumInsOption > 0) {
             $cover = new Model_Insurance_Cover();
             $cover->policyOptionID = $this->_optionID;
             $cover->sumInsured = $this->_sumInsOption;
             $this->_premOption = $policyDisb->getPolicyOptionMatch($policy->policyOptions, $value, $policy->optionPremiums) * $this->_mult;
             $this->_discOption = $policyDisb->getPolicyOptionMatch($policy->policyOptions, $value, $policy->optionDiscounts);
             $this->_calculateTax();
             $this->_calculateNet($policy, $value);
             $cover->grosspremium = $this->_premOption + $this->_iptOption;
             $cover->premium = $this->_premOption;
             $cover->netpremium = $this->_netOption;
             $cover->ipt = $this->_iptOption;
             $pItemHist->setItemHist($policy, $cover);
         }
     }
 }
 /**
  * @inheritdoc
  */
 public function accept($policyNumber, $mtaId)
 {
     /** @var \RRP\Application\Decorators\RentRecoveryPlusPolicy $policy */
     $policy = ApplicationDecoratorFactory::getDecorator('RentRecoveryPlusPolicy');
     $policy->populateByPolicyNumber($policyNumber);
     $this->legacyMtaData = $this->legacyMta->getByMtaID($mtaId);
     $this->rrpMtaData = $this->rrpMta->getRentRecoveryPlusMta($mtaId);
     $proRataPremium = $policy->getAppData()->getPremium() + $this->legacyMtaData->getPremium();
     $proRataQuote = $policy->getAppData()->getQuote() + $this->legacyMtaData->getQuote();
     $proRataIpt = $policy->getAppData()->getIpt() + $this->legacyMtaData->getIpt();
     $propertyRental = PolicyOptionsManager::getOption($this->legacyMtaData->getPolicyOptions(), $this->getContainer()->get('rrp.legacy.const.policy_option_rrp'), $this->legacyMtaData->getAmountscovered());
     $isNilExcess = PolicyOptionsManager::isOptionSet($this->legacyMtaData->getPolicyOptions(), $this->getContainer()->get('rrp.legacy.const.policy_option_rrp-nilexcess'), $this->legacyMtaData->getAmountscovered());
     $policyPremium = PolicyOptionsManager::getOption($policy->getAppData()->getPolicyOptions(), $this->getContainer()->get('rrp.legacy.const.policy_option_rrp'), $policy->getAppData()->getOptionPremiums());
     $mtaPremium = PolicyOptionsManager::getOption($this->legacyMtaData->getPolicyOptions(), $this->getContainer()->get('rrp.legacy.const.policy_option_rrp'), $this->legacyMtaData->getOptionPremiums());
     $optionPremiums = PolicyOptionsManager::addPolicyOption($policyPremium + $mtaPremium);
     if ($isNilExcess) {
         $policyNilExcessOption = PolicyOptionsManager::getOption($policy->getAppData()->getPolicyOptions(), $this->getContainer()->get('rrp.legacy.const.policy_option_rrp-nilexcess'), $policy->getAppData()->getOptionPremiums());
         $mtaNilExcessOption = PolicyOptionsManager::getOption($this->legacyMtaData->getPolicyOptions(), $this->getContainer()->get('rrp.legacy.const.policy_option_rrp-nilexcess'), $this->legacyMtaData->getOptionPremiums());
         $optionPremiums = PolicyOptionsManager::addPolicyOption($policyNilExcessOption + $mtaNilExcessOption, $optionPremiums);
     }
     $policy->getAppData()->setPolicyOptions($this->legacyMtaData->getPolicyOptions())->setAmountsCovered($this->legacyMtaData->getAmountscovered())->setOptionPremiums($optionPremiums)->setPremium($proRataPremium)->setQuote($proRataQuote)->setIpt($proRataIpt);
     $policy->getRrpData()->setClaimInfo($this->rrpMtaData->getClaimInfo());
     $disbData = $this->disbursement->getDisbursement($policy->getAppData()->getWhiteLabelID(), $policy->getAppData()->getRateSetID());
     if (!$disbData) {
         $message = sprintf('Disbursement data not found (WhiteLabelId = %s, RateSetID = %d)', $policy->getAppData()->getWhiteLabelID(), $policy->getAppData()->getRateSetID());
         throw new \RuntimeException($message);
     }
     $getter = sprintf('getRrpi%s%dm', ReferenceTypes::isFullReference($policy->getRrpData()->getReferenceType()) ? 'FullRef' : 'CreditCheck', $policy->getAppData()->getPolicyLength());
     if ($isNilExcess) {
         $getter .= '0xs';
     }
     if (!method_exists($disbData, $getter)) {
         $message = sprintf('Unknown disbursement type (%s)', $getter);
         throw new \RuntimeException($message);
     }
     $disbursement = $disbData->{$getter}();
     if (empty($disbursement)) {
         $message = sprintf('Disbursement data not set (WhiteLabelId = %s, RateSetID = %d, %s)', $policy->getAppData()->getWhiteLabelID(), $policy->getAppData()->getRateSetID(), $getter);
         throw new \RuntimeException($message);
     }
     $termData = $this->policyTerm->getPolicyTerm($policy->getAppData()->getPolicyNumber(), $policy->getAppData()->getStartDate());
     if (!$termData->id) {
         throw new \RuntimeException('Invalid Term Id');
     }
     if ($propertyRental < RentRecoveryPlus::BAND_A_LIMIT) {
         $band = $disbData::BAND_A;
         $transBand = RentRecoveryPlus::BAND_A;
     } else {
         $band = $disbData::BAND_B;
         $transBand = RentRecoveryPlus::BAND_B;
     }
     $insuranceNetAmount = $disbData->extractBandDisbursement($disbursement, $band);
     $proRataCalcs = new ProRataCalculations($policy->getAppData()->getStartDate(), $this->legacyMtaData->getDateOnRisk());
     $netPremium = $proRataCalcs->getProRata($policy->getAppData()->getPolicyLength(), $policy->getAppData()->getPolicyLength(), $insuranceNetAmount, $termData->netPremium);
     $this->policyTerm->updatePolicyTerm($policy->getAppData(), $termData->term, array('netPremium' => $netPremium));
     $this->policyNotes->addNote($policyNumber, $this->legacyMtaData->getDisplayNotes());
     if ($policy->save()) {
         if ($this->legacyMta->updateStatus($policyNumber, $mtaId, $this->mtaStatusLive)) {
             $coverOptions = array();
             foreach ($policy->getAppData()->getValidPolicyOptionNames() as $optionName) {
                 if (PolicyOptionsManager::isOptionSet($policy->getAppData()->getPolicyOptions(), $optionName, $policy->getAppData()->getAmountsCovered())) {
                     $optionId = $this->policyOptions->fetchOptionsByName($optionName);
                     $sumInsured = PolicyOptionsManager::getOption($policy->getAppData()->getPolicyOptions(), $optionName, $policy->getAppData()->getAmountsCovered());
                     $premium = PolicyOptionsManager::getOption($policy->getAppData()->getPolicyOptions(), $optionName, $policy->getAppData()->getOptionPremiums());
                     $coverOptions[] = array('policyNumber' => $policyNumber, 'policyOptionID' => $optionId, 'sumInsured' => $sumInsured, 'premium' => $premium);
                 }
             }
             $this->policyCover->setCover($policyNumber, $coverOptions);
             if ($this->legacyMtaData->getPremium() == 0) {
                 //If no premium change there's no need to store anything in the transaction
                 return true;
             }
             $transaction = TransactionDecoratorFactory::getDecorator(TransactionDecoratorFactory::TRANSACTION_UPDATE, $policy->getAppData()->getPremium(), $insuranceNetAmount, $termData->id, $mtaId, $transBand, $this->legacyMtaData->getDateOnRisk(), $policy->getAppData());
             $transaction->processAllTransactions();
             return true;
         }
     }
     return false;
 }
Пример #6
0
 /**
  * Gets policy minimum insured from the given policy type and name
  * 
  * @param str $type Policy type
  * @param str $name Policy Name
  */
 public function fetchPolicyOptionMinimumSumInsuredByName($type, $name)
 {
     $source = new Datasource_Insurance_Policy_Options($type);
     $optionsObj = $source->fetchOptionsByName($name);
     return $optionsObj->getMinimumSumInsured();
 }
Пример #7
0
 /**
  * Set cover amount
  *
  * @param int $sumInsured
  * @return void
  */
 public function setCoverAmount($sumInsured, $type)
 {
     // Get the current amounts covered
     $amountsCovered = explode('|', $this->_quoteModel->amountsCovered);
     $amountsCovered[$type] = $sumInsured;
     $this->_quoteModel->amountsCovered = implode('|', $amountsCovered);
     // Re-calculate priced
     $this->calculatePremiums();
     if (!is_null($this->_quoteModel->policyNumber) && $this->_quoteModel->policyNumber != '') {
         // We have a policy number so we need to update the legacy policy cover table
         $optionPremiums = explode('|', $this->_quoteModel->optionPremiums);
         // We also have to update the legacy policy cover table
         $policyCover = new Datasource_Insurance_Policy_Cover();
         $policyOptions = new Datasource_Insurance_Policy_Options('T');
         $options = $policyOptions->fetchOptions();
         $optionIDsArray = array();
         foreach ($options as $option) {
             $optionIDsArray[$option->policyOption] = $option->policyOptionID;
         }
         // Contents cover
         $coverArray[] = array('policyOptionID' => $optionIDsArray['contentstp'], 'sumInsured' => is_null($amountsCovered[self::CONTENTS]) ? 0 : $amountsCovered[self::CONTENTS], 'premium' => is_null($optionPremiums[self::CONTENTS]) ? 0 : $optionPremiums[self::CONTENTS], 'policyNumber' => $this->_quoteModel->policyNumber);
         $coverArray[] = array('policyOptionID' => $optionIDsArray['pedalcyclesp'], 'sumInsured' => is_null($amountsCovered[self::PEDALCYCLES]) ? 0 : $amountsCovered[self::PEDALCYCLES], 'premium' => is_null($optionPremiums[self::PEDALCYCLES]) ? 0 : $optionPremiums[self::PEDALCYCLES], 'policyNumber' => $this->_quoteModel->policyNumber);
         $coverArray[] = array('policyOptionID' => $optionIDsArray['specpossessionsp'], 'sumInsured' => is_null($amountsCovered[self::SPECIFIEDPOSSESSIONS]) ? 0 : $amountsCovered[self::SPECIFIEDPOSSESSIONS], 'premium' => is_null($optionPremiums[self::SPECIFIEDPOSSESSIONS]) ? 0 : $optionPremiums[self::SPECIFIEDPOSSESSIONS], 'policyNumber' => $this->_quoteModel->policyNumber);
         $coverArray[] = array('policyOptionID' => $optionIDsArray['possessionsp'], 'sumInsured' => is_null($amountsCovered[self::UNSPECIFIEDPOSSESSIONS]) ? 0 : $amountsCovered[self::UNSPECIFIEDPOSSESSIONS], 'premium' => is_null($optionPremiums[self::UNSPECIFIEDPOSSESSIONS]) ? 0 : $optionPremiums[self::UNSPECIFIEDPOSSESSIONS], 'policyNumber' => $this->_quoteModel->policyNumber);
         $policyCover->setCover($this->_quoteModel->policyNumber, $coverArray);
     }
     $this->_save();
 }