/** * Makes array of ClientAccount which must be used for Custodian Fee File generator. * * @param $riaUser * @param $selectedAccounts * @param $year * @param $quarter * * @return array * @throws \Exception */ public function getAccountsForCustodianFeeFile($riaUser, $selectedAccounts, $year, $quarter) { $now = new \DateTime(); $interval = new \DateInterval('P3D'); $periods = $this->periodManager->getPeriod($year, $quarter); /* @var ClientAccountRepository $clientAccountRepo */ $clientAccountRepo = $this->em->getRepository('WealthbotClientBundle:ClientAccount'); $accounts = $clientAccountRepo->filterAccountsForCustodianFeeFile($riaUser, $selectedAccounts, $periods['endDate']); $firstAccount = reset($accounts); if ($firstAccount) { $approveDate = $this->summaryInformationManager->getClientBillApproveDate($firstAccount->getClient(), $year, $quarter); if ($now->sub($interval) < $approveDate) { throw new \Exception('You must wait 3 days after bill approval in order to create Custodian Fee File'); } } return $accounts; }
public function getBillItemStatus(ClientAccount $account, $year, $quarter) { $period = $this->periodManager->getPeriod($year, $quarter); $systemAccount = $account->getSystemAccount(); if (!$systemAccount) { return BillItem::STATUS_BILL_IS_NOT_APPLICABLE; } $activityCheck = $this->em->getRepository('WealthbotClientBundle:ClientAccountValue')->getFirstActivityDate($account); if (!$activityCheck || $activityCheck->getDate()->getTimestamp() >= $period['endDate']->getTimestamp()) { return BillItem::STATUS_BILL_IS_NOT_APPLICABLE; } /** @var BillItem $billItem */ $billItem = $this->em->getRepository('WealthbotClientBundle:BillItem')->getByAccountAndPeriod($account, $year, $quarter); if ($billItem) { return $billItem->getStatus(); } return BillItem::STATUS_BILL_NOT_GENERATED; }
/** * @param int $year * @param int $quarter * @return array */ public function getPeriod($year, $quarter) { return $this->periodManager->getPeriod($year, $quarter); }