From ebca717c49907d32f846a9fc1c4c087d54060e02 Mon Sep 17 00:00:00 2001 From: babak alizadeh Date: Wed, 14 Feb 2024 18:26:11 +0000 Subject: [PATCH] start working on cheques part --- hesabixCore/src/Controller/BusinessController.php | 4 ++++ hesabixCore/src/Controller/BuyController.php | 14 ++++++++++++++ .../src/Controller/HesabdariController.php | 4 +++- hesabixCore/src/Entity/Permission.php | 15 +++++++++++++++ hesabixCore/src/Service/Explore.php | 12 ++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/hesabixCore/src/Controller/BusinessController.php b/hesabixCore/src/Controller/BusinessController.php index 59a6a16..6516f8a 100644 --- a/hesabixCore/src/Controller/BusinessController.php +++ b/hesabixCore/src/Controller/BusinessController.php @@ -213,6 +213,7 @@ class BusinessController extends AbstractController $perms->setSell(true); $perms->setCost(true); $perms->setIncome(true); + $perms->setCheque(true); $perms->setReport(true); $perms->setAccounting(true); $perms->setLog(true); @@ -382,6 +383,7 @@ class BusinessController extends AbstractController 'settings'=>true, 'persons'=>true, 'commodity'=>true, + 'cheque'=>true, 'getpay'=>true, 'store'=>true, 'bank'=>true, @@ -423,6 +425,7 @@ class BusinessController extends AbstractController 'cost'=>$perm->isCost(), 'income'=>$perm->isIncome(), 'buy'=>$perm->isBuy(), + 'cheque'=>$perm->isCheque(), 'sell'=>$perm->isSell(), 'accounting'=>$perm->isAccounting(), 'report'=>$perm->isReport(), @@ -489,6 +492,7 @@ class BusinessController extends AbstractController $perm->setStore($params['store']); $perm->setCost($params['cost']); $perm->setIncome($params['income']); + $perm->setCheque($params['cheque']); $perm->setAccounting($params['accounting']); $perm->setReport($params['report']); $perm->setPermission($params['permission']); diff --git a/hesabixCore/src/Controller/BuyController.php b/hesabixCore/src/Controller/BuyController.php index ef282f9..bb980b5 100644 --- a/hesabixCore/src/Controller/BuyController.php +++ b/hesabixCore/src/Controller/BuyController.php @@ -58,4 +58,18 @@ class BuyController extends AbstractController return $this->json(ServiceExplore::ExploreBuyDoc($doc)); } + + #[Route('/api/buy/get/invoices/list', name: 'app_buy_get_invoices_list')] + public function app_buy_get_invoices_list(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager, string $code): JsonResponse + { + $acc = $access->hasRole('buy'); + if(!$acc) + throw $this->createAccessDeniedException(); + $invoices = $entityManager->getRepository(HesabdariDoc::class)->findBy([ + 'bid'=>$acc['bid'], + 'year'=>$acc['year'], + 'type'=>'buy' + ]); + return $this->json(ServiceExplore::ExploreBuyDocsList($invoices)); + } } diff --git a/hesabixCore/src/Controller/HesabdariController.php b/hesabixCore/src/Controller/HesabdariController.php index 62dda6f..c47158b 100644 --- a/hesabixCore/src/Controller/HesabdariController.php +++ b/hesabixCore/src/Controller/HesabdariController.php @@ -178,8 +178,10 @@ class HesabdariController extends AbstractController elseif($params['type'] == 'cost') $roll='cost'; elseif($params['type'] == 'income') $roll='income'; elseif($params['type'] == 'buy') $roll='buy'; + elseif($params['type'] == 'buy_rfb') $roll='buy'; elseif($params['type'] == 'transfer') $roll='transfer'; elseif($params['type'] == 'sell') $roll='sell'; + elseif($params['type'] == 'sell_rbs') $roll='buy'; elseif($params['type'] == 'all') $roll='accounting'; else $this->createNotFoundException(); @@ -216,7 +218,7 @@ class HesabdariController extends AbstractController 'amount'=>$item->getAmount(), 'submitter'=> $item->getSubmitter()->getFullName(), ]; - if($params['type'] == 'buy' || $params['type'] == 'sell'){ + if($params['type'] == 'sell_rbs' || $params['type'] == 'buy_rfb' || $params['type'] == 'buy' || $params['type'] == 'sell'){ $mainRow = $entityManager->getRepository(HesabdariRow::class)->getNotEqual($item,'person'); $temp['person'] = ''; if($mainRow) diff --git a/hesabixCore/src/Entity/Permission.php b/hesabixCore/src/Entity/Permission.php index 4e4a94f..b4737b7 100644 --- a/hesabixCore/src/Entity/Permission.php +++ b/hesabixCore/src/Entity/Permission.php @@ -102,6 +102,9 @@ class Permission #[ORM\Column(nullable: true)] private ?bool $archiveView = null; + #[ORM\Column(nullable: true)] + private ?bool $cheque = null; + public function getId(): ?int { return $this->id; @@ -454,4 +457,16 @@ class Permission return $this; } + + public function isCheque(): ?bool + { + return $this->cheque; + } + + public function setCheque(?bool $cheque): static + { + $this->cheque = $cheque; + + return $this; + } } diff --git a/hesabixCore/src/Service/Explore.php b/hesabixCore/src/Service/Explore.php index de80f16..16744a5 100644 --- a/hesabixCore/src/Service/Explore.php +++ b/hesabixCore/src/Service/Explore.php @@ -193,4 +193,16 @@ class Explore{ ]; } + public static function ExploreBuyDocsList(array $items){ + $result = []; + foreach($items as $item){ + $result[] = [ + 'id'=>$item->getId(), + 'date'=>$item->getDate(), + 'des'=>$item->getDes(), + ]; + } + return $result; + } + } \ No newline at end of file