Skip to content

Instantly share code, notes, and snippets.

@aliemre
Created April 9, 2016 13:08
Show Gist options
  • Save aliemre/49c6ec05c3c8e5e4d569b79a8ee8cbec to your computer and use it in GitHub Desktop.
Save aliemre/49c6ec05c3c8e5e4d569b79a8ee8cbec to your computer and use it in GitHub Desktop.
The Service
<?php
namespace System\ReportBundle\Service;
use Doctrine\ORM\EntityManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
class TYHWebService
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $title;
/**
* @var string
*/
private $slug;
/**
* @var string
*/
private $uuId;
/**
* @var string
*/
private $taxNumber;
/**
* @var string
*/
private $billType;
/**
* @var \DateTime
*/
private $createDate;
/**
* @var string
*/
private $documentNumber;
/**
* @var \DateTime
*/
private $expirationDate;
/**
* @var string
*/
private $costPrice;
/**
* @var string
*/
private $discountPrice;
/**
* @var string
*/
private $extraTaxPrice;
/**
* @var string
*/
private $totalPrice;
/**
* @var string
*/
private $currencyType;
/**
* @var string
*/
private $currencyValue;
/**
* @var string
*/
private $day;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var \DateTime
*/
private $updateAt;
/**
* @var \DateTime
*/
private $deletedAt;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $galleries;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $images;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $receipts;
/**
* @var string
*/
private $locale;
/**
* @var ContainerInterface
*/
private $container;
/**
* @var EntityManager
*/
private $em;
/**
* Constructor
* @param ContainerInterface $containerInterface
* @param EntityManager $entityManager
*/
public function __construct(ContainerInterface $containerInterface, EntityManager $entityManager)
{
$this->container = $containerInterface;
$this->em = $entityManager;
}
/**
* Get Expenses
*
* @param $startDate
* @param $endDate
*
* @return array
*/
public function getExpenses($startDate, $endDate)
{
$qb = $this->em->createQueryBuilder();
$qb
->select('e')
->from('SystemReportBundle:Expense', 'e')
->where(
$qb->expr()->between('e.createDate', ':startDate', ':endDate')
)
->setParameters(array(
'startDate' => $startDate,
'endDate' => $endDate
));
return $qb->getQuery()->getResult();
}
/**
* Get Receipts
*
* @param $expenseId
*
* @return array
*/
public function getReceiptsByExpense($expenseId)
{
$qb = $this->em->createQueryBuilder();
$qb
->select('r')
->from('SystemReportBundle:Receipt', 'r')
->leftJoin('r.expense', 're', 'WITH', 're.id = r.id');
return $qb->getQuery()->getResult();
}
/**
* Get Declarations
*
* @param $startDate
* @param $endDate
*
* @return array
*/
public function getDeclarations($startDate, $endDate)
{
$qb = $this->em->createQueryBuilder();
$qb
->select('d')
->from('SystemReportBundle:Declaration', 'd')
->where(
$qb->expr()->between('d.declarationDate', ':startDate', ':endDate')
)
->setParameters(array(
'startDate' => $startDate,
'endDate' => $endDate
));
return array('GetDeclarations' => $qb->getQuery()->getResult());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment