Example #1
0
 public function sendBorrowerDeclinedEvent(Borrower $borrower)
 {
     $userId = $borrower->getId();
     $data = array('$type' => 'decline', '$api_key' => $this->siftScienceKey, '$user_id' => $userId, '$is_bad' => true, 'reasons' => 'Declined', '$description' => 'Borrower application declined', '$time' => time());
     $siftScienceUrl = "https://api.siftscience.com/v203/users/" . $userId . "/labels";
     $this->sendEvent($siftScienceUrl, json_encode($data));
 }
Example #2
0
 public function maximumPeriod()
 {
     $maximumMonths = Setting::get('loan.maximumPeriod');
     if ($this->borrower->getCountry()->getInstallmentPeriod() == Loan::WEEKLY_INSTALLMENT) {
         $maximumMonths = ceil($maximumMonths / 12 * 52);
     }
     return $maximumMonths;
 }
 public function verify(Borrower $borrower, User $user, $data)
 {
     $borrower->setActivationStatus($data['isEligibleByAdmin'] ? Borrower::ACTIVATION_APPROVED : Borrower::ACTIVATION_DECLINED);
     $borrower->save();
     if ($borrower->isActivationApproved()) {
         $this->borrowerMailer->sendApprovedConfirmationMail($borrower);
     } else {
         $this->borrowerMailer->sendDeclinedConfirmationMail($borrower);
         $this->siftScienceService->sendBorrowerDeclinedEvent($borrower);
     }
 }
Example #4
0
 public function applyForLoan(Borrower $borrower, $data)
 {
     $exchangeRate = ExchangeRateQuery::create()->findCurrent($borrower->getCountry()->getCurrency());
     $data['currencyCode'] = $borrower->getCountry()->getCurrencyCode();
     $loanCategory = CategoryQuery::create()->findOneById($data['categoryId']);
     $data['nativeAmount'] = $data['amount'];
     // TODO
     $data['amount'] = Converter::toUSD(Money::create($data['nativeAmount'], $data['currencyCode']), $exchangeRate)->getAmount();
     $loan = Loan::createFromData($data);
     $loan->setCategory($loanCategory)->setBorrower($borrower)->setStatus(Loan::OPEN);
     PropelDB::transaction(function ($con) use($loan) {
         $loan->save($con);
         $this->changeLoanStage($con, $loan, null, Loan::OPEN);
     });
     $this->borrowerMailer->sendLoanConfirmation($borrower, $loan);
     // TODO send mail to lenders
     $this->addToLoanIndex($loan);
 }
Example #5
0
 public function getPaginatedComments(Borrower $borrower, $page, $maxPerPage)
 {
     $roots = CommentQuery::create()->filterByBorrowerId($borrower->getId())->filterByLevel(0)->orderById('desc')->paginate($page, $maxPerPage);
     $comments = CommentQuery::create()->filterByRootId($roots->toKeyValue('id', 'id'))->filterByLevel(['min' => 1])->orderById('asc')->find();
     $idToComments = [];
     foreach ($roots as $root) {
         $idToComments[$root->getId()] = $root;
     }
     foreach ($comments as $comment) {
         $idToComments[$comment->getId()] = $comment;
     }
     foreach ($comments as $comment) {
         if (!$comment->isRoot()) {
             $parentComment = $idToComments[$comment->getParentId()];
             $parentComment->addChild($comment);
         }
     }
     return $roots;
 }
Example #6
0
 public function sendDeclinedConfirmationMail(Borrower $borrower)
 {
     $subject = \Lang::get('borrowerActivation.email.declined.subject', ['name' => $borrower->getName()]);
     $data = ['borrowerName' => $borrower->getName(), 'to' => $borrower->getUser()->getEmail(), 'from' => '*****@*****.**', 'subject' => $subject];
     $this->mailer->send('emails.borrower.activation.declined-confirmation', $data);
 }
Example #7
0
 public function isFacebookRequired(Borrower $borrower)
 {
     $user = $borrower->getUser();
     $facebookId = $user->getFacebookId();
     $createdAt = $user->getCreatedAt();
     $requiredDate = \DateTime::createFromFormat('j-M-Y', '1-Jan-2014');
     $borrowerRequiresFacebook = $borrower->getCountry()->isFacebookRequired();
     return $borrowerRequiresFacebook && !$facebookId && $createdAt > $requiredDate;
 }
Example #8
0
 public function getNestedData()
 {
     $data = $this->getData() + $this->borrower->getPersonalInformation();
     return Utility::nestedArray($data);
 }
Example #9
0
 public function getDefaultData()
 {
     return ['isEligibleByAdmin' => $this->borrower->isActivationApproved()];
 }
Example #10
0
 public function getDefaultData()
 {
     $review = $this->borrower->getReview();
     return ['isAddressLocatable' => $review ? $review->getIsAddressLocatable() : true, 'isAddressLocatableNote' => $review ? $review->getIsAddressLocatableNote() : ''];
 }