/** * @param ClientAccount $account * @param float $fee * @param int $year * @param int $quarter * @return float|int */ public function calculateBillSumByPeriod(ClientAccount $account, $fee, $year, $quarter) { $period = $this->feeManager->getPeriod($year, $quarter); $systemAccount = $account->getSystemAccount(); $accountValues = $this->em->getRepository('WealthbotClientBundle:ClientAccountValue')->getAverageAccountValues($account, $period['startDate'], $period['endDate']); $dayInPeriod = $period['endDate']->diff($period['startDate'])->format('%a'); return $this->feeManager->calculateFeeBilled($fee, $accountValues['count_values'], $dayInPeriod); }
public function getPortfolioInformation(User $user, CeModelInterface $model, $isQualified = false) { if ($user->hasRole('ROLE_CLIENT')) { $ria = $user->getRia(); } else { $ria = $user; } $portfolioInformation = new PortfolioInformation(); $portfolioInformation->setUser($user); $portfolioInformation->setModel($model); $portfolioInformation->setIsQualifiedModel($isQualified); $portfolioInformation->setFees($this->feeManager->getClientFees($ria)); if ($model->getOwner()->hasRole('ROLE_RIA')) { $transactionCommissionFees = $this->em->getRepository('WealthbotAdminBundle:SecurityAssignment')->findMinAndMaxTransactionFeeForModel($model->getParentId()); $portfolioInformation->setTransactionCommissionFees(array_values($transactionCommissionFees)); } return $portfolioInformation; }
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(); }
public function testFeeBilled() { $feeManager = new FeeManager($this->getMockEntityManager(), $this->getUserManagerMock(), $this->getMockCashCalculationManager(), $this->getMockPeriodManager(), $this->getMockBillingSpecManager()); $fees = $this->returnFees(); $fee = $feeManager->calculateFee(600000, $fees); $c = $feeManager->calculateFeeBilled($fee, 30, 45); $this->assertEquals(11000.0, $c, "Invalid calculated fee billed (FeeManager::calculateFeeBilled): {$c}"); }