Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 /**
  * Stub for overide
  * @param LoanApplication $application
  * @return string
  */
 protected function getDocumentBasePath(LoanApplication $application)
 {
     return $this->losConnection->getLicenseKey() . '/' . $application->getLosId();
 }