Exemplo n.º 1
0
 public function postEditBid()
 {
     $data = \Input::all();
     $lender = \Auth::user()->getLender();
     $loan = LoanQuery::create()->filterById($data['loanId'])->findOne();
     $totalLoanAmount = $loan->getAmount();
     $amount = Money::valueOf($data['amount'], Currency::valueOf('USD'));
     $oldBid = BidQuery::create()->filterByLender($lender)->filterByLoan($loan)->findOne();
     if ($oldBid->getBidAmount()->compare($amount) != -1) {
         \Flash::error(\Lang::get('Loan.edit-bid.amount'));
         return Redirect::back()->withInput();
     }
     if ($totalLoanAmount->getAmount() <= $data['amount']) {
         \Flash::error(\Lang::get('Loan.edit-bid.interest-rate'));
         return Redirect::back()->withInput();
     }
     if ($data['interestRate'] <= $oldBid->getInterestRate()) {
         \Flash::error(\Lang::get('Loan.edit-bid.bid-amount-exceded'));
         return Redirect::back()->withInput();
     }
     $bid = BidQuery::create()->filterByLoan($loan)->filterByLender($lender)->findOne();
     $this->loanService->editBid($bid, $data);
     Flash::success(\Lang::get('Loan.edit-bid.success') . $data['amount']);
     return Redirect::route('loan:index', $data['loanId']);
 }
Exemplo n.º 2
0
 /**
  * Test different rounding modes.
  *
  * @param string $mode          the mode to test
  * @param int    $decimalDigits the decimal digits to round to
  * @param string $given         the given input
  * @param string $expected      the expected output
  *
  * @dataProvider roundingDataProvider
  */
 public function testRounding($mode, $decimalDigits, $given, $expected)
 {
     $money = Money::valueOf($given, Currency::valueOf(Currency::TEST));
     $actual = $money->round($decimalDigits, $mode);
     $this->assertSame($expected, $actual->getAmount());
 }