/** * Removes all tax rates from invoices. * * @param Tax $tax */ public function removeTax(Tax $tax) { if (Tax::TYPE_EXCLUSIVE === $tax->getType()) { $qb = $this->createQueryBuilder('i'); $query = $qb->where('i.tax = :tax')->setParameter('tax', $tax)->groupBy('i.quote')->getQuery(); /** @var Quote $quote */ foreach ($query->execute() as $quote) { $quote->setTotal($quote->getBaseTotal() + $quote->getTax()); $quote->setTax(null); $this->getEntityManager()->persist($quote); } $this->getEntityManager()->flush(); } $qb = $this->createQueryBuilder('q')->update()->set('q.tax', 'NULL')->where('q.tax = :tax')->setParameter('tax', $tax); $qb->getQuery()->execute(); }
/** * @param Tax $tax * * @return JsonResponse */ public function getAction(Tax $tax) { $result = array('id' => $tax->getId(), 'name' => $tax->getName(), 'type' => $tax->getType(), 'rate' => $tax->getRate()); return new JsonResponse($result); }
/** * @param Tax $tax * * @return JsonResponse */ public function getAction(Tax $tax) { $result = ['id' => $tax->getId(), 'name' => $tax->getName(), 'type' => $tax->getType(), 'rate' => $tax->getRate()]; return $this->json($result); }