public function getCashOnDate(User $user, \DateTime $date) { /** @var ClientAccount[] $accounts */ $accounts = $user->getClientAccounts(); $sum = 0; foreach ($accounts as $account) { $systemAccount = $account->getSystemAccount(); if ($systemAccount) { $sum += $this->em->getRepository('WealthbotClientBundle:ClientAccountValue')->getFreeCashBeforeDate($systemAccount, $date); } } return $sum; }
public function createBill(User $user, $dateStr, ObjectManager $manager) { $date = new \DateTime($dateStr); $period = $this->periodManager->getPreviousQuarter($date); $accounts = $user->getClientAccounts(); $bill = new Bill(); $bill->setCreatedAt(new \DateTime($dateStr)); $bill->setClient($user); $bill->setYear($period['year']); $bill->setQuarter($period['quarter']); $manager->persist($bill); foreach ($accounts as $account) { $systemAccount = $account->getSystemAccount(); if ($systemAccount) { $billItem = new BillItem(); $billItem->setSystemAccount($systemAccount); $billItem->setBill($bill); $billItem->setFeeBilled($this->feeManager->getRiaFee($account, $period['year'], $period['quarter'])); $billItem->setCreatedAt(new \DateTime($dateStr)); $manager->persist($billItem); } } $manager->flush(); }