/** * Create a ReferencingCase with pre populated ProspectiveLandlord object. * * @return ReferencingCase */ private function getPrePopulatedCase() { // First, get the DirectLandlord object from IRIS and instantiate an empty ProspectiveLandlord. $directLandlord = $this->irisEntityManager->find(new DirectLandlord()); $prospectiveLandlord = new ProspectiveLandlord(); // Now map the DirectLandlord into a new ProspectiveLandlord: // foreach property in the DirectLandlord, if the ProspectiveLandlord contains a setter method, set it using the corresponding get method. // TODO getter and setter discovery can be handled more effectively $directLandlordReflect = new \ReflectionClass($directLandlord); $properties = $directLandlordReflect->getProperties(); foreach ($properties as $property) { $setMethod = sprintf('set%s', ucfirst($property->getName())); $getMethod = sprintf('get%s', ucfirst($property->getName())); if (method_exists($prospectiveLandlord, $setMethod) && method_exists($directLandlord, $getMethod)) { $prospectiveLandlord->{$setMethod}($directLandlord->{$getMethod}()); } } // Add the newly formed ProspectiveLandlord to the case. $case = new ReferencingCase(); $case->setProspectiveLandlord($prospectiveLandlord); return $case; }
/** * @param $productId * @param ReferencingCase $case * @param AbstractReferencingApplication $application * @param int $guarantorSequenceNumber * @return int */ public function getPrice($productId, ReferencingCase $case, AbstractReferencingApplication $application, $guarantorSequenceNumber = 0) { $criteria = array('productId' => $productId, 'propertyLetType' => $case->getPropertyLetType(), 'rentGuaranteeOfferingType' => $case->getRentGuaranteeOfferingType(), 'shareOfRent' => $application->getRentShare(), 'policyLengthInMonths' => $case->getTenancyTerm(), 'guarantorSequenceNumber' => $guarantorSequenceNumber, 'isRenewal' => 0); $productPrice = $this->irisEntityManager->find(new ProductPrice(), $criteria); return $productPrice->getGrossPrice(); }