예제 #1
0
 /**
  * @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;
 }
예제 #2
0
 protected function formatMismo231(LoanApplication $application)
 {
     $borrower = $application->getBorrower();
     $maritalStatusBorrower = $borrower->getMaritalStatus();
     $coBorrowers = $application->getCoBorrower();
     $type = $application->getLoanType();
     $propertyType = $application->getPropertyType();
     $resType = $application->getResidencyType();
     switch ($propertyType) {
         case '1':
             $application->setPropertyType("twotofourunitproperty");
             break;
         case '2':
             $application->setPropertyType("condominium");
             break;
         case '3':
             $application->setPropertyType("twotofourunitproperty");
             break;
         case '4':
             $application->setPropertyType("twotofourunitproperty");
             break;
         case '5':
             $application->setPropertyType("condominium");
             break;
         case '7':
             $application->setPropertyType("condominium");
             break;
         default:
             $application->setPropertyType("singlefamilyresidence");
     }
     if ($type == 0) {
         $application->setLoanType("Purchase");
     } else {
         if ($application->getRefinancePurpose() == 3) {
             $application->setLoanType("Refinance");
         } else {
             $application->setLoanType("Refinance");
         }
     }
     $appTitleManner = $application->getTitleManner();
     switch ($appTitleManner) {
         case 'Community property':
             $application->setTitleManner("Community Property");
             break;
         case 'Joint Tenants':
             $application->setTitleManner("Joint Tenancy");
             break;
         case 'Single Man':
             $application->setTitleManner("Single");
             break;
         case 'Single Woman':
             $application->setTitleManner("Single");
             break;
         case 'Married Man':
             $application->setTitleManner("A Married Man As His Separate Estate");
             break;
         case 'Married Woman':
             $application->setTitleManner("A Married Woman As Her Separate Estate");
             break;
         case 'Tenants in common':
             $application->setTitleManner("Tenancy in Common");
             break;
         case 'To be decided in escrow':
             $application->setTitleManner("");
             break;
         case 'Unmarried man':
             $application->setTitleManner("An Unmarried Person");
             break;
         case 'Unmarried woman':
             $application->setTitleManner("An Unmarried Person");
             break;
         case 'Other':
             $application->setTitleManner("");
             break;
         default:
             $application->setTitleManner("");
     }
     $refiPurpose = $application->getRefinancePurpose();
     switch ($refiPurpose) {
         case '0':
             $application->setRefinancePurpose("cashoutdebtconsolidation");
             break;
         case '1':
             $application->setRefinancePurpose("cashouthomeimprovement");
             break;
         case '2':
             $application->setRefinancePurpose("cashoutother");
             break;
         case '3':
             $application->setRefinancePurpose("nocashoutother");
             break;
         case '4':
             $application->setRefinancePurpose("cashoutlimited");
             break;
         default:
             $application->setRefinancePurpose("cashoutdebtconsolidation");
     }
     switch ($resType) {
         case '0':
             $application->setResidencyType("PrimaryResidence");
             break;
         case '1':
             $application->setResidencyType("SecondHome");
             break;
         case '2':
             $application->setResidencyType("Investor");
             break;
         default:
             $application->setResidencyType("PrimaryResidence");
     }
     if ($borrower->getDeclarationUsCitizen()) {
         $borrower->setDeclarationUsCitizen("USCitizen");
     } elseif ($borrower->getDeclarationResidentAlien()) {
         $borrower->setDeclarationUsCitizen("PermanentResidentAlien");
     } else {
         $borrower->setDeclarationUsCitizen("Unknown");
     }
     if ($borrower->getDeclarationOwnershipWithinThreeYears()) {
         switch ($borrower->getDeclarationOwnershipWithinThreeYearsPropertyTitle()) {
             case '0':
                 $borrower->setDeclarationOwnershipWithinThreeYearsPropertyTitle("Sole");
                 break;
             case '1':
                 $borrower->setDeclarationOwnershipWithinThreeYearsPropertyTitle("JointWithSpouse");
                 break;
             case '2':
                 $borrower->setDeclarationOwnershipWithinThreeYearsPropertyTitle("JointWithOtherThanSpouse");
                 break;
             default:
         }
         switch ($borrower->getDeclarationOwnershipWithinThreeYearsPropertyType()) {
             case '0':
                 $borrower->setDeclarationOwnershipWithinThreeYearsPropertyType("PrimaryResidence");
                 break;
             case '1':
                 $borrower->setDeclarationOwnershipWithinThreeYearsPropertyType("SecondaryResidence");
                 break;
             case '2':
                 $borrower->setDeclarationOwnershipWithinThreeYearsPropertyType("Investment");
                 break;
             default:
         }
     }
     if (!$borrower->getGovtMonitoringOptOut()) {
         switch ($borrower->getEthnicity()) {
             case '0':
                 $borrower->setEthnicity('HispanicOrLatino');
                 break;
             case '1':
                 $borrower->setEthnicity('NotHispanicOrLatino');
                 break;
             case '2':
                 $borrower->setEthnicity('NotApplicable');
                 break;
             default:
         }
         switch ($borrower->getRace()) {
             case '0':
                 $borrower->setRace('AmericanIndianOrAlaskanNative');
                 break;
             case '1':
                 $borrower->setRace('AsianOrPacificIslander');
                 break;
             case '2':
                 $borrower->setRace('BlackNotOfHispanicOrigin');
                 break;
             case '3':
                 $borrower->setRace('AsianOrPacificIslander');
                 break;
             case '4':
                 $borrower->setRace('WhiteNotOfHispanicOrigin');
                 break;
             default:
                 $borrower->setRace('Other');
         }
         if ($borrower->getIsMale()) {
             $borrower->setIsMale("Male");
         } else {
             $borrower->setIsMale("Female");
         }
     }
     $borrowerAssetsA = $borrower->getAssetAccount();
     foreach ($borrowerAssetsA as $a) {
         $aType = $a->getType();
         switch ($aType) {
             case '0':
                 $a->setType('CheckingAccount');
                 break;
             case '1':
                 $a->setType('SavingsAccount');
                 break;
             case '2':
                 $a->setType('MoneyMarketFund');
                 break;
             case '3':
                 $a->setType('CertificateOfDepositTimeDeposit');
                 break;
             case '4':
                 $a->setType('MutualFund');
                 break;
             case '5':
                 $a->setType('RetirementFund');
                 break;
             default:
                 $a->setType('OtherLiquidAssets');
         }
     }
     switch ($maritalStatusBorrower) {
         case '0':
             $borrower->setMaritalStatus('Married');
             break;
         case '1':
             $borrower->setMaritalStatus('Unmarried');
             break;
         case '2':
             $borrower->setMaritalStatus('Separated');
             break;
         default:
     }
     if ($borrower->getDependents()) {
         $BorrowerDependentsAges = explode(",", $application->getBorrower()->getDependentsAges());
         $application->getBorrower()->setDependentsAges($BorrowerDependentsAges);
     }
     $borrowerEmployment = $borrower->getEmployment()->getValues();
     foreach ($borrowerEmployment as $job) {
         $borEmpPhone = null;
         if ($job->getEndDate()->add(new \DateInterval('P1D')) >= $application->getCreated() && $application->getBorrower()->getEmployed()) {
             $job->setCurrent("Y");
         } else {
             $job->setCurrent("N");
         }
         switch ($job->getSelfEmployed()) {
             case '0':
                 $job->setSelfEmployed("N");
                 break;
             case '1':
                 $job->setSelfEmployed("Y");
                 break;
             default:
         }
         $borEmpPhone = $job->getEmployerPhone();
         if (isset($borEmpPhone)) {
             $borEmpPhone = preg_replace("/[^0-9]/", "", $borEmpPhone);
             $job->setEmployerPhone($borEmpPhone);
         }
     }
     ////////////////////////////////////////////////////////////////////////////
     //
     // Co Borrowers
     //
     ////////////////////////////////////////////////////////////////////
     foreach ($coBorrowers as $coBorrower) {
         $maritalStatusCoBorrower = $coBorrower->getMaritalStatus();
         $coBorrowerDependentsAges = NULL;
         if ($coBorrower->getDeclarationUsCitizen()) {
             $coBorrower->setDeclarationUsCitizen("USCitizen");
         } elseif ($coBorrower->getDeclarationResidentAlien()) {
             $coBorrower->setDeclarationUsCitizen("PermanentResidentAlien");
         } else {
             $coBorrower->setDeclarationUsCitizen("Unknown");
         }
         if ($coBorrower->getDeclarationOwnershipWithinThreeYears()) {
             switch ($coBorrower->getDeclarationOwnershipWithinThreeYearsPropertyTitle()) {
                 case '0':
                     $coBorrower->setDeclarationOwnershipWithinThreeYearsPropertyTitle("Sole");
                     break;
                 case '1':
                     $coBorrower->setDeclarationOwnershipWithinThreeYearsPropertyTitle("JointWithSpouse");
                     break;
                 case '2':
                     $coBorrower->setDeclarationOwnershipWithinThreeYearsPropertyTitle("JointWithOtherThanSpouse");
                     break;
                 default:
             }
             switch ($coBorrower->getDeclarationOwnershipWithinThreeYearsPropertyType()) {
                 case '0':
                     $coBorrower->setDeclarationOwnershipWithinThreeYearsPropertyType("PrimaryResidence");
                     break;
                 case '1':
                     $coBorrower->setDeclarationOwnershipWithinThreeYearsPropertyType("SecondaryResidence");
                     break;
                 case '2':
                     $coBorrower->setDeclarationOwnershipWithinThreeYearsPropertyType("Investment");
                     break;
                 default:
             }
         }
         if (!$coBorrower->getGovtMonitoringOptOut()) {
             switch ($coBorrower->getEthnicity()) {
                 case '0':
                     $coBorrower->setEthnicity('HispanicOrLatino');
                     break;
                 case '1':
                     $coBorrower->setEthnicity('NotHispanicOrLatino');
                     break;
                 case '2':
                     $coBorrower->setEthnicity('NotApplicable');
                     break;
                 default:
             }
             switch ($coBorrower->getRace()) {
                 case '0':
                     $coBorrower->setRace('AmericanIndianOrAlaskanNative');
                     break;
                 case '1':
                     $coBorrower->setRace('AsianOrPacificIslander');
                     break;
                 case '2':
                     $coBorrower->setRace('BlackNotOfHispanicOrigin');
                     break;
                 case '3':
                     $coBorrower->setRace('AsianOrPacificIslander');
                     break;
                 case '4':
                     $coBorrower->setRace('WhiteNotOfHispanicOrigin');
                     break;
                 default:
                     $coBorrower->setRace('Other');
             }
             if ($coBorrower->getIsMale()) {
                 $coBorrower->setIsMale("Male");
             } else {
                 $coBorrower->setIsMale("Female");
             }
         }
         switch ($maritalStatusCoBorrower) {
             case '0':
                 $coBorrower->setMaritalStatus('Married');
                 break;
             case '1':
                 $coBorrower->setMaritalStatus('Unmarried');
                 break;
             case '2':
                 $coBorrower->setMaritalStatus('Separated');
                 break;
             default:
         }
         if ($coBorrower->getDependents()) {
             $coBorrowerDependentsAges = explode(",", $coBorrower->getDependentsAges());
             $coBorrower->setDependentsAges($coBorrowerDependentsAges);
         }
         $coBorrowerEmployment = $coBorrower->getEmployment()->getValues();
         foreach ($coBorrowerEmployment as $job) {
             $coBorEmpPhone = null;
             if ($job->getEndDate()->add(new \DateInterval('P1D')) >= $application->getCreated() && $application->getBorrower()->getEmployed()) {
                 $job->setCurrent("Y");
             } else {
                 $job->setCurrent("N");
             }
             switch ($job->getSelfEmployed()) {
                 case '0':
                     $job->setSelfEmployed("N");
                     break;
                 case '1':
                     $job->setSelfEmployed("Y");
                     break;
                 default:
             }
             $coBorEmpPhone = $job->getEmployerPhone();
             if (isset($coBorEmpPhone)) {
                 $borEmpPhone = preg_replace("/[^0-9]/", "", $coBorEmpPhone);
                 $job->setEmployerPhone($borEmpPhone);
             }
         }
         $coBborrowerAssetsA = $coBorrower->getAssetAccount();
         foreach ($coBborrowerAssetsA as $a) {
             $aType = $a->getType();
             switch ($aType) {
                 case '0':
                     $a->setType('CheckingAccount');
                     break;
                 case '1':
                     $a->setType('SavingsAccount');
                     break;
                 case '2':
                     $a->setType('MoneyMarketFund');
                     break;
                 case '3':
                     $a->setType('CertificateOfDepositTimeDeposit');
                     break;
                 case '4':
                     $a->setType('MutualFund');
                     break;
                 case '5':
                     $a->setType('RetirementFund');
                     break;
                 default:
                     $a->setType('OtherLiquidAssets');
             }
         }
     }
     return $application;
 }
예제 #3
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;
 }