protected function onSuccess(PermanenceReport $report) { //Remove numbers of card $sellcard = $report->getSellCard(); $nbCard = $this->em->getRepository('ESNAdministrationBundle:Card')->getNumberOfCards(); $availableCard = $nbCard - $sellcard; $report->setAmountSell($report->getSellCard() * 5); $report->setOwner($this->user); $Card = new Card(); $Card->setNumber($availableCard); $this->em->persist($Card); $operation = new Operation(); $operation->setMontant($report->getAmountSell()); $operation->setDate(new \DateTime()); $operation->setLibelle("Vente carte ESN pendant la perm"); $operation->setDescription("Vente de " . $report->getSellCard() . " cartes ESN"); $this->em->persist($operation); // CAISSE $montant = $this->em->getRepository('ESNTreasuryBundle:Caisse')->getLastCaisse(); $caisse = new Caisse(); $caisse->setMontant($montant + $operation->getMontant()); $this->em->persist($caisse); if (!$report->getId()) { $this->em->persist($report); } $this->em->flush(); }
protected function onSuccess(ParticipateTrip $participateTrip) { $participateTrip->setDateInscription(new \DateTime()); $operation = new Operation(); $operation->setDate(new \DateTime()); $operation->setDescription("New payment for the trip : " . $participateTrip->getTrip()->getName()); $operation->setLibelle("Payment for a trip"); $operation->setMontant($participateTrip->getTrip()->getPrice()); $montant = $this->em->getRepository('ESNTreasuryBundle:Caisse')->getLastCaisse(); $caisse = new Caisse(); $caisse->setMontant($montant + $operation->getMontant()); $this->em->persist($caisse); $this->em->persist($operation); $this->em->persist($participateTrip); $this->em->flush(); }