/** * @param CreateBillsForAccountCommand $command * @return void */ public function handle($command) { $account = $command->getAccount(); $billingPeriod = new \DatePeriod($account->getBillingStartDate(), $account->getBillingInterval(), $account->dateToClose()); foreach ($billingPeriod as $billDate) { $bill = Bill::create($account, $billDate); $this->billRepository->save($bill); } }
/** * @return Response */ public function indexAction() { $accounts = $this->accountRepository->findAll(); $upcomingBills = $this->billRepository->findBillsDue(new \DateInterval('P1M')); return new Response($this->templating->render('@HCLabsBills/Dashboard/index.html.twig', ['accounts' => $accounts, 'upcoming_bills' => $upcomingBills])); }
/** * @param \HCLabs\Bills\Command\Scenario\PayBill\PayBillCommand $command * @return void */ public function handle($command) { $command->getBill()->pay(); $this->billRepository->save($command->getBill()); $this->dispatch('bill.paid', new BillHasBeenPaidEvent($command->getBill())); }