Пример #1
0
 /**
  * @param User $client
  * @param integer $year
  * @param integer $quarter
  * @param bool $flush
  * @return Bill
  */
 public function createBill(User $client, $year, $quarter, $flush = true)
 {
     $bill = new Bill();
     $bill->setCreatedAt(new \DateTime());
     $bill->setClient($client);
     $bill->setYear($year);
     $bill->setQuarter($quarter);
     $this->em->persist($bill);
     if ($flush) {
         $this->em->flush();
     }
     return $bill;
 }
Пример #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();
 }