/** * * @param Site $site * @param string $losId */ public function createLoanFromLos(Site $site, $losId) { $loan = new LoanApplication(); $loan->setLosId($losId); $loan->setSite($site); $loan->setSource(1); $loan->setStatus(6); $loan->setCompleted(true); $this->upsertLoanFromLos($loan); return $loan; }
/** * @param $dataIn * @param \Sudoux\MortgageBundle\Entity\LoanApplication $application * @param int $source * @return \Sudoux\MortgageBundle\Entity\LoanApplication * @author Eric Haynes */ public function convertToLoanApp($dataIn, LoanApplication $application = null, $source = 4) { $xml = simplexml_load_string($dataIn); $json = json_encode($xml); $destinyData = json_decode($json, TRUE); if (!isset($application)) { $application = new LoanApplication(); $application->setLastStepCompleted(6); $application->setHasRealtor(false); //add section to grab realtor info if in xml $application->setNumUnits(1); $application->setSource($source); $housingExpense = new ExpenseHousing(); $application->setExpenseHousing($housingExpense); } $application->setStatus(6); // loan-info // //////////////////////////////// $loanAmount = $destinyData['loan-info']['@attributes']['base-loan-amount']; $application->setLoanAmount($this->toFloat($loanAmount)); $loanTerm = $destinyData['loan-info']['@attributes']['loan-term']; $application->setLoanTerm($this->getLoanTermInYears($loanTerm)); $loanType = $destinyData['loan-info']['@attributes']['loan-purpose']; $newLoanType = $this->getLoanTypeDestiny($loanType); $application->setLoanType($newLoanType); if ($newLoanType == 1) { $refiPurpose = $destinyData['loan-info']['@attributes']['purpose-of-refinance']; $application->setRefinancePurpose($this->getLoanRefiPurposeDestiny($refiPurpose)); $refiFirstMortgageAmount = $destinyData['loan-info']['@attributes']['first-mortgage-amount']; $application->setRefinanceOriginalCost($refiFirstMortgageAmount); $refiFirstMortgageRate = $destinyData['loan-info']['@attributes']['interest-rate']; $application->setRefinanceCurrentRate($refiFirstMortgageRate); $loanProgram = $destinyData['loan-info']['@attributes']['loan-program']; $application->setRefinanceCurrentLoanType($loanProgram); } $residencyType = $destinyData['loan-info']['@attributes']['occupancy-type']; $application->setResidencyType($this->getResidencyTypeDestiny($residencyType)); $salePrice = $destinyData['loan-info']['@attributes']['sale-price']; $application->setSalePrice($this->toFloat($salePrice)); // property-info // ///////////////////////////////// $propertyLocation = $application->getPropertyLocation(); $propertyAddress = ucwords(strtolower($destinyData['property-info']['@attributes']['street-address'])); $propertyLocation->setAddress1($propertyAddress); $propertyCity = ucwords(strtolower($destinyData['property-info']['@attributes']['city'])); $propertyLocation->setCity($propertyCity); //echo $propertyCity; exit; $propertyState = $destinyData['property-info']['@attributes']['state']; $propertyStateEntity = $this->em->getRepository('SudouxCmsLocationBundle:State')->findStateByAbbreviation($propertyState); $propertyLocation->setState($propertyStateEntity); $propertyZipcode = $destinyData['property-info']['@attributes']['zip']; $propertyLocation->setZipcode($this->toZipcode($propertyZipcode)); $propertyType = $destinyData['property-info']['@attributes']['property-type-code']; $application->setPropertyType($this->getPropertyTypeDestiny($propertyType)); // borrower info // //////////////////////////////// $marriageStatus = $this->guessMarriedTypeDestiny($destinyData['borrower-info']); foreach ($destinyData['borrower-info'] as $destinyBorrower) { if ($destinyBorrower['@attributes']['co-borrower'] == 'false') { $borrower = $application->getBorrower(); $this->convertDestinyToBorrower($application, $borrower, $destinyBorrower, false); $borrower->setMaritalStatus($marriageStatus); } else { $coBorrowers = $application->getCoBorrower(); $coBorrowerSsn = $destinyBorrower['@attributes']['ssn']; $coBorrower = null; if (count($coBorrowers) > 0) { // check if coborrower exists foreach ($coBorrowers as $cb) { $existingSsn = preg_replace("/[^0-9]/", "", $cb->getSsn()); if ($existingSsn == $coBorrowerSsn) { $coBorrower = $cb; break; } } } if (!isset($coBorrower)) { $coBorrower = new Borrower(); $application->addCoBorrower($coBorrower); $coBorrower->setSsn($coBorrowerSsn); } $this->convertDestinyToBorrower($application, $coBorrower, $destinyBorrower, true); $coBorrower->setMaritalStatus($marriageStatus); } } // loan status // //////////////////////////////// return $application; }