protected function execute(InputInterface $input, OutputInterface $output) { $this->em = $this->getContainer()->get('doctrine')->getManager(); $locks = $this->em->getRepository('ApplicationSonataClientOperationsBundle:Locking')->findBy(array(), array('year' => 'ASC', 'month' => 'ASC', 'client_id' => 'ASC')); $clients = $clientDeclarations = $clientDeclarationComputations = array(); foreach ($locks as $lock) { $rapState = $this->em->getRepository('ApplicationSonataClientOperationsBundle:RapprochementState')->findOneBy(array('client_id' => $lock->getClientId(), 'month' => $lock->getMonth(), 'year' => $lock->getYear())); if (!$rapState) { $rapState = new RapprochementState(); $rapState->setClientId($lock->getClientId())->setMonth($lock->getMonth())->setYear($lock->getYear()); } $key = sha1($lock->getClientId() . $lock->getYear() . $lock->getMonth()); if (!isset($clients[$key])) { $client = $this->em->getRepository('ApplicationSonataClientBundle:Client')->findOneBy(array('id' => $lock->getClientId())); if (!$client) { continue; } $clients[$key] = $client; } if (!isset($clientDeclarations[$key])) { $clientDeclaration = new ClientDeclaration($clients[$key]); $clientDeclaration->setYear($lock->getYear())->setMonth($lock->getMonth()); $clientDeclarations[$key] = $clientDeclaration; $clientDeclarationComputations[$key] = new ClientDeclarationComputation($clientDeclaration); } $realCreditTvaAReporter = $clientDeclarationComputations[$key]->getCreditOfVATCarriedForward(); $rapState->setRealCreditTvaAReporter($realCreditTvaAReporter); $this->em->persist($rapState); $this->em->flush(); } }
public function getDeclaration($year = null, $month = null) { static $instances = array(); if (is_null($year) || is_null($month)) { $now = new \DateTime(); $dateQuery = $now->format('d') > 25 ? $now : new \DateTime('now -1 month'); $year = $dateQuery->format('Y'); $month = $dateQuery->format('m'); } $key = sha1($this->getId() . $year . $month); if (!isset($instances[$key])) { $clientDeclaration = new ClientDeclaration($this); $clientDeclaration->setShowAllOperations(false)->setYear($year)->setMonth($month); $instances[$key] = $clientDeclaration; } return $instances[$key]; }
/** * @return \Symfony\Component\HttpFoundation\Response */ public function declarationAction() { $client = $this->getClient(); $clientDeclaration = new ClientDeclaration($client); $clientDeclaration->setShowAllOperations($this->_show_all_operations)->setYear($this->_year)->setMonth($this->_month)->setQueryMonth($this->_query_month); $this->get('request')->setLocale(strtolower($client->getLanguage())); /** @var $em \Doctrine\ORM\EntityManager */ $em = $this->getDoctrine()->getManager(); /** @var $bank \Application\Sonata\ClientBundle\Entity\Coordonnees */ $bank = $em->getRepository('ApplicationSonataClientBundle:Coordonnees')->findOneBy(array()); $debug = isset($_GET['d']); $page = $this->render('ApplicationSonataClientOperationsBundle::declaration.html.twig', array('info' => array('time' => strtotime($this->_year . '-' . $this->_month . '-01'), 'month' => $this->_month, 'year' => $this->_year, 'quarter' => floor(($this->_month - 1) / 3) + 1), 'debug' => $debug, 'client' => $client, 'bank' => $bank, 'rapState' => $clientDeclaration->getRapprochementState(), 'V01TVAlist' => $clientDeclaration->getV01TVAList(), 'V07EXlist' => $clientDeclaration->getV07EXList(), 'V05LIClist' => $clientDeclaration->getV05LICList(), 'V03283Ilist' => $clientDeclaration->getV03283IList(), 'V11INTlist' => $clientDeclaration->getV11INTList(), 'A02TVAlist' => $clientDeclaration->getA02TVAList(), 'A08IMlist' => $clientDeclaration->getA08IMList(), 'A02TVAPrevlist' => $clientDeclaration->getA02TVAPrevList(), 'A08IMPrevlist' => $clientDeclaration->getA08IMPrevList(), 'A06AIBlist' => $clientDeclaration->getA06AIBList(), 'A04283Ilist' => $clientDeclaration->getA04283IList(), 'A10CAFlist' => $clientDeclaration->getA10CAFList(), 'A04283ISumPrev' => $clientDeclaration->getA04283ISumPrev(), 'A06AIBSumPrev' => $clientDeclaration->getA06AIBSumPrev(), 'RulingNettTotal' => $clientDeclaration->getRulingNettTotal(), 'RulingVatTotal' => $clientDeclaration->getRulingVatTotal(), 'Total1' => $clientDeclaration->getTotalVat1(), 'Total2' => $clientDeclaration->getTotalVat2(), 'SoldeTVATotal' => $clientDeclaration->getSoldeTVATotal(), 'RealSoldeTVATotal' => $clientDeclaration->getRealSoldeTVATotal(), 'TotalBalance' => $clientDeclaration->getTotalBalance(), 'PreviousCreditDeTVA' => $clientDeclaration->getPreviousMonth()->getAbsCreditOfVATCarriedForward(), 'SoldeTVATotalPlusPreviousCreditDeTVA' => $clientDeclaration->getSoldeTVATotalPlusPreviousCreditDeTVA(), 'ClientDeclaration' => $clientDeclaration, 'ClientDeclarationComputation' => new ClientDeclarationComputation($clientDeclaration), 'locked' => $this->getLocking())); if (!$debug) { $mpdf = new mPDF('c', 'A4', 0, '', 15, 15, 10, 13, 9, 2); //$mpdf->SetDisplayMode('fullpage'); //$mpdf->SetHeader('test header', 'E'); $mpdf->WriteHTML($page->getContent()); $mpdf->Output(); exit; } return $page; }
public function getPreviousMonth() { static $instances = array(); $lastMonth = new \DateTime("{$this->_year}-{$this->_month}-01 -1 month"); $_year = $lastMonth->format('Y'); $_month = $lastMonth->format('m'); $key = sha1($this->client->getId() . $_year . $_month); if (!isset($instances[$key])) { //$instances[$key] = $this->findRappState($_year, $_month); $prevMonthClientDeclaration = new ClientDeclaration($this->client); $prevMonthClientDeclaration->setShowAllOperations($this->_show_all_operations)->setYear($_year)->setMonth($_month); $instances[$key] = $prevMonthClientDeclaration; } return $instances[$key]; }
public function __construct(ClientDeclaration $clientDeclaration) { $this->currentClientDeclaration = $clientDeclaration; $this->previousMonthClientDeclaration = $clientDeclaration->getPreviousMonth(); }
protected function setRealCreditTvaAReporter() { $em = $this->getDoctrine()->getManager(); $rapState = $em->getRepository('ApplicationSonataClientOperationsBundle:RapprochementState')->findOneBy(array('client_id' => $this->_client_id, 'month' => $this->_month, 'year' => $this->_year)); if (!$rapState) { $rapState = new RapprochementState(); $rapState->setClientId($this->_client_id)->setMonth($this->_month)->setYear($this->_year); } $clientDeclaration = new ClientDeclaration($this->_client); $clientDeclaration->setYear($this->_year)->setMonth($this->_month); $clientDeclarationComputation = new ClientDeclarationComputation($clientDeclaration); $realCreditTvaAReporter = $clientDeclarationComputation->getCreditOfVATCarriedForward(); $rapState->setRealCreditTvaAReporter($realCreditTvaAReporter); $em->persist($rapState); $em->flush(); }