progress in cheque and some bug fix

This commit is contained in:
Hesabix 2024-02-19 10:36:57 +00:00
parent 9945c8bb05
commit d451893bc7
5 changed files with 64 additions and 8 deletions

View file

@ -32,9 +32,49 @@ class ChequeController extends AbstractController
'bid'=>$acc['bid'],
'type'=>'input'
]);
return $this->json([
'input'=>Explore::SerializeCheques(array_reverse($chequesInput))
$chequesOutput = $entityManager->getRepository(Cheque::class)->findBy([
'bid'=>$acc['bid'],
'type'=>'output'
]);
return $this->json([
'input'=>Explore::SerializeCheques(array_reverse($chequesInput)),
'output'=>Explore::SerializeCheques(array_reverse($chequesOutput))
]);
}
#[Route('/api/cheque/info/{id}', name: 'app_cheque_info')]
public function app_cheque_info(string $id, Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,Jdate $jdate): JsonResponse
{
$acc = $access->hasRole('cheque');
if(!$acc)
throw $this->createAccessDeniedException();
$cheque = $entityManager->getRepository(Cheque::class)->findOneBy([
'bid'=>$acc['bid'],
'id'=>$id
]);
if(!$cheque)
throw $this->createNotFoundException('cheque not found');
return $this->json(Explore::SerializeCheque($cheque));
}
#[Route('/api/cheque/reject/{id}', name: 'app_cheque_reject')]
public function app_cheque_reject(string $id, Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,Jdate $jdate): JsonResponse
{
$acc = $access->hasRole('cheque');
if(!$acc)
throw $this->createAccessDeniedException();
$cheque = $entityManager->getRepository(Cheque::class)->findOneBy([
'bid'=>$acc['bid'],
'id'=>$id
]);
if(!$cheque)
throw $this->createNotFoundException('cheque not found');
$cheque->setStatus('برگشت خورده');
$cheque->setRejected(true);
$log->insert('بانکداری','چک شماره شماره ' . $cheque->getNumber() . ' به برگشت خورده تغییر یافت. ',$this->getUser(),$request->headers->get('activeBid'));
$entityManager->persist($cheque);
$entityManager->flush();
return $this->json(['result'=>'ok']);
}
#[Route('/api/cheque/pass/{id}', name: 'app_cheque_pass')]

View file

@ -347,10 +347,10 @@ class HesabdariController extends AbstractController
elseif ($person->getBid()->getId() != $acc['bid']->getId()) throw $this->createAccessDeniedException('person is not in this business');
$hesabdariRow->setPerson($person);
}
if($row['type'] == 'cheque'){
elseif($row['type'] == 'cheque'){
$person = $entityManager->getRepository(Person::class)->findOneBy([
'bid'=> $acc['bid'],
'id'=>$row['person']
'id'=>$row['chequeOwner']
]);
$cheque = new Cheque();
$cheque->setBid($acc['bid']);
@ -373,6 +373,7 @@ class HesabdariController extends AbstractController
else
$cheque->setAmount($hesabdariRow->getBs());
$cheque->setLocked(false);
$cheque->setRejected(false);
$cheque->setStatus('پاس نشده');
$entityManager->persist($cheque);
$entityManager->flush();

View file

@ -49,7 +49,7 @@ class SupportController extends AbstractController
]);
}
#[Route('/api/admin/support/mod/{id}', name: 'app_admin_support_mod')]
public function app_admin_support_mod(SMS $SMS,Request $request, EntityManagerInterface $entityManager,string $id = '',Notification $notifi): JsonResponse
public function app_admin_support_mod(SMS $SMS,Request $request, EntityManagerInterface $entityManager,Notification $notifi,string $id = ''): JsonResponse
{
$params = [];
if ($content = $request->getContent()) {

View file

@ -71,6 +71,9 @@ class Cheque
#[ORM\Column(length: 255, nullable: true)]
private ?string $date = null;
#[ORM\Column(nullable: true)]
private ?bool $rejected = null;
public function __construct()
{
$this->hesabdariRows = new ArrayCollection();
@ -315,4 +318,16 @@ class Cheque
return $this;
}
public function isRejected(): ?bool
{
return $this->rejected;
}
public function setRejected(?bool $rejected): static
{
$this->rejected = $rejected;
return $this;
}
}

View file

@ -223,8 +223,8 @@ class Explore{
'amount'=>$cheque->getAmount(),
'status'=>$cheque->getStatus(),
'date'=>$cheque->getDate(),
'locked'=>$cheque->isLocked()
'locked'=>$cheque->isLocked(),
'rejected'=>$cheque->isRejected()
];
}