Ejemplo n.º 1
0
 /**
  * @param $fannieMaeData
  * @param LoanApplication $application
  * @param int $source
  * @return LoanApplication
  */
 public function convertFannieMaeToLoanApplication($fannieMaeData, LoanApplication $application = null, $source = 0)
 {
     if (isset($application)) {
         // remove data for update
         $application->removeAllAssetAccount();
         $application->removeAllAssetRealEstate();
         // reset housing expense
     } else {
         $application = new LoanApplication();
         $application->setLastStepCompleted(6);
         $application->setHasRealtor(false);
         $application->setSource($source);
         $housingExpense = new ExpenseHousing();
         $application->setExpenseHousing($housingExpense);
     }
     $loanAmount = StringUtil::find($fannieMaeData, "01A", 131, 15);
     $application->setLoanAmount($this->toFloat($loanAmount));
     $loanTerm = StringUtil::find($fannieMaeData, "01A", 153, 3);
     $application->setLoanTerm($this->getLoanTerm($loanTerm));
     $loanType = StringUtil::find($fannieMaeData, "02B", 6, 2);
     $application->setLoanType($this->getLoanType($loanType));
     // refi data
     $refinanceYearAquired = StringUtil::find($fannieMaeData, "02D", 4, 4);
     $application->setRefinanceYearAquired($this->toInt($refinanceYearAquired));
     $refinanceOriginalCost = StringUtil::find($fannieMaeData, "02D", 8, 15);
     $application->setRefinanceOriginalCost($this->toFloat($refinanceOriginalCost));
     $refinanceExistingLiens = StringUtil::find($fannieMaeData, "02D", 23, 15);
     $application->setRefinanceExistingLiens($this->toFloat($refinanceExistingLiens));
     $refinancePurpose = StringUtil::find($fannieMaeData, "02D", 68, 2);
     $application->setRefinancePurpose($this->getRefinancePurpose($refinancePurpose));
     /*$refinancePurpose = StringUtil::find($fannieMaeData, "02D", 68, 2);	
     		$application->setRefinanceCurrentLender($refinanceCurrentLender);
     		$application->setRefinanceCurrentLoanType($refinanceCurrentLoanType);
     		$application->setRefinanceCurrentRate($refinanceCurrentRate);*/
     $salePrice = StringUtil::find($fannieMaeData, "07A", 4, 15);
     $application->setSalePrice($this->toFloat($salePrice));
     $numUnits = StringUtil::find($fannieMaeData, "02A", 100, 3);
     $application->setNumUnits($this->toInt($numUnits));
     $propertyYearBuilt = StringUtil::find($fannieMaeData, "02A", 185, 4);
     $application->setPropertyYearBuilt($this->toInt($propertyYearBuilt));
     $propertyType = StringUtil::find($fannieMaeData, "LNC", 6, 2);
     $application->setPropertyType($this->getPropertyType($propertyType));
     $residencyType = StringUtil::find($fannieMaeData, "02B", 88, 1);
     $application->setResidencyType($this->getResidencyType($residencyType));
     $titleManner = StringUtil::find($fannieMaeData, "02B", 89, 60);
     $application->setTitleManner($titleManner);
     $titleCompany = StringUtil::find($fannieMaeData, "02C", 4, 60);
     $application->setTitleCompany1($titleCompany);
     // property_location \Sudoux\Cms\LocationBundle\Entity\Location
     $propertyLocation = $application->getPropertyLocation();
     $propertyAddress = StringUtil::find($fannieMaeData, "02A", 4, 50);
     $propertyLocation->setAddress1($propertyAddress);
     $propertyCity = StringUtil::find($fannieMaeData, "02A", 54, 35);
     $propertyLocation->setCity($propertyCity);
     //echo $propertyCity; exit;
     $propertyState = StringUtil::find($fannieMaeData, "02A", 89, 2);
     $propertyStateEntity = $this->em->getRepository('SudouxCmsLocationBundle:State')->findStateByAbbreviation($propertyState);
     $propertyLocation->setState($propertyStateEntity);
     $propertyZipcode = StringUtil::find($fannieMaeData, "02A", 91, 5);
     $propertyLocation->setZipcode($this->toZipcode($propertyZipcode));
     $propertyUnit = StringUtil::find($fannieMaeData, "02A", 55, 11);
     $propertyLocation->setUnit($propertyUnit);
     // reset the housing expense
     $housingExpense = $application->getExpenseHousing();
     if (isset($housingExpense)) {
         $housingExpense->reset();
     }
     $borrower = $application->getBorrower();
     $this->convertFannieMaeToBorrower($application, $borrower, $fannieMaeData, array('03A_suffix' => 'BW'));
     $fnmCoBorrowers = StringUtil::findLinesStartingWith($fannieMaeData, "03AQZ");
     $coBorrowers = $application->getCoBorrower();
     foreach ($fnmCoBorrowers as $fnmCoBorrower) {
         $coBorrowerSsn = StringUtil::find($fnmCoBorrower, "03AQZ", 6, 9);
         $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->convertFannieMaeToBorrower($application, $coBorrower, $fannieMaeData, array('03A_suffix' => 'QZ'));
     }
     //exit;
     return $application;
 }