/**
  * @param array $accounts
  * @param $year
  * @param $quarter
  * @param $billItemStatus
  *
  * @return array
  */
 public function getAccountsInfo(array $accounts, $year, $quarter, $billItemStatus = null)
 {
     $data = array();
     $total = 0;
     $period = $this->periodManager->getPeriod($year, $quarter);
     foreach ($accounts as $account) {
         $billItem = $this->em->getRepository('WealthbotClientBundle:BillItem')->getByAccountAndPeriod($account, $year, $quarter);
         $feeBilled = $this->summaryInformationManager->getAccountFeeBilled($account, $year, $quarter);
         $item = array('name' => $account->getOwnerNames(), 'type' => SystemAccount::getTypeName($account->getSystemType()), 'number' => $this->summaryInformationManager->getAccountNumber($account), 'status' => $this->summaryInformationManager->getAccountStatus($account), 'averageAccountValue' => $this->summaryInformationManager->getAccountAverageValue($account, $period['startDate'], $period['endDate']), 'daysInPortfolio' => $this->summaryInformationManager->getAccountDaysInPortfolio($account, $period['startDate'], $period['endDate']), 'fee' => $feeBilled);
         if (!empty($billItemStatus)) {
             if ($billItem && $billItem->getStatus() == $billItemStatus) {
                 $data[] = $item;
             }
         } else {
             $data[] = $item;
         }
         $total += $feeBilled;
     }
     return array($data, $total);
 }