Ejemplo n.º 1
0
 public function getCountry()
 {
     if ($this->country === null) {
         $this->country = $this->borrower->getCountry();
     }
     return $this->country;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
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;
 }