some progress
This commit is contained in:
parent
49eb437fd7
commit
3346a98624
|
@ -703,4 +703,6 @@ class HesabdariController extends AbstractController
|
|||
}
|
||||
return $temp;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,46 +2,155 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Business;
|
||||
use App\Entity\BankAccount;
|
||||
use App\Entity\Year;
|
||||
use App\Service\Log;
|
||||
use App\Service\Jdate;
|
||||
use App\Service\Access;
|
||||
use App\Entity\Business;
|
||||
use App\Entity\Cashdesk;
|
||||
use App\Entity\HesabdariRow;
|
||||
use App\Entity\Person;
|
||||
use App\Entity\Salary;
|
||||
use App\Service\Explore;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
class YearController extends AbstractController
|
||||
{
|
||||
#[Route('/api/year/list', name: 'app_year_list')]
|
||||
public function app_year_list(Request $request,EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_year_list(Request $request, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$business = $entityManager->getRepository(Business::class)->find($request->headers->get('activeBid'));
|
||||
if(!$business)
|
||||
if (!$business)
|
||||
throw $this->createNotFoundException();
|
||||
$years = $entityManager->getRepository(Year::class)->findBy([
|
||||
'bid'=>$business
|
||||
'bid' => $business
|
||||
]);
|
||||
return $this->json($years);
|
||||
}
|
||||
|
||||
#[Route('/api/year/get', name: 'app_year_get')]
|
||||
public function app_year_get(Jdate $jdate,Request $request,EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_year_get(Jdate $jdate, Request $request, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$business = $entityManager->getRepository(Business::class)->find($request->headers->get('activeBid'));
|
||||
if(!$business)
|
||||
if (!$business)
|
||||
throw $this->createNotFoundException();
|
||||
$year = $entityManager->getRepository(Year::class)->find($request->headers->get('activeYear'));
|
||||
if(!$year)
|
||||
if (!$year)
|
||||
throw $this->createNotFoundException();
|
||||
$yearLoad = $entityManager->getRepository(Year::class)->findOneBy([
|
||||
'id'=> $year->getId(),
|
||||
'bid'=>$business
|
||||
'id' => $year->getId(),
|
||||
'bid' => $business
|
||||
]);
|
||||
$yearLoad->setStart($jdate->jdate('Y/m/d',$yearLoad->getStart()));
|
||||
$yearLoad->setEnd($jdate->jdate('Y/m/d',$yearLoad->getEnd()));
|
||||
$yearLoad->setNow($jdate->jdate('Y/m/d',time()));
|
||||
$yearLoad->setStart($jdate->jdate('Y/m/d', $yearLoad->getStart()));
|
||||
$yearLoad->setEnd($jdate->jdate('Y/m/d', $yearLoad->getEnd()));
|
||||
$yearLoad->setNow($jdate->jdate('Y/m/d', time()));
|
||||
return $this->json($yearLoad);
|
||||
}
|
||||
|
||||
#[Route('/api/year/lastyear/info', name: 'app_year_last_year_info')]
|
||||
public function app_year_last_year_info(Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$acc = $access->hasRole('plugAccproCloseYear');
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
//get all banks for calculate
|
||||
$currentYear = $entityManager->getRepository(Year::class)->findOneBy([
|
||||
'bid' => $acc['bid'],
|
||||
'head' => true
|
||||
]);
|
||||
|
||||
//get all banks for calculate
|
||||
$banks = $entityManager->getRepository(BankAccount::class)->findBy([
|
||||
'bid' => $acc['bid'],
|
||||
]);
|
||||
$banksBs = 0;
|
||||
$banksBd = 0;
|
||||
foreach ($banks as $item) {
|
||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'bank' => $item,
|
||||
'year' => $currentYear
|
||||
]);
|
||||
foreach ($rows as $row) {
|
||||
$banksBd += $row->getBd();
|
||||
$banksBs += $row->getBs();
|
||||
}
|
||||
}
|
||||
|
||||
$response = [];
|
||||
$response['banks'] = [
|
||||
'bs' => $banksBs,
|
||||
'bd' => $banksBd
|
||||
];
|
||||
|
||||
//get all cashdesks for calculate
|
||||
$cashdesks = $entityManager->getRepository(Cashdesk::class)->findBy([
|
||||
'bid' => $acc['bid'],
|
||||
]);
|
||||
$cashdesksBs = 0;
|
||||
$cashdesksBd = 0;
|
||||
foreach ($cashdesks as $item) {
|
||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'cashdesk' => $item,
|
||||
'year' => $currentYear
|
||||
]);
|
||||
foreach ($rows as $row) {
|
||||
$cashdesksBd += $row->getBd();
|
||||
$cashdesksBs += $row->getBs();
|
||||
}
|
||||
}
|
||||
$response['cashdesks'] = [
|
||||
'bs' => $cashdesksBs,
|
||||
'bd' => $cashdesksBd
|
||||
];
|
||||
|
||||
//get all salarys for calculate
|
||||
$salarys = $entityManager->getRepository(Salary::class)->findBy([
|
||||
'bid' => $acc['bid'],
|
||||
]);
|
||||
$salarysBs = 0;
|
||||
$salarysBd = 0;
|
||||
foreach ($salarys as $item) {
|
||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'salary' => $item,
|
||||
'year' => $currentYear
|
||||
]);
|
||||
foreach ($rows as $row) {
|
||||
$salarysBd += $row->getBd();
|
||||
$salarysBs += $row->getBs();
|
||||
}
|
||||
}
|
||||
$response['salarys'] = [
|
||||
'bs' => $salarysBs,
|
||||
'bd' => $salarysBd
|
||||
];
|
||||
|
||||
//get all debtor for calculate
|
||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||
'bid' => $acc['bid'],
|
||||
]);
|
||||
$debtorsBs = 0;
|
||||
$debtorsBd = 0;
|
||||
foreach ($persons as $item) {
|
||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'person' => $item,
|
||||
'year' => $currentYear
|
||||
]);
|
||||
foreach ($rows as $row) {
|
||||
$debtorsBd += $row->getBd();
|
||||
$debtorsBs += $row->getBs();
|
||||
}
|
||||
}
|
||||
$response['persons'] = [
|
||||
'bs' => $debtorsBs,
|
||||
'bd' => $debtorsBd
|
||||
];
|
||||
|
||||
$response['year'] = Explore::ExploreYear($currentYear);
|
||||
return $this->json($response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,9 +46,8 @@ class PersonRepository extends ServiceEntityRepository
|
|||
public function searchByNikename(Business $bid,string $search,int $maxResults = 10): array
|
||||
{
|
||||
return $this->createQueryBuilder('p')
|
||||
->andwhere('p.bid = :val')
|
||||
->andWhere("p.nikename LIKE :search")
|
||||
->orWhere("p.mobile LIKE :search")
|
||||
->where('p.bid = :val')
|
||||
->andWhere("p.nikename LIKE :search OR p.mobile LIKE :search")
|
||||
->setParameter('val', $bid)
|
||||
->setParameter('search', '%' . $search . '%')
|
||||
->setMaxResults($maxResults)
|
||||
|
|
Loading…
Reference in a new issue