Exemplo n.º 1
0
 /**
  * @param ClientAccount $account
  * @param Bill $bill
  * @param integer $year
  * @param integer $quarter
  * @param bool $flush
  * @return BillItem
  */
 public function createBillItem(ClientAccount $account, Bill $bill, $flush = true)
 {
     $sysAccount = $account->getSystemAccount();
     $year = $bill->getYear();
     $quarter = $bill->getQuarter();
     $riaFee = $this->getRiaBillSumByPeriod($account, $year, $quarter);
     $adminFee = $this->getAdminBillSumByPeriod($account, $year, $quarter);
     $billItem = new BillItem();
     $billItem->setSystemAccount($sysAccount);
     $billItem->setBill($bill);
     $billItem->setFeeBilled($riaFee + $adminFee);
     $billItem->setRiaFee($riaFee);
     $billItem->setAdminFee($adminFee);
     $billItem->setCreatedAt(new \DateTime());
     $billItem->setStatus(BillItem::STATUS_BILL_GENERATED);
     $this->em->persist($billItem);
     $flush && $this->em->flush();
     return $billItem;
 }
Exemplo n.º 2
0
 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();
 }