/** * Lists all races and payment amounts for a specific club. * * @Route("/event/{event}/billing/{club}", name="billing_show") * @Method("GET") */ public function showAction(Event $event, Club $club) { $em = $this->getDoctrine()->getManager(); /** @var RaceRepository $raceRepo */ $raceRepo = $em->getRepository('AppBundle:Race'); // $paid = $repo->findBy(array('event' => $event->getId(), 'club' => $club->getId())); $races = $raceRepo->getAllRacesThatHaveRegistrations($event->getId()); $billingPositions = array(); $total = 0.0; /** @var Race $race */ foreach ($races as $race) { $price = $race->getPricePerStarter(); /** @var RaceSection $section */ foreach ($race->getSections() as $section) { /** @var Registration $registration */ foreach ($section->getRegistrations() as $registration) { /** @var Club $myClub */ $myClub = $registration->getTeam()->getClub(); if ($club->getId() == $myClub->getId()) { // TODO handle de-registered and those from other races if (array_key_exists($race->getId(), $billingPositions)) { $billingPositions[$race->getId()]['teams'] += 1; $billingPositions[$race->getId()]['amount'] += $price; } else { $billingPositions[$race->getId()] = array('teams' => 1, 'amount' => $price, 'race' => $race); } $total += $price; } } } } return $this->render('billing/show.html.twig', array('club' => $club, 'event' => $event, 'positions' => $billingPositions, 'rr' => $raceRepo, 'total' => $total)); }
/** * Check if the total paid is equal to the total of open payments * * @param Event $event The event to inspect. * @param Club $club The club for that the check should be done. * @return bool <tt>true</tt> if everything was paid */ public function hasPaidEverything(Event $event, Club $club) { // search for all billings $billings = $this->findBy(array('event' => $event->getId(), 'club' => $club->getId())); $totalPaid = 0.0; /** @var Billing $billing */ foreach ($billings as $billing) { $totalPaid += $billing->getEuro() + $billing->getCent() / 100.0; } $toPay = $this->getTotalToPay($event, $club); return 0 <= $toPay - $totalPaid; }
/** * Creates a form to delete a Club entity. * * @param Club $club The Club entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(Club $club) { return $this->createFormBuilder()->setAction($this->generateUrl('club_delete', array('id' => $club->getId())))->setMethod('DELETE')->getForm(); }