Exemple #1
0
 protected function refundLenders(ConnectionInterface $con, Loan $loan, $status = Loan::EXPIRED)
 {
     $transactions = TransactionQuery::create()->filterByLoan($loan)->filterLoanBids()->find();
     $refunds = $this->getLenderRefunds($transactions);
     foreach ($refunds as $refund) {
         if (!$refund['refundAmount']->greaterThan(Money::create(0))) {
             continue;
         }
         if ($status == Loan::CANCELED) {
             $this->transactionService->addLoanBidCanceledTransaction($con, $refund['refundAmount'], $loan, $refund['lender']);
         } else {
             $this->transactionService->addLoanBidExpiredTransaction($con, $refund['refundAmount'], $loan, $refund['lender']);
         }
     }
     // TODO: lender invite
     return $refunds;
 }