/** * Sets the data using the mid-term adjustment as the source * * @param RentRecoveryPlusMta $mta * @param float $premium */ public function setFromMta(RentRecoveryPlusMta $mta, $premium) { $this->hasPossibleClaimCircumstances = $mta->getHasPossibleClaimCircumstances(); $this->hasPermittedOccupiersOnly = $mta->getHasPermittedOccupiersOnly(); $this->hasTenancyDisputes = $mta->getHasTenancyDisputes(); $this->hasPriorClaims = $mta->getHasPriorClaims(); $this->isDepositSufficient = $mta->getIsDepositSufficient(); $this->propertyRental = $mta->getPropertyRental(); $this->isAssuredShortholdTenancy = TenancyAgreementTypes::isAssuredShortholdTenancy($mta->getTenancyAgreementType()); $this->claimInfo = $mta->getClaimInfo(); $this->premium = $premium; $this->hasProviderBeenChecked = true; $this->source = self::SOURCE_MID_TERM; }
/** * Validation function for optional constraints * * @param RentRecoveryPlusMta $mta * @param ExecutionContextInterface $context */ public function checkDates($mta, ExecutionContextInterface $context) { if ('0000-00-00' === $mta->getMtaEffectiveAt()) { return; } $startAt = new \DateTime($mta->getPolicyStartedAt()); $expiresAt = new \DateTime($mta->getPolicyExpiresAt()); $effectiveAt = new \DateTime($mta->getMtaEffectiveAt()); $now = new \DateTime(); $now->setTime(0, 0, 0); if ($effectiveAt > $expiresAt) { $context->addViolationAt('mtaEffectiveAt', 'Requested date exceeds existing end date of ' . $expiresAt->format('d/m/Y'), array(), null); } else { if ($effectiveAt < $now) { $context->addViolationAt('mtaEffectiveAt', 'Requested date is in the past', array(), null); } else { if ($effectiveAt < $startAt) { $context->addViolationAt('mtaEffectiveAt', 'Requested date is prior to policy start date of ' . $startAt->format('d/m/Y'), array(), null); } } } }