protected function formatVantage(LoanApplication $application)
 {
     $site = $application->getSite();
     $a = new \stdClass();
     $coBorrowers = $application->getCoBorrower();
     $borrower = $application->getBorrower();
     $a->isCurrentlyEmployed = False;
     $a->coIsCurrentlyEmployed = False;
     $a->firstName = $borrower->getFirstName();
     $a->lastName = $borrower->getLastName();
     $a->address1 = $borrower->getLocation()->getLocation()->getAddress1();
     $a->address2 = $borrower->getLocation()->getLocation()->getAddress2();
     $a->city = $borrower->getLocation()->getLocation()->getCity();
     $a->state = $borrower->getLocation()->getLocation()->getState()->getAbbreviation();
     $a->zipcode = $borrower->getLocation()->getLocation()->getZipcode();
     $a->email = $borrower->getEmail();
     $a->phoneHome = $borrower->getPhoneHome();
     $a->phoneCell = $borrower->getPhoneMobile();
     $a->ssn = $borrower->getSsn();
     $a->dependants = $borrower->getDependentsNumber();
     $a->dependantsAges = $borrower->getDependentsAges();
     $a->yearsOfResidence = $borrower->getLocation()->getYearsAtLocation();
     $a->monthsOfResidence = $borrower->getLocation()->getMonthsAtLocation();
     $a->isRenting = !$borrower->getLocation()->getOwnResidence();
     $a->hasCoborrower = !$coBorrowers->isEmpty();
     $a->yearsOfSchool = $borrower->getYearsOfSchool();
     switch ($borrower->getMaritalStatus()) {
         case '0':
             $a->maritalStatus = 3;
             break;
         case '1':
             $a->maritalStatus = 1;
             break;
         case '2':
             $a->maritalStatus = 4;
             break;
         default:
             $a->maritalStatus = 0;
     }
     foreach ($borrower->getEmployment() as $job) {
         if ($job->getEndDate()->add(new \DateInterval('P1D')) >= $application->getCreated() && $application->getBorrower()->getEmployed()) {
             $a->isCurrentlyEmployed = True;
             $job->setCurrent(True);
             $a->employer = $job->getEmployerName();
             $a->employerPhone = $job->getEmployerPhone();
             $a->employerAddress1 = $job->getLocation()->getAddress1();
             $a->employerAddress2 = $job->getLocation()->getAddress2();
             $a->employerCity = $job->getLocation()->getCity();
             $a->employerState = $job->getLocation()->getState()->getAbbreviation();
             $a->employerZipCode = $job->getLocation()->getZipcode();
             $a->employmentYearsOnJob = $job->getTimeAtJob()->years;
             $a->employmentMonthsOnJob = $job->getTimeAtJob()->months;
             $a->employmentTitle = $job->getTitle();
         } else {
             $job->setCurrent(False);
         }
     }
     foreach ($coBorrowers as $coBorrower) {
         $a->coFirstName = $coBorrower->getFirstName();
         $a->coLastName = $coBorrower->getLastName();
         $a->coAddress1 = $coBorrower->getLocation()->getLocation()->getAddress1();
         $a->coAddress2 = $coBorrower->getLocation()->getLocation()->getAddress2();
         $a->coCity = $coBorrower->getLocation()->getLocation()->getCity();
         $a->coState = $coBorrower->getLocation()->getLocation()->getstate()->getAbbreviation();
         $a->coZip = $coBorrower->getLocation()->getLocation()->getZipcode();
         $a->coPhoneHome = $coBorrower->getPhoneHome();
         $a->coPhoneCell = $coBorrower->getPhoneMobile();
         $a->coSSN = $coBorrower->getSsn();
         $a->coEmail = $coBorrower->getEmail();
         $a->coDependants = $coBorrower->getDependentsNumber();
         $a->coDependantsAges = $coBorrower->getDependentsAges();
         $a->coYearsOfResidence = $coBorrower->getLocation()->getYearsAtLocation();
         $a->coMonthsOfResidence = $coBorrower->getLocation()->getMonthsAtLocation();
         $a->coIsRenting = !$coBorrower->getLocation()->getOwnResidence();
         foreach ($coBorrower->getEmployment() as $job) {
             if ($job->getEndDate()->add(new \DateInterval('P1D')) >= $application->getCreated() && $application->getBorrower()->getEmployed()) {
                 $a->coIsCurrentlyEmployed = True;
                 $job->setCurrent(True);
                 $a->CoEmployer = $job->getEmployerName();
                 $a->CoEmployerPhone = $job->getEmployerPhone();
                 $a->CoEmployerAddress1 = $job->getLocation()->getAddress1();
                 $a->CoEmployerAddress2 = $job->getLocation()->getAddress2();
                 $a->CoEmployerCity = $job->getLocation()->getCity();
                 $a->CoEmployerState = $job->getLocation()->getState()->getAbbreviation();
                 $a->CoEmployerZipCode = $job->getLocation()->getZipcode();
                 $a->CoEmploymentYearsOnJob = $job->getTimeAtJob()->years;
                 $a->CoEmploymentMonthsOnJob = $job->getTimeAtJob()->months;
                 $a->CoEmploymentTitle = $job->getTitle();
             } else {
                 $job->setCurrent(False);
             }
         }
         switch ($coBorrower->getMaritalStatus()) {
             case '0':
                 $a->coMaritalStatus = 3;
                 break;
             case '1':
                 $a->coMaritalStatus = 1;
                 break;
             case '2':
                 $a->coMaritalStatus = 4;
                 break;
             default:
                 $a->coMaritalStatus = 0;
         }
     }
     $a->loanAmount = $application->getLoanAmount();
     $a->propertyMarketValue = $application->getSalePrice();
     $a->propertyAddress1 = $application->getPropertyLocation()->getAddress1();
     $a->propertyAddress2 = $application->getPropertyLocation()->getAddress2();
     $a->propertyCity = $application->getPropertyLocation()->getCity();
     $a->propertyState = $application->getPropertyLocation()->getState()->getAbbreviation();
     $a->propertyZipCode = $application->getPropertyLocation()->getZipcode();
     $a->realEstateBrokerPhone = $application->getRealtorPhone();
     $a->propertyUse = $application->getResidencyType() + 1;
     $a->vendorLeadPrice = '$5.00';
     $a->vendorLeadId = $application->getId();
     $a->vendorId = $site->getSettings()->getLos()->getUsername();
     $a->vendorPassword = $site->getSettings()->getLos()->getPassword();
     $a->orgId = $site->getSettings()->getLos()->getLicenseKey();
     $a->customerIp = $ip = getenv('HTTP_CLIENT_IP') ?: getenv('HTTP_X_FORWARDED_FOR') ?: getenv('HTTP_X_FORWARDED') ?: getenv('HTTP_FORWARDED_FOR') ?: getenv('HTTP_FORWARDED') ?: getenv('REMOTE_ADDR');
     $a->vendorWebProperty = $site->getPrimaryDomain()->getDomain();
     $a->vendorCampaign = $site->getSettings()->getLos()->getSettings();
     return $a;
 }
 /**
  * @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;
 }
Example #3
0
 /**
  * 
  * @param LoanApplication $application
  * @param int $milestoneId
  * @param int $milestoneGroupId
  * @throws \Exception
  */
 public function setLoanMilestone(LoanApplication $application, $milestoneId, $milestoneGroupId)
 {
     try {
         $integrationSite = $this->losConnection->getSite();
         //print_r('Site ID: '. $integrationSite->getId() . ' | Milestone ID: '. $milestoneId . ' | Milestone Group ID: ' . $milestoneGroupId);
         $newMilestone = $this->em->getRepository('SudouxMortgageBundle:LoanMilestone')->findOneMilestoneByLosId($integrationSite, $milestoneId, $milestoneGroupId);
         //print_r('Milestone Name: ' . $newMilestone->getName());
         if (isset($newMilestone)) {
             // check for a change and send to the
             $currentMilestone = $application->getMilestone();
             if (isset($currentMilestone)) {
                 $sendNotifications = $application->getSite()->getSettings()->getInheritedSendMilestonesNotifications();
                 $user = $application->getUser();
                 if ($currentMilestone->getId() != $newMilestone->getId() && $sendNotifications && isset($user)) {
                     if ($user->hasRole('ROLE_MEMBER')) {
                         $email = new Email();
                         $email->setSubject("Your loan status has been updated");
                         $email->setMessage(sprintf("Your loan status for %s has been updated to %s.", $application->getPropertyLocation()->getAddress1(), $newMilestone->getName()));
                         $email->setRecipient($user->getEmail());
                         $email->setSite($application->getSite());
                         $application->addEmail($email);
                         $emailUtil = $this->container->get('sudoux.cms.message.email_util');
                         $emailUtil->logAndSend($email);
                     }
                 }
             }
             $application->setMilestone($newMilestone);
             $application->setMilestoneGroup($newMilestone->getMilestoneGroup());
         } else {
             $e = new \Exception("Milestone not found for loan " . $application->getId());
             $this->logger->crit($e->getMessage());
         }
     } catch (\Exception $e) {
         $this->logger->crit($e->getMessage());
     }
 }
 /**
  * @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;
 }