Пример #1
0
 /**
  * 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();
 }
Пример #2
0
 /**
  * @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);
 }
Пример #3
0
 /**
  * @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);
 }