Exemple #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']);
 }
 /**
  * Check historical codes.
  */
 public function testInforForHistoricalCodes()
 {
     $infos = Currency::getInfoForCurrenciesWithHistoricalCode();
     foreach ($infos as $info) {
         $this->assertArrayHasKey('code', $info);
         $this->assertArrayHasKey('isoStatus', $info);
         $this->assertEquals(Currency::ISO_STATUS_HISTORICAL, $info['isoStatus']);
         $this->assertArrayHasKey('decimalDigits', $info);
         $this->assertGreaterThanOrEqual(0, $info['decimalDigits']);
         $this->assertArrayHasKey('name', $info);
     }
 }
 /**
  * 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());
 }