public function getPricing(LoanApplication $loan)
 {
     foreach ($loan->getPricingScenario() as $scenario) {
         $this->em->remove($scenario);
     }
     $loan->removeAllPricingScenarios();
     $this->em->flush();
 }
 protected function removeLoanCreditReports(LoanApplication $loan)
 {
     $this->removeBorrowerCreditReport($loan->getBorrower());
     $coBorrowers = $loan->getCoBorrower();
     foreach ($coBorrowers as $borrower) {
         $this->removeBorrowerCreditReport($borrower);
     }
 }
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $site = $this->site;
     $application = $this->application;
     $builder->add('sale_price', 'money', array('label' => 'Sale Price', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('loan_amount', 'money', array('label' => 'Loan Amount', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('loan_term', 'number', array('label' => 'Term (Years)', 'required' => true, 'attr' => array('class' => 'span1', 'maxlength' => 2)))->add('loan_type', 'choice', array('label' => 'Which type of loan are you applying for?', 'multiple' => false, 'choices' => $application->loanTypes, 'expanded' => true, 'multiple' => false))->add('status', 'choice', array('label' => 'Loan Status', 'choices' => $application->loanStatuses))->add('num_units', 'number', array('label' => 'Number of Units', 'required' => true, 'attr' => array('class' => 'span1')))->add('property_type', 'choice', array('choices' => $application->propertyTypes, 'empty_value' => 'Please select one'))->add('property_year_built', 'text', array('label' => 'Year Built', 'required' => false, 'attr' => array('class' => 'span2', 'maxlength' => 4)))->add('residency_type', 'choice', array('choices' => $application->residencyTypes, 'empty_value' => 'Please select one'))->add('title_company1', 'text', array('label' => 'Name #1', 'required' => false))->add('title_company2', 'text', array('label' => 'Name #2', 'required' => false))->add('has_realtor', 'choice', array('label' => 'Are you currently working with a Realtor?', 'choices' => array(0 => 'No', 1 => 'Yes'), 'multiple' => false, 'expanded' => true))->add('property_location', new PropertyLocationType($site), array('validation_groups' => array('step2')))->add('realtor_name', 'text', array('attr' => array('class' => 'realtor-info-field')))->add('realtor_company', 'text', array('attr' => array('class' => 'realtor-info-field')))->add('realtor_phone', 'text', array('attr' => array('class' => 'realtor-info-field phonenumber')))->add('borrower', new BorrowerType())->add('co_borrower', 'collection', array('type' => new BorrowerType(), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('asset_account', 'collection', array('type' => new AssetAccountType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('asset_real_estate', 'collection', array('type' => new AssetRealEstateType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('income_other', 'collection', array('type' => new IncomeOtherType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('income_monthly', 'collection', array('type' => new IncomeMonthlyType($this->application->getId()), 'allow_add' => true, 'allow_delete' => true, 'prototype' => true, 'by_reference' => false))->add('agreement_one', 'checkbox', array('required' => true))->add('agreement_two', 'checkbox', array('required' => true))->add('agreement_three', 'checkbox', array('required' => true))->add('expense_housing', new ExpenseHousingType())->add('comments', 'textarea', array('attr' => array('class' => 'span3'), 'required' => false))->add('loan_officer', 'entity', array('label' => 'Are you working with a loan officer?', 'class' => 'SudouxMortgageBundle:LoanOfficer', 'property' => 'fullname', 'multiple' => false, 'empty_value' => 'Select a loan officer', 'required' => false, 'query_builder' => function (EntityRepository $er) use($site) {
         return $er->findAllBySiteType($site);
     }))->add('refinance_year_aquired', 'number', array('label' => 'Year Acquired', 'required' => true, 'attr' => array('class' => 'span1', 'maxlength' => 4)))->add('refinance_original_cost', 'money', array('label' => 'Original Cost', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('refinance_existing_liens', 'money', array('label' => 'Existing Liens', 'currency' => 'USD', 'required' => true, 'precision' => 2, 'grouping' => true, 'attr' => array('class' => 'span2')))->add('refinance_current_rate', 'text', array('label' => 'Current Rate', 'required' => true, 'attr' => array('class' => 'span1')))->add('refinance_current_loan_type', 'text', array('label' => 'Current Loan Type', 'required' => true, 'attr' => array('class' => 'span3')))->add('refinance_current_lender', 'text', array('label' => 'Current Lender', 'required' => true, 'attr' => array('class' => 'span3')))->add('refinance_purpose', 'choice', array('label' => 'Purpose of Refinance', 'choices' => $application->refinancePurposes, 'required' => true, 'empty_value' => 'Please select one'))->add('referral_source', 'entity', array('class' => 'Sudoux\\Cms\\FormBundle\\Entity\\ReferralSource', 'property' => 'name', 'required' => false, 'multiple' => true, 'expanded' => true, 'label' => 'Where did you hear about us?', 'attr' => array('class' => 'checkbox-group'), 'query_builder' => function (EntityRepository $er) use($site) {
         return $er->findAllActiveBySiteQuery($site);
     }))->add('no_property_location', 'checkbox', array('label' => 'I do not have a property yet', 'attr' => array('class' => ''), 'required' => false));
     $titleManner = $this->application->getTitleManner();
     if (isset($titleManner)) {
         $builder->add('title_manner', 'text', array('label' => 'Manner', 'required' => false));
     } else {
         $builder->add('title_manner', 'choice', array('label' => 'Manner', 'required' => false, 'choices' => $application->titleManners, 'empty_value' => 'Please select one', 'required' => false));
     }
     /*$group = $application->getMilestoneGroup();
             if(isset($group)) {
     			$builder->add('milestone', 'entity', array(
     				'label' => 'Loan Status',
     				'class' => 'SudouxMortgageBundle:LoanMilestone',
     				'property' => 'name',
     				'multiple' => false,
     				'empty_value' => 'Select a status',
     				'required' => false,
     				'query_builder' => function(EntityRepository $er) use ($group) {
     					return $er->findByMilestoneGroupQuery($group->getId());
     				}
     			));
     		}*/
 }
예제 #4
0
 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 Request $request
  * @param null $id
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
  * @throws \Exception
  */
 public function applyStep1Action(Request $request, $id = null)
 {
     $siteRequest = $this->get('sudoux.cms.site');
     $site = $siteRequest->getSite();
     $em = $this->getDoctrine()->getEntityManager();
     $securityContext = $this->container->get('security.context');
     $user = $securityContext->getToken()->getUser();
     $newApplication = true;
     if (isset($id)) {
         $application = $em->getRepository('SudouxMortgageBundle:LoanApplication')->findOneBySite($site, $id);
         if (!isset($application)) {
             throw $this->createNotFoundException($this::LOAN_NOT_FOUND_MESSAGE);
         }
         $newApplication = false;
     } else {
         $application = new LoanApplication();
         $siteLoanOfficer = $site->getSettings()->getLoanOfficer();
         if (isset($siteLoanOfficer)) {
             $application->setLoanOfficer($siteLoanOfficer);
         }
     }
     if ($application->getLockStatus() > 0) {
         $session = $request->getSession();
         $session->getFlashBag()->add('error', $this::LOAN_LOCKED_MESSAGE);
         return $this->redirect($this->generateUrl('sudoux_mortgage_admin_loan_member', array('id' => $id)));
     }
     $showReferralSources = false;
     $referralSourceCount = $em->getRepository('SudouxCmsFormBundle:ReferralSource')->findAllActiveBySiteCount($site);
     if ($referralSourceCount > 0) {
         $showReferralSources = true;
     }
     $form = $this->createForm(new LoanApplicationType($site, $application), $application, array('validation_groups' => array('step1')));
     if ($request->getMethod() == 'POST') {
         $form->bindRequest($request);
         if ($form->isValid()) {
             try {
                 if ($newApplication) {
                     $application->setLastStepCompleted(1);
                     $application->setSite($site);
                     $application->setAdminUser($user);
                     // set the defaults because the constructor is not called on prototype forms
                     $coBorrowers = $application->getCoBorrower();
                     if (count($coBorrowers) > 0) {
                         foreach ($coBorrowers as $coBorrower) {
                             $coBorrower->setDefaults();
                         }
                     }
                 }
                 //echo 'Co-Borrowers: ' . count($application->getCoBorrower()); exit;
                 $em->persist($application);
                 $em->flush();
                 return $this->redirect($this->generateUrl('sudoux_mortgage_admin_loan_step2', array('id' => $application->getId())));
             } catch (\Exception $e) {
                 $logger = $this->get('logger');
                 $logger->crit($e->getMessage());
                 throw $e;
             }
         }
     }
     return $this->render('SudouxMortgageBundle:LoanApplicationAdmin:applyStep1.html.twig', array('form' => $form->createView(), 'application' => $application, 'showReferralSources' => $showReferralSources));
 }
예제 #6
0
 /**
  * Stub for overide
  * @param LoanApplication $application
  * @return string
  */
 protected function getDocumentBasePath(LoanApplication $application)
 {
     return $this->losConnection->getLicenseKey() . '/' . $application->getLosId();
 }
예제 #7
0
 public function setLoanMilestone(LoanApplication $application, $milestoneId, $milestoneGroupId)
 {
     $site = $application->getSite();
     $this->setLosSync($site);
     if (isset($this->losSync)) {
         return $this->losSync->setLoanMilestone($application, $milestoneId, $milestoneGroupId);
     }
 }
예제 #8
0
 /**
  * Creates or Updates a loan to the LOS
  * @param LoanApplication $application
  * @throws \Exception
  */
 public function upsertLoanToLos(LoanApplication $application)
 {
     try {
         $loId = null;
         $loanOfficer = $application->getLoanOfficer();
         if (isset($loanOfficer)) {
             $loId = $loanOfficer->getLosId();
         }
         $params = array('vendor' => $this->losConnection->getUsername(), 'cust' => $this->losConnection->getLicenseKey(), 'LO' => $loId, 'FNM' => $this->loanToFannieMae($application));
         $request = $this->client->post($this::BASE_SERVICE_URL . '/process1003.ashx', array('Content-Type' => 'text/plain'), $params);
         $factory = new PhpStreamRequestFactory();
         $stream = $factory->fromRequest($request);
         $data = '';
         // Read until the stream is closed
         while (!$stream->feof()) {
             // Read a line from the stream
             $data .= $stream->readLine();
         }
         if (!is_numeric($data)) {
             $params = array('vendor' => $this->losConnection->getUsername(), 'cust' => $this->losConnection->getLicenseKey(), 'LO' => '', 'FNM' => $this->loanToFannieMae($application));
             $request = $this->client->post($this::BASE_SERVICE_URL . '/process1003.ashx', array('Content-Type' => 'text/plain'), $params);
             $stream = $factory->fromRequest($request);
             $data = '';
             // Read until the stream is closed
             while (!$stream->feof()) {
                 // Read a line from the stream
                 $data .= $stream->readLine();
             }
         }
         if (is_numeric($data)) {
             $application->setLosId($data);
             $modifiedDate = new \DateTime();
             $modifiedDate->getTimestamp();
             $application->setLosModified($modifiedDate);
             $application->setLosLoanNumber($data);
             $application->setStatus(1);
             // lookup lo
             if (isset($loId)) {
                 $losLoanOfficer = $this->em->getRepository('SudouxMortgageBundle:LoanOfficer')->findOneBySiteAndLosId($application->getSite(), $loId);
                 $application->setLoanOfficer($losLoanOfficer);
             } else {
                 $application->setLoanOfficer(null);
             }
             $this->em->persist($application);
             $this->em->flush();
         } else {
             $e = new \Exception("Error adding loan - ID: " . $application->getId() . " Exception: " . $data);
             $this->logger->crit($e->getMessage());
             throw $e;
         }
     } catch (\Exception $e) {
         $this->logger->crit($e->getMessage());
         throw $e;
     }
     return $data;
 }
예제 #9
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;
 }
 /**
  * @param Request $request
  * @param null $id
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
  * @throws \Exception
  */
 public function applyStep1Action(Request $request, $id = null)
 {
     $securityContext = $this->container->get('security.context');
     if (!$securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         $session = $request->getSession();
         $session->getFlashBag()->add('error', $this::NOT_REGISTERED_MESSAGE);
         return $this->redirect($this->generateUrl('sudoux_cms_member_register'));
     }
     $siteRequest = $this->get('sudoux.cms.site');
     $site = $siteRequest->getSite();
     $em = $this->getDoctrine()->getEntityManager();
     $user = $securityContext->getToken()->getUser();
     $newApplication = true;
     if (isset($id)) {
         $application = $em->getRepository('SudouxMortgageBundle:LoanApplication')->findOneBy(array('id' => $id, 'user' => $user));
         if (!isset($application)) {
             throw $this->createNotFoundException($this::LOAN_NOT_FOUND_MESSAGE);
         }
         if ($application->getLockStatus() > 0) {
             $session = $request->getSession();
             $session->getFlashBag()->add('error', $this::LOAN_LOCKED_MESSAGE);
             return $this->redirect($this->generateUrl('sudoux_mortgage_loan_member_detail', array('id' => $id)));
         }
         $newApplication = false;
     } else {
         $application = new LoanApplication();
         $siteLoanOfficer = $site->getSettings()->getLoanOfficer();
         if (isset($siteLoanOfficer)) {
             $application->setLoanOfficer($siteLoanOfficer);
         }
     }
     if ($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         // autofill user info
         $application->getBorrower()->setEmail($user->getEmail());
     }
     $showReferralSources = false;
     $referralSourceCount = $em->getRepository('SudouxCmsFormBundle:ReferralSource')->findAllActiveBySiteCount($site);
     if ($referralSourceCount > 0) {
         $showReferralSources = true;
     }
     $form = $this->createForm(new LoanApplicationType($site, $application), $application, array('validation_groups' => array('step1')));
     if ($request->getMethod() == 'POST') {
         $form->bindRequest($request);
         $this->validateChildEntity($application, $form, 'borrower');
         if ($form->isValid()) {
             try {
                 $application->setSite($site);
                 $application->setUser($user);
                 if ($newApplication) {
                     $application->setLastStepCompleted(1);
                     $em->persist($application);
                     $em->flush();
                     // set the defaults because the constructor is not called on prototype forms
                     $coBorrowers = $application->getCoBorrower();
                     if (count($coBorrowers) > 0) {
                         foreach ($coBorrowers as $coBorrower) {
                             $coBorrower->setDefaults();
                         }
                     }
                     $email = new Email();
                     $email->setSubject('A borrower has started a loan application');
                     $message = sprintf("A borrower has started a loan application. <a href=\"%s\">Click here</a> to view the application.", $this->generateUrl('sudoux_mortgage_admin_loan_step1', array('id' => $application->getId()), true));
                     $message .= sprintf('<p>Borrower: %s<br>', $application->getBorrower()->getFullName());
                     $message .= sprintf('Email: %s<br>', $application->getBorrower()->getEmail());
                     $message .= sprintf('Phone: %s</p>', $application->getBorrower()->getPhoneHome());
                     if ($application->getCoBorrower()->count() > 0) {
                         $coBorrower = $application->getCoBorrower()->get(0);
                         $message .= sprintf('<p>Co-Borrower: %s</p>', $coBorrower->getFullName());
                         $message .= sprintf('Email: %s<br>', $coBorrower->getEmail());
                         $message .= sprintf('Phone: %s</p>', $coBorrower->getPhoneHome());
                     }
                     $email->setMessage($message);
                     $email->setSite($site);
                     // notify the site admin or lo
                     $loanOfficer = $application->getLoanOfficer();
                     if (isset($loanOfficer)) {
                         $notificationEmail = $loanOfficer->getEmail();
                         $email->setRecipientName($loanOfficer->getFullName());
                     } else {
                         $notificationEmail = $site->getSettings()->getInheritedWebsiteEmail();
                         $email->setRecipientName('Site Administrator');
                     }
                     $email->setRecipient($notificationEmail);
                     $email->setBcc($site->getSettings()->getInheritedWebsiteEmailBcc());
                     $emailUtil = $this->get('sudoux.cms.message.email_util');
                     $emailUtil->logAndSend($email);
                 } else {
                     $em->persist($application);
                     $em->flush();
                 }
                 return $this->redirect($this->generateUrl('sudoux_mortgage_loan_apply_step2', array('id' => $application->getId())));
             } catch (\Exception $e) {
                 $logger = $this->get('logger');
                 $logger->crit($e->getMessage());
                 throw $e;
             }
         }
     }
     return $this->render('SudouxMortgageBundle:LoanApplicationFront:applyStep1.html.twig', array('form' => $form->createView(), 'application' => $application, 'showReferralSources' => $showReferralSources));
 }
예제 #11
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;
 }
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
  * @throws \Exception
  */
 public function prequalifyAction(Request $request)
 {
     $securityContext = $this->container->get('security.context');
     $user = $securityContext->getToken()->getUser();
     $siteRequest = $this->get('sudoux.cms.site');
     $site = $siteRequest->getSite();
     $em = $this->getDoctrine()->getEntityManager();
     $officers = $em->getRepository('SudouxMortgageBundle:LoanOfficer')->findBy(array('site' => $site, 'active' => true));
     $application = new LoanApplication();
     $application->setIsPrequal(true);
     $application->setSite($site);
     $siteLoanOfficer = $site->getSettings()->getLoanOfficer();
     if (isset($siteLoanOfficer)) {
         $application->setLoanOfficer($siteLoanOfficer);
     }
     if ($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         // autofill user info
         $application->getBorrower()->setEmail($user->getEmail());
         $application->setUser($user);
     }
     $showReferralSources = false;
     $referralSourceCount = $em->getRepository('SudouxCmsFormBundle:ReferralSource')->findAllActiveBySiteCount($site);
     if ($referralSourceCount > 0) {
         $showReferralSources = true;
     }
     $form = $this->createForm(new LoanApplicationType($site), $application, array('validation_groups' => array('prequalify')));
     if ($request->getMethod() == 'POST') {
         $form->bindRequest($request);
         if ($form->isValid()) {
             try {
                 $em->persist($application);
                 $em->flush();
                 $emailUtil = $this->get('sudoux.cms.message.email_util');
                 // notify the borrrower
                 $email = new Email();
                 $email->setSubject('Pre-qualification Application Complete');
                 $email->setMessage($this::PREQUAL_SUCCESS_MESSAGE);
                 $email->setRecipient($application->getBorrower()->getEmail());
                 $email->setRecipientName($application->getBorrower()->getFullName());
                 $email->setSite($site);
                 $emailUtil->logAndSend($email);
                 // notifiy the site admin
                 $email = new Email();
                 $email->setSubject('A borrower has completed a pre-qualification application');
                 $message = sprintf("A borrower has completed a pre-qualification application. <a href=\"%s\">Click here</a> to view the application.", $this->generateUrl('sudoux_mortgage_admin_loan_step1', array('id' => $application->getId()), true));
                 $message .= sprintf('<p>Borrower: %s<br/>', $application->getBorrower()->getFullName());
                 $message .= sprintf('Email: %s<br/>', $application->getBorrower()->getEmail());
                 $message .= sprintf('Phone: %s</p>', $application->getBorrower()->getPhoneHome());
                 if ($application->getCoBorrower()->count() > 0) {
                     $coBorrower = $application->getCoBorrower()->get(0);
                     $message .= sprintf('<p>Co-Borrower: %s<br/>', $coBorrower->getFullName());
                     $message .= sprintf('Email: %s<br/>', $coBorrower->getEmail());
                     $message .= sprintf('Phone: %s</p>', $coBorrower->getPhoneHome());
                 }
                 $email->setMessage($message);
                 $email->setSite($site);
                 // notify the site admin or lo
                 $loanOfficer = $application->getLoanOfficer();
                 if (isset($loanOfficer)) {
                     $notificationEmail = $loanOfficer->getEmail();
                     $email->setRecipientName($loanOfficer->getFullName());
                 } else {
                     $notificationEmail = $site->getSettings()->getInheritedWebsiteEmail();
                     $email->setRecipientName('Site Administrator');
                 }
                 $email->setBcc($site->getSettings()->getInheritedWebsiteEmailBcc());
                 $email->setRecipient($notificationEmail);
                 $emailUtil->logAndSend($email);
                 $job = new Job('sudoux:mortgage:loan', array('add_loan_prospects', sprintf('--loan_id=%s', $application->getId()), '--env=' . $this->get('kernel')->getEnvironment(), '--no-debug'), true, 'loan_process_queue');
                 $em->persist($job);
                 $em->flush();
                 $redirectUrl = $site->getSettings()->getInheritedPrequalCompleteUrl();
                 if (isset($redirectUrl)) {
                     if ($this->get('kernel')->getEnvironment() == 'dev') {
                         $redirectUrl = '/app_dev.php' . $redirectUrl;
                     }
                 } else {
                     $redirectUrl = $this->generateUrl('sudoux_mortgage_loan_prequalify_complete');
                 }
                 return $this->redirect($redirectUrl);
             } catch (\Exception $e) {
                 $logger = $this->get('logger');
                 $logger->crit($e->getMessage());
             }
         }
     }
     return $this->render('SudouxMortgageBundle:LoanApplicationFront:prequalify.html.twig', array('form' => $form->createView(), 'application' => $application, 'officers' => $officers, 'showReferralSources' => $showReferralSources));
 }
예제 #13
0
 /**
  * @param LoanApplication $application
  * @param Borrower $borrower
  * @param $fannieMaeData
  * @param $options
  */
 protected function convertFannieMaeToBorrower(LoanApplication $application, Borrower $borrower, $fannieMaeData, $options)
 {
     // clear for update
     $incomeMonthly = $borrower->getIncomeMonthly();
     if (count($borrower->getIncomeMonthly()) > 0) {
         $borrower->removeAllIncomeMonthly();
     }
     $borrowerSsn = StringUtil::find($fannieMaeData, "03A" . $options['03A_suffix'], 6, 9);
     $borrower->setSsn($borrowerSsn);
     $borrowerFirstName = StringUtil::find($fannieMaeData, "03A" . $options['03A_suffix'], 15, 35);
     $borrower->setFirstName($borrowerFirstName);
     $borrowerLastName = StringUtil::find($fannieMaeData, "03A" . $options['03A_suffix'], 85, 35);
     $borrower->setLastName($borrowerLastName);
     $borrowerMiddleInitial = StringUtil::find($fannieMaeData, "03A" . $options['03A_suffix'], 50, 35);
     $borrower->setMiddleInitial($borrowerMiddleInitial);
     $borrowerSuffix = StringUtil::find($fannieMaeData, "03A" . $options['03A_suffix'], 120, 4);
     $borrower->setSuffix($borrowerSuffix);
     $borrowerEmail = StringUtil::find($fannieMaeData, "03A" . $options['03A_suffix'], 160, 80);
     $borrower->setEmail($borrowerEmail);
     $borrowerPhoneHome = StringUtil::find($fannieMaeData, "03A" . $options['03A_suffix'], 124, 10);
     $borrower->setPhoneHome($borrowerPhoneHome);
     $borrowerMaritialStatus = StringUtil::find($fannieMaeData, "03A" . $options['03A_suffix'], 139, 1);
     $borrower->setMaritalStatus($this->getBorrowerMaritalStatus($borrowerMaritialStatus));
     $borrowerYearsOfSchool = StringUtil::find($fannieMaeData, "03A" . $options['03A_suffix'], 137, 2);
     $borrower->setYearsOfSchool($this->toInt($borrowerYearsOfSchool));
     $borrowerBirthDate = StringUtil::find($fannieMaeData, "03A" . $options['03A_suffix'], 152, 8);
     $borrower->setBirthDate($this->convertToDateTime($borrowerBirthDate));
     $borrowerDependentsNumber = StringUtil::find($fannieMaeData, "03A" . $options['03A_suffix'], 140, 2);
     $borrower->setDependentsNumber($this->toInt($borrowerDependentsNumber));
     $borrowerDependentsAges = StringUtil::findAll($fannieMaeData, "03B" . $borrowerSsn, 13, 3);
     if (count($borrowerDependentsAges) == 1) {
         $borrower->setDependentsAges($borrowerDependentsAges[0]);
     } else {
         if (count($borrowerDependentsAges) > 1) {
             $borrower->setDependentsAges(implode(',', $borrowerDependentsAges));
         }
     }
     // BorrowerLocation
     $borrowerLocation = $borrower->getLocation();
     $borrowerLocationYears = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "ZG", 112, 2);
     $borrowerLocation->setYearsAtLocation($this->toInt($borrowerLocationYears));
     $borrowerLocationMonths = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "ZG", 114, 2);
     $borrowerLocation->setMonthsAtLocation($this->toInt($borrowerLocationMonths));
     $borrowerLocationOwnResidence = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "ZG", 111, 1);
     $borrowerLocation->setOwnResidence($this->getBorrowerLocationOwnResidence($borrowerLocationOwnResidence));
     // BorrowerLocation Location
     $borrowerLocationLocation = $borrowerLocation->getLocation();
     $borrowerLocationLocationAddress = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "ZG", 15, 50);
     $borrowerLocationLocation->setAddress1($borrowerLocationLocationAddress);
     $borrowerLocationLocationCity = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "ZG", 65, 35);
     $borrowerLocationLocation->setCity($borrowerLocationLocationCity);
     $borrowerLocationLocationState = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "ZG", 100, 2);
     $borrowerLocationLocationStateEntity = $this->em->getRepository('SudouxCmsLocationBundle:State')->findStateByAbbreviation($borrowerLocationLocationState);
     $borrowerLocationLocation->setState($borrowerLocationLocationStateEntity);
     $borrowerLocationLocationZipcode = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "ZG", 102, 5);
     $borrowerLocationLocation->setZipcode($this->toZipcode($borrowerLocationLocationZipcode));
     // Borrower Previous Locations
     $fnmBorrowerPreviousLocations = StringUtil::findLinesStartingWith($fannieMaeData, "03C" . $borrowerSsn . "F4");
     $borrower->removeAllPreviousLocations();
     // clear prev locations for update
     if (count($fnmBorrowerPreviousLocations) > 0) {
         foreach ($fnmBorrowerPreviousLocations as $fnmLocation) {
             $borrowerPreviousLocation = new BorrowerLocation();
             $borrower->addPreviousLocation($borrowerPreviousLocation);
             $borrowerPreviousLocationYears = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "F4", 112, 2);
             $borrowerPreviousLocation->setYearsAtLocation($this->toInt($borrowerPreviousLocationYears));
             $borrowerPreviousLocationMonths = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "F4", 114, 2);
             $borrowerPreviousLocation->setMonthsAtLocation($this->toInt($borrowerPreviousLocationMonths));
             $borrowerPreviousLocationOwnResidence = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "F4", 111, 1);
             $borrowerPreviousLocation->setOwnResidence($this->getBorrowerLocationOwnResidence($borrowerPreviousLocationOwnResidence));
             $borrowerPreviousLocationLocation = $borrowerPreviousLocation->getLocation();
             $borrowerPreviousLocationLocationAddress = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "F4", 15, 50);
             $borrowerPreviousLocationLocation->setAddress1($borrowerPreviousLocationLocationAddress);
             $borrowerPreviousLocationLocationCity = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "F4", 65, 35);
             $borrowerPreviousLocationLocation->setCity($borrowerLocationLocationCity);
             $borrowerPreviousLocationLocationState = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "F4", 100, 2);
             $borrowerPreviousLocationLocationStateEntity = $this->em->getRepository('SudouxCmsLocationBundle:State')->findStateByAbbreviation($borrowerPreviousLocationLocationState);
             $borrowerPreviousLocationLocation->setState($borrowerPreviousLocationLocationStateEntity);
             $borrowerPreviousLocationLocationZipcode = StringUtil::find($fannieMaeData, "03C" . $borrowerSsn . "F4", 102, 5);
             $borrowerPreviousLocationLocation->setZipcode($this->toZipcode($borrowerPreviousLocationLocationZipcode));
         }
     }
     // borrower employment
     $borrowerEmployment = $borrower->getEmployment();
     $fnmBorrowerEmployment = StringUtil::findLinesStartingWith($fannieMaeData, "04A" . $borrowerSsn);
     $borrower->removeAllEmployment();
     // remove employment for update
     if (count($fnmBorrowerEmployment)) {
         foreach ($fnmBorrowerEmployment as $fnmEmployment) {
             $employment = new Employment();
             $borrower->addEmployment($employment);
             $employerName = StringUtil::find($fnmEmployment, "04A" . $borrowerSsn, 13, 35);
             $employment->setEmployerName($employerName);
             $selfEmployed = StringUtil::find($fnmEmployment, "04A" . $borrowerSsn, 129, 1);
             $employment->setSelfEmployed($this->convertToBoolean($selfEmployed));
             $yearsInProfession = StringUtil::find($fnmEmployment, "04A" . $borrowerSsn, 134, 2);
             $employment->setYearsEmployed($this->toInt($yearsInProfession));
             $yearsOnJob = StringUtil::find($fnmEmployment, "04A" . $borrowerSsn, 130, 2);
             $employment->setYearsOnJob($this->toInt($yearsOnJob));
             $position = StringUtil::find($fnmEmployment, "04A" . $borrowerSsn, 136, 25);
             $employment->setTitle($position);
             $employerPhone = StringUtil::find($fnmEmployment, "04A" . $borrowerSsn, 161, 10);
             $employment->setEmployerPhone($employerPhone);
             $location = $employment->getLocation();
             $locationAddress = StringUtil::find($fnmEmployment, "04A" . $borrowerSsn, 48, 35);
             $location->setAddress1($locationAddress);
             $locationCity = StringUtil::find($fnmEmployment, "04A" . $borrowerSsn, 83, 35);
             $location->setCity($locationCity);
             $locationState = StringUtil::find($fnmEmployment, "04A" . $borrowerSsn, 118, 2);
             $locationStateEntity = $this->em->getRepository('SudouxCmsLocationBundle:State')->findStateByAbbreviation($locationState);
             $location->setState($locationStateEntity);
             $locationZipcode = StringUtil::find($fnmEmployment, "04A" . $borrowerSsn, 120, 5);
             $location->setZipcode($this->toZipcode($locationZipcode));
         }
     }
     // previous employment
     $fnmBorrowerEmployment = StringUtil::findLinesStartingWith($fannieMaeData, "04B" . $borrowerSsn);
     if (count($fnmBorrowerEmployment)) {
         foreach ($fnmBorrowerEmployment as $fnmEmployment) {
             $employment = new Employment();
             $borrower->addEmployment($employment);
             $employerName = StringUtil::find($fnmEmployment, "04B" . $borrowerSsn, 13, 35);
             $employment->setEmployerName($employerName);
             $selfEmployed = StringUtil::find($fnmEmployment, "04B" . $borrowerSsn, 129, 1);
             $employment->setSelfEmployed($this->convertToBoolean($selfEmployed));
             $startDateString = StringUtil::find($fnmEmployment, "04B" . $borrowerSsn, 131, 8);
             $startDate = $this->convertToDateTime($startDateString);
             if (isset($startDate)) {
                 $employment->setStartDate($startDate);
             }
             $endDateString = StringUtil::find($fnmEmployment, "04B" . $borrowerSsn, 139, 8);
             $endDate = $this->convertToDateTime($endDateString);
             if (isset($endDate)) {
                 $employment->setEndDate($endDate);
             }
             $position = StringUtil::find($fnmEmployment, "04B" . $borrowerSsn, 162, 25);
             $employment->setTitle($position);
             $employerPhone = StringUtil::find($fnmEmployment, "04B" . $borrowerSsn, 187, 10);
             $employment->setEmployerPhone($employerPhone);
             $location = $employment->getLocation();
             $locationAddress = StringUtil::find($fnmEmployment, "04B" . $borrowerSsn, 48, 35);
             $location->setAddress1($locationAddress);
             $locationCity = StringUtil::find($fnmEmployment, "04B" . $borrowerSsn, 83, 35);
             $location->setCity($locationCity);
             $locationState = StringUtil::find($fnmEmployment, "04B" . $borrowerSsn, 118, 2);
             $locationStateEntity = $this->em->getRepository('SudouxCmsLocationBundle:State')->findStateByAbbreviation($locationState);
             $location->setState($locationStateEntity);
             $locationZipcode = StringUtil::find($fnmEmployment, "04B" . $borrowerSsn, 120, 5);
             $location->setZipcode($this->toZipcode($locationZipcode));
         }
     }
     // account assets
     $fnmBorrowerAccountAsset = StringUtil::findLinesStartingWith($fannieMaeData, "06C" . $borrowerSsn);
     $borrower->removeAllAssetAccount();
     if (count($fnmBorrowerAccountAsset)) {
         foreach ($fnmBorrowerAccountAsset as $fnmAsset) {
             $accountAsset = new AssetAccount();
             $accountAsset->setBorrower($borrower);
             $application->addAssetAccount($accountAsset);
             $type = StringUtil::find($fnmAsset, "06C" . $borrowerSsn, 13, 3);
             $accountAsset->setType($this->getAccountType($type));
             $accountInstitutionName = StringUtil::find($fnmAsset, "06C" . $borrowerSsn, 16, 35);
             $accountAsset->setInstitutionName($accountInstitutionName);
             $accountNumber = StringUtil::find($fnmAsset, "06C" . $borrowerSsn, 132, 30);
             $accountAsset->setAccountNumber($accountNumber);
             $balance = StringUtil::find($fnmAsset, "06C" . $borrowerSsn, 162, 15);
             $accountAsset->setBalance($this->toFloat($balance));
         }
     }
     // real estate assets
     $fnmBorrowerRealEstateAsset = StringUtil::findLinesStartingWith($fannieMaeData, "06G" . $borrowerSsn);
     $borrower->removeAllAssetRealestate();
     if (count($fnmBorrowerRealEstateAsset)) {
         foreach ($fnmBorrowerRealEstateAsset as $fnmAsset) {
             $asset = new AssetRealEstate();
             $asset->setBorrower($borrower);
             $application->addAssetRealEstate($asset);
             $assetLocation = $asset->getLocation();
             $streetAddress = StringUtil::find($fnmAsset, "06G" . $borrowerSsn, 13, 35);
             $assetLocation->setAddress1($streetAddress);
             $city = StringUtil::find($fnmAsset, "06G" . $borrowerSsn, 48, 35);
             $assetLocation->setCity($city);
             $state = StringUtil::find($fnmAsset, "06G" . $borrowerSsn, 83, 2);
             $stateEntity = $this->em->getRepository('SudouxCmsLocationBundle:State')->findStateByAbbreviation($state);
             $assetLocation->setState($stateEntity);
             $zipcode = StringUtil::find($fnmAsset, "06G" . $borrowerSsn, 85, 5);
             $assetLocation->setZipcode($this->toZipcode($zipcode));
             $marketValue = StringUtil::find($fnmAsset, "06G" . $borrowerSsn, 97, 15);
             $asset->setMarketValue($this->toFloat($marketValue));
             $mortgageAmount = StringUtil::find($fnmAsset, "06G" . $borrowerSsn, 112, 15);
             $asset->setMortgageAmount($this->toFloat($mortgageAmount));
             $rentGrossIncome = StringUtil::find($fnmAsset, "06G" . $borrowerSsn, 127, 15);
             $asset->setRentGrossIncome($this->toFloat($rentGrossIncome));
             $mortgagePayment = StringUtil::find($fnmAsset, "06G" . $borrowerSsn, 142, 15);
             $asset->setMortgagePayment($this->toFloat($mortgagePayment));
             $insuranceTax = StringUtil::find($fnmAsset, "06G" . $borrowerSsn, 157, 15);
             $asset->setInsTaxExp($this->toFloat($insuranceTax));
             $rentNetIncome = StringUtil::find($fnmAsset, "06G" . $borrowerSsn, 172, 15);
             $asset->setRentNetIncome($this->toFloat($rentNetIncome));
         }
     }
     // combined housing expenses
     $housingExpense = $application->getExpenseHousing();
     if (!isset($housingExpense)) {
         $housingExpense = new ExpenseHousing();
         $application->setExpenseHousing($housingExpense);
     }
     $housingExpenseRent = StringUtil::find($fannieMaeData, "05H" . $borrowerSsn . "125", 16, 15);
     $housingExpense->setRent($this->getHousingExpenseTotal($housingExpense->getRent(), $housingExpenseRent));
     $housingExpenseMortgage = StringUtil::find($fannieMaeData, "05H" . $borrowerSsn . "126", 16, 15);
     $housingExpense->setMortgage($this->getHousingExpenseTotal($housingExpense->getMortgage(), $housingExpenseMortgage));
     $housingExpenseHazardInsurance = StringUtil::find($fannieMaeData, "05H" . $borrowerSsn . "101", 16, 15);
     $housingExpense->setInsuranceHazard($this->getHousingExpenseTotal($housingExpense->getInsuranceHazard(), $housingExpenseHazardInsurance));
     $housingExpenseOtherFinancial = StringUtil::find($fannieMaeData, "05H" . $borrowerSsn . "122", 16, 15);
     $housingExpense->setOtherFinancial($this->getHousingExpenseTotal($housingExpense->getOtherFinancial(), $housingExpenseOtherFinancial));
     $housingExpenseMortgageInsurance = StringUtil::find($fannieMaeData, "05H" . $borrowerSsn . "102", 16, 15);
     $housingExpense->setInsuranceMortgage($this->getHousingExpenseTotal($housingExpense->getInsuranceMortgage(), $housingExpenseMortgageInsurance));
     $housingExpenseRealEstateTax = StringUtil::find($fannieMaeData, "05H" . $borrowerSsn . "114", 16, 15);
     $housingExpense->setTaxRealEstate($this->getHousingExpenseTotal($housingExpense->getTaxRealEstate(), $housingExpenseRealEstateTax));
     $housingExpenseHoaDues = StringUtil::find($fannieMaeData, "05H" . $borrowerSsn . "106", 16, 15);
     $housingExpense->setHoaDues($this->getHousingExpenseTotal($housingExpense->getHoaDues(), $housingExpenseHoaDues));
     $housingExpenseOther = StringUtil::find($fannieMaeData, "05H" . $borrowerSsn . "123", 16, 15);
     $housingExpense->setOther($this->getHousingExpenseTotal($housingExpense->getOther(), $housingExpenseOther));
     // monthly income
     $application->removeIncomeMonthlyByBorrower($borrower);
     $borrowerMonthlyIncome = new IncomeMonthly();
     $borrowerMonthlyIncome->setBorrower($borrower);
     $application->addIncomeMonthly($borrowerMonthlyIncome);
     $borrowerMonthlyIncomeBase = StringUtil::find($fannieMaeData, "05I" . $borrowerSsn . "20", 15, 15);
     $borrowerMonthlyIncome->setBase($this->toFloat($borrowerMonthlyIncomeBase));
     $borrowerMonthlyIncomeOvertime = StringUtil::find($fannieMaeData, "05I" . $borrowerSsn . "09", 15, 15);
     $borrowerMonthlyIncome->setOvertime($this->toFloat($borrowerMonthlyIncomeOvertime));
     $borrowerMonthlyIncomeBonus = StringUtil::find($fannieMaeData, "05I" . $borrowerSsn . "08", 15, 15);
     $borrowerMonthlyIncome->setBonus($this->toFloat($borrowerMonthlyIncomeBonus));
     $borrowerMonthlyIncomeCommission = StringUtil::find($fannieMaeData, "05I" . $borrowerSsn . "10", 15, 15);
     $borrowerMonthlyIncome->setCommission($this->toFloat($borrowerMonthlyIncomeCommission));
     $borrowerMonthlyIncomeInterest = StringUtil::find($fannieMaeData, "05I" . $borrowerSsn . "17", 15, 15);
     $borrowerMonthlyIncome->setInterest($this->toFloat($borrowerMonthlyIncomeInterest));
     $borrowerMonthlyIncomeRentNet = StringUtil::find($fannieMaeData, "05I" . $borrowerSsn . "33", 15, 15);
     $borrowerMonthlyIncome->setRentNet($this->toFloat($borrowerMonthlyIncomeRentNet));
     $borrowerMonthlyIncomeOther = StringUtil::find($fannieMaeData, "05I" . $borrowerSsn . "45", 15, 15);
     $borrowerMonthlyIncome->setOther($this->toFloat($borrowerMonthlyIncomeOther));
     // declarations
     $declarationOutstandingJudgement = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 13, 1);
     $borrower->setDeclarationOutstandingJudgement($this->convertToBoolean($declarationOutstandingJudgement));
     $declarationOutstandingJudgementDetails = StringUtil::find($fannieMaeData, "08B" . $borrowerSsn . "91", 15, 255);
     $borrower->setDeclarationOutstandingJudgementDetails($this->getStringValue($declarationOutstandingJudgementDetails));
     $declarationBankruptcy = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 14, 1);
     $borrower->setDeclarationBankruptcy($this->convertToBoolean($declarationBankruptcy));
     $declarationBankruptcyDetails = StringUtil::find($fannieMaeData, "08B" . $borrowerSsn . "92", 15, 255);
     $borrower->setDeclarationBankruptcyDetails($this->getStringValue($declarationBankruptcyDetails));
     $declarationForclosure = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 15, 1);
     $borrower->setDeclarationForclosure($this->convertToBoolean($declarationForclosure));
     $declarationForclosureDetails = StringUtil::find($fannieMaeData, "08B" . $borrowerSsn . "93", 15, 255);
     $borrower->setDeclarationForclosureDetails($this->getStringValue($declarationForclosureDetails));
     $declarationLawsuit = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 16, 1);
     $borrower->setDeclarationLawsuit($this->convertToBoolean($declarationLawsuit));
     $declarationLawsuitDetails = StringUtil::find($fannieMaeData, "08B" . $borrowerSsn . "94", 15, 255);
     $borrower->setDeclarationLawsuitDetails($this->getStringValue($declarationLawsuitDetails));
     $declarationForclosureObligation = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 17, 1);
     $borrower->setDeclarationForclosureObligation($this->convertToBoolean($declarationForclosureObligation));
     $declarationForclosureObligationDetails = StringUtil::find($fannieMaeData, "08B" . $borrowerSsn . "95", 15, 255);
     $borrower->setDeclarationForclosureObligationDetails($this->getStringValue($declarationForclosureObligationDetails));
     $declarationInDefault = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 18, 1);
     $borrower->setDeclarationInDefault($this->convertToBoolean($declarationInDefault));
     $declarationInDefaultDetails = StringUtil::find($fannieMaeData, "08B" . $borrowerSsn . "96", 15, 255);
     $borrower->setDeclarationInDefaultDetails($this->getStringValue($declarationInDefaultDetails));
     $declarationAlimonyChildSupport = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 19, 1);
     $borrower->setDeclarationAlimonyChildSupport($this->convertToBoolean($declarationAlimonyChildSupport));
     $declarationAlimonyChildSupportDetails = StringUtil::find($fannieMaeData, "08B" . $borrowerSsn . "97", 15, 255);
     $borrower->setDeclarationAlimonyChildSupportDetails($this->getStringValue($declarationAlimonyChildSupportDetails));
     $declarationDownPaymentBorrowed = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 20, 1);
     $borrower->setDeclarationDownPaymentBorrowed($this->convertToBoolean($declarationDownPaymentBorrowed));
     $declarationDownPaymentBorrowedDetails = StringUtil::find($fannieMaeData, "08B" . $borrowerSsn . "98", 15, 255);
     $borrower->setDeclarationDownPaymentBorrowedDetails($this->getStringValue($declarationDownPaymentBorrowedDetails));
     $declarationNoteEndorser = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 21, 1);
     $borrower->setDeclarationNoteEndorser($this->convertToBoolean($declarationNoteEndorser));
     $declarationNoteEndorserDetails = StringUtil::find($fannieMaeData, "08B" . $borrowerSsn . "99", 15, 255);
     $borrower->setDeclarationNoteEndorserDetails($this->getStringValue($declarationNoteEndorserDetails));
     $declarationUsCitizen = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 22, 2);
     $borrower->setDeclarationUsCitizen($this->getUsCitizen($declarationUsCitizen));
     $declarationResidentAlien = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 22, 2);
     $borrower->setDeclarationResidentAlien($this->getResidentAlien($declarationResidentAlien));
     $declarationPrimaryResidence = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 24, 1);
     $borrower->setDeclarationPrimaryResidence($this->convertToBoolean($declarationPrimaryResidence));
     $declarationOwnershipWithinThreeYears = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 25, 1);
     $borrower->setDeclarationOwnershipWithinThreeYears($this->convertToBoolean($declarationOwnershipWithinThreeYears));
     $declarationOwnershipWithinThreeYearsPropertyType = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 26, 1);
     $borrower->setDeclarationOwnershipWithinThreeYearsPropertyType($this->getOwnershipPropertyType($declarationOwnershipWithinThreeYearsPropertyType));
     $declarationOwnershipWithinThreeYearsPropertyTitle = StringUtil::find($fannieMaeData, "08A" . $borrowerSsn, 27, 2);
     $borrower->setDeclarationOwnershipWithinThreeYearsPropertyTitle($this->getOwnershipTitle($declarationOwnershipWithinThreeYearsPropertyTitle));
     // govt monitoring
     $borrowerGovtMonitoringOptOut = StringUtil::find($fannieMaeData, "10A" . $borrowerSsn, 13, 1);
     $borrower->setGovtMonitoringOptOut($this->convertToBoolean($borrowerGovtMonitoringOptOut));
     $borrowerRace = StringUtil::find($fannieMaeData, "10R" . $borrowerSsn, 13, 2);
     $borrower->setRace($this->getBorrowerRace($borrowerRace));
     $borrowerEthnicity = StringUtil::find($fannieMaeData, "10A" . $borrowerSsn, 14, 1);
     $borrower->setEthnicity($this->getBorrowerEthnicity($borrowerEthnicity));
     $borrowerSex = StringUtil::find($fannieMaeData, "10A" . $borrowerSsn, 45, 1);
     $borrower->setIsMale($this->getBorrowerIsMale($borrowerSex));
     // expenses
     $declarationAlimonyChildSupportAlimony = StringUtil::find($fannieMaeData, "06F" . $borrowerSsn . "DR", 16, 15);
     $borrower->setDeclarationAlimonyChildSupportAlimony($this->toFloat($declarationAlimonyChildSupportAlimony));
     $declarationAlimonyChildSupportChildSupport = StringUtil::find($fannieMaeData, "06F" . $borrowerSsn . "DT", 16, 15);
     $borrower->setDeclarationAlimonyChildSupportChildSupport($this->toFloat($declarationAlimonyChildSupportChildSupport));
     $declarationAlimonyChildSupportSeparateMaintenance = StringUtil::find($fannieMaeData, "06F" . $borrowerSsn . "DV", 16, 15);
     $borrower->setDeclarationAlimonyChildSupportSeparateMaintenance($this->toFloat($declarationAlimonyChildSupportSeparateMaintenance));
 }
 /**
  * @param LoanApplication $application
  * @param $id
  * @return mixed
  * @throws \Doctrine\ORM\NonUniqueResultException
  */
 public function findOneByLosId(LoanApplication $application, $id)
 {
     $q = $this->createQueryBuilder('d')->where('l.loan = :loan_id')->andWhere('d.los_id = :id')->setParameter('id', $id)->setParameter('loan_id', $application->getId())->getQuery();
     return $q->getOneOrNullResult();
 }
예제 #15
0
 /**
  * @param LoanApplication $application
  * @param $milestoneId
  * @param $milestoneGroupId
  * @return mixed
  */
 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());
     }
 }