示例#1
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);
 }
示例#2
0
 public function minimumAmount()
 {
     $amountUsd = Money::create(Setting::get('loan.minimumAmount'));
     $amount = Converter::fromUSD($amountUsd, $this->currency, $this->exchangeRate);
     return $amount->floor();
 }