/** * Gets the application data using the policy number * * @param $policyNumber * @return RentRecoveryPlusApplication|null */ public function getApplicationData($policyNumber) { if (!$this->populateByPolicyNumber($policyNumber)) { return null; } else { if ($this->appData->getPayStatus() == $this->container->get('rrp.legacy.const.pay_status_referred')) { return null; } } $referenceNumbers = array(); /** @var \Model_Insurance_RentRecoveryPlus_RrpTenantReference $rrpTenantReference */ foreach ($this->rrpTenantReferenceData as $rrpTenantReference) { $referenceNumbers[] = $rrpTenantReference->getReferenceNumber(); } $tenancyStartAt = \DateTime::createFromFormat('Y-m-d', $this->rrpData->getTenancyStartAt()); $applicationData = new RentRecoveryPlusApplication(); $applicationData->setPolicyNumber($policyNumber)->setPolicyLength($this->appData->getPolicyLength())->setReferenceType($this->rrpData->getReferenceType())->setOtherProvider($this->rrpData->getOtherProvider())->setReferenceNumber(implode("\n", $referenceNumbers))->setIsNilExcess(PolicyOptionsManager::isOptionSet($this->appData->getPolicyOptions(), $this->container->get('rrp.legacy.const.policy_option_rrp-nilexcess'), $this->appData->getAmountsCovered()))->setIsContinuationOfExistingPolicy($this->underwritingAnswers[RentRecoveryPlusAnswers::QUESTION_ID_CONTINUATION])->setExistingPolicyRef($this->rrpData->getExistingPolicyRef())->setIsExistingPolicyToBeCancelled($this->rrpData->getIsExistingPolicyToBeCancelled())->setCancellationObjections($this->rrpData->getCancellationObjections())->setPropertyLetType($this->rrpData->getPropertyLetType())->setHasLandlordPermission($this->rrpData->getHasLandlordPermission())->setPropertyAddress1($this->combineAddress($this->appData->getPropertyAddress1(), $this->appData->getPropertyAddress2()))->setPropertyAddress2($this->appData->getPropertyAddress3())->setPropertyPostcode($this->appData->getPropertyPostcode())->setPropertyDeposit($this->rrpData->getPropertyDeposit())->setPropertyRental(PolicyOptionsManager::getOption($this->appData->getPolicyOptions(), $this->container->get('rrp.legacy.const.policy_option_rrp'), $this->appData->getAmountsCovered()))->setHasPaidRentInAdvance($this->underwritingAnswers[RentRecoveryPlusAnswers::QUESTION_ID_RENT_IN_ADVANCE])->setTenancyStartAt($tenancyStartAt)->setPolicyStartAt(\DateTime::createFromFormat('Y-m-d', $this->appData->getStartDate()))->setLandlordTitle($this->lliData->getTitle())->setLandlordFirstName($this->lliData->getFirstName())->setLandlordLastName($this->lliData->getLastName())->setLandlordEmailAddress($this->lliData->getEmailAddress())->setLandlordPhoneNumber($this->lliData->getPhoneNumber())->setLandlordAddress1($this->combineAddress($this->lliData->getAddress1(), $this->lliData->getAddress2()))->setLandlordAddress2($this->lliData->getAddress3())->setLandlordPostcode($this->lliData->getPostcode())->setLandlordCountry($this->lliData->getCountry())->setHasPossibleClaimCircumstances($this->underwritingAnswers[RentRecoveryPlusAnswers::QUESTION_ID_CLAIM_CIRCUMSTANCES])->setClaimInfo($this->rrpData->getClaimInfo())->setHasPermittedOccupiersOnly($this->underwritingAnswers[RentRecoveryPlusAnswers::QUESTION_ID_PERMITTED_OCCUPIERS])->setHasTenancyDisputes($this->underwritingAnswers[RentRecoveryPlusAnswers::QUESTION_ID_TENANCY_DISPUTES])->setTenancyAgreementType(TenancyAgreementTypes::getIsAssuredShortholdTenancy($this->underwritingAnswers[RentRecoveryPlusAnswers::QUESTION_ID_TENANCY_AST]))->setHasPriorClaims($this->underwritingAnswers[RentRecoveryPlusAnswers::QUESTION_ID_PRIOR_CLAIMS])->setIsDepositSufficient($this->underwritingAnswers[RentRecoveryPlusAnswers::QUESTION_ID_DEPOSIT_SUFFICIENT])->setIsPayMonthly($this->appData->getPayBy() == $this->container->get('rrp.legacy.const.pay_by_monthly')); $this->isNewApplication = false; return $applicationData; }