From d09149f91689a44f819f5f1728ba7932882b7a25 Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Thu, 10 Apr 2025 17:08:12 +0000 Subject: [PATCH] progress in cheque part --- .../src/Controller/AdminController.php | 24 +- .../src/Controller/ChequeController.php | 360 ++++++++++++-- webUI/src/components/forms/Hpersonsearch.vue | 4 +- webUI/src/i18n/fa_lang.ts | 10 +- webUI/src/router/index.ts | 6 + webUI/src/views/acc/cheque/input.vue | 74 ++- webUI/src/views/acc/cheque/list.vue | 464 ++++++++++++++++-- webUI/src/views/acc/cheque/transfer.vue | 209 ++++++++ .../views/acc/component/cheque/passCheck.vue | 303 +++++++----- .../user/manager/settings/sms/smsSettings.vue | 76 ++- 10 files changed, 1278 insertions(+), 252 deletions(-) create mode 100644 webUI/src/views/acc/cheque/transfer.vue diff --git a/hesabixCore/src/Controller/AdminController.php b/hesabixCore/src/Controller/AdminController.php index 1bc2acc..64f8e24 100644 --- a/hesabixCore/src/Controller/AdminController.php +++ b/hesabixCore/src/Controller/AdminController.php @@ -340,10 +340,13 @@ class AdminController extends AbstractController $resp['fromNum'] = $registryMGR->get('sms', 'fromNum'); $resp['sharefaktor'] = $registryMGR->get('sms', 'sharefaktor'); $resp['plan'] = $registryMGR->get('sms', 'plan'); + $resp['chequeInput'] = $registryMGR->get('sms', 'chequeInput'); + $resp['passChequeInput'] = $registryMGR->get('sms', 'passChequeInput'); + $resp['rejectChequeInput'] = $registryMGR->get('sms', 'rejectChequeInput'); $resp['plugRepservice'] = [ 'get' => $registryMGR->get('sms', 'plugRepserviceStateGet'), 'getback' => $registryMGR->get('sms', 'plugRepserviceStateGetback'), - 'repired' => $registryMGR->get('sms', 'plugRepserviceStateRepaired'), + 'repaired' => $registryMGR->get('sms', 'plugRepserviceStateRepaired'), 'unrepaired' => $registryMGR->get('sms', 'plugRepserviceStateUnrepired'), 'creating' => $registryMGR->get('sms', 'plugRepserviceStateCreating'), 'created' => $registryMGR->get('sms', 'plugRepserviceStateCreated') @@ -352,6 +355,9 @@ class AdminController extends AbstractController 'sharefaktor' => $registryMGR->get('sms', 'plugAccproSharefaktor'), 'storeroomSmsOther' => $registryMGR->get('sms', 'plugAccproStoreroomSmsOther'), 'storeroomSmsBarbari' => $registryMGR->get('sms', 'plugAccproStoreroomSmsBarbari'), + 'chequeInput' => $registryMGR->get('sms', 'plugAccproChequeInput'), + 'passChequeInput' => $registryMGR->get('sms', 'plugAccproPassChequeInput'), + 'rejectChequeInput' => $registryMGR->get('sms', 'plugAccproRejectChequeInput') ]; return $this->json($resp); } @@ -389,12 +395,18 @@ class AdminController extends AbstractController $registryMGR->update('sms', 'sharefaktor', $params['sharefaktor']); if (array_key_exists('plan', $params)) $registryMGR->update('sms', 'plan', $params['plan']); + if (array_key_exists('chequeInput', $params)) + $registryMGR->update('sms', 'chequeInput', $params['chequeInput']); + if (array_key_exists('passChequeInput', $params)) + $registryMGR->update('sms', 'passChequeInput', $params['passChequeInput']); + if (array_key_exists('rejectChequeInput', $params)) + $registryMGR->update('sms', 'rejectChequeInput', $params['rejectChequeInput']); if (array_key_exists('plugRepservice', $params)) { if (array_key_exists('get', $params['plugRepservice'])) $registryMGR->update('sms', 'plugRepserviceStateGet', $params['plugRepservice']['get']); - if (array_key_exists('repired', $params['plugRepservice'])) - $registryMGR->update('sms', 'plugRepserviceStateRepaired', $params['plugRepservice']['repired']); + if (array_key_exists('repaired', $params['plugRepservice'])) + $registryMGR->update('sms', 'plugRepserviceStateRepaired', $params['plugRepservice']['repaired']); if (array_key_exists('unrepaired', $params['plugRepservice'])) $registryMGR->update('sms', 'plugRepserviceStateUnrepired', $params['plugRepservice']['unrepaired']); if (array_key_exists('getback', $params['plugRepservice'])) @@ -411,6 +423,12 @@ class AdminController extends AbstractController $registryMGR->update('sms', 'plugAccproStoreroomSmsBarbari', $params['plugAccpro']['storeroomSmsBarbari']); if (array_key_exists('storeroomSmsOther', $params['plugAccpro'])) $registryMGR->update('sms', 'plugAccproStoreroomSmsOther', $params['plugAccpro']['storeroomSmsOther']); + if (array_key_exists('chequeInput', $params['plugAccpro'])) + $registryMGR->update('sms', 'plugAccproChequeInput', $params['plugAccpro']['chequeInput']); + if (array_key_exists('passChequeInput', $params['plugAccpro'])) + $registryMGR->update('sms', 'plugAccproPassChequeInput', $params['plugAccpro']['passChequeInput']); + if (array_key_exists('rejectChequeInput', $params['plugAccpro'])) + $registryMGR->update('sms', 'plugAccproRejectChequeInput', $params['plugAccpro']['rejectChequeInput']); } return $this->json(JsonResp::success()); diff --git a/hesabixCore/src/Controller/ChequeController.php b/hesabixCore/src/Controller/ChequeController.php index 1837423..aea6fb8 100644 --- a/hesabixCore/src/Controller/ChequeController.php +++ b/hesabixCore/src/Controller/ChequeController.php @@ -7,117 +7,123 @@ use App\Entity\Cheque; use App\Entity\HesabdariDoc; use App\Entity\HesabdariRow; use App\Entity\HesabdariTable; +use App\Entity\Person; use App\Service\Log; use App\Service\Jdate; use App\Service\Access; use App\Service\Explore; use App\Service\JsonResp; use App\Service\Provider; +use App\Service\SMS; +use App\Service\PluginService; +use App\Service\RegistryMGR; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class ChequeController extends AbstractController { #[Route('/api/cheque/list', name: 'app_cheque_list')] - public function app_accounting_insert(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,Jdate $jdate): JsonResponse + public function app_accounting_insert(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, Jdate $jdate): JsonResponse { $acc = $access->hasRole('cheque'); - if(!$acc) + if (!$acc) throw $this->createAccessDeniedException(); $chequesInput = $entityManager->getRepository(Cheque::class)->findBy([ - 'bid'=>$acc['bid'], - 'type'=>'input' + 'bid' => $acc['bid'], + 'type' => 'input' ]); $chequesOutput = $entityManager->getRepository(Cheque::class)->findBy([ - 'bid'=>$acc['bid'], - 'type'=>'output' + 'bid' => $acc['bid'], + 'type' => 'output' ]); return $this->json([ - 'input'=>Explore::SerializeCheques(array_reverse($chequesInput)), - 'output'=>Explore::SerializeCheques(array_reverse($chequesOutput)) + 'input' => Explore::SerializeCheques(array_reverse($chequesInput)), + 'output' => Explore::SerializeCheques(array_reverse($chequesOutput)) ]); } #[Route('/api/cheque/list/forpay', name: 'app_cheque_list_for_pay')] - public function app_cheque_list_for_pay(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,Jdate $jdate): JsonResponse + public function app_cheque_list_for_pay(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, Jdate $jdate): JsonResponse { $acc = $access->hasRole('cheque'); - if(!$acc) + if (!$acc) throw $this->createAccessDeniedException(); $cheques = $entityManager->getRepository(Cheque::class)->findBy([ - 'bid'=>$acc['bid'], - 'type'=>'input', - 'locked'=>false, + 'bid' => $acc['bid'], + 'type' => 'input', + 'locked' => false, ]); - + return $this->json( Explore::SerializeCheques(array_reverse($cheques)), ); } #[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 + 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) + if (!$acc) throw $this->createAccessDeniedException(); $cheque = $entityManager->getRepository(Cheque::class)->findOneBy([ - 'bid'=>$acc['bid'], - 'id'=>$id + 'bid' => $acc['bid'], + 'id' => $id ]); - if(!$cheque) + 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 + 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) + if (!$acc) throw $this->createAccessDeniedException(); $cheque = $entityManager->getRepository(Cheque::class)->findOneBy([ - 'bid'=>$acc['bid'], - 'id'=>$id + 'bid' => $acc['bid'], + 'id' => $id ]); - if(!$cheque) + if (!$cheque) throw $this->createNotFoundException('cheque not found'); $cheque->setStatus('برگشت خورده'); $cheque->setRejected(true); - $log->insert('بانکداری','چک شماره شماره ' . $cheque->getNumber() . ' به برگشت خورده تغییر یافت. ',$this->getUser(),$request->headers->get('activeBid')); + $log->insert('بانکداری', 'چک شماره شماره ' . $cheque->getNumber() . ' به برگشت خورده تغییر یافت. ', $this->getUser(), $request->headers->get('activeBid')); $entityManager->persist($cheque); $entityManager->flush(); - return $this->json(['result'=>'ok']); + return $this->json(['result' => 'ok']); } #[Route('/api/cheque/pass/{id}', name: 'app_cheque_pass')] - public function app_cheque_pass(string $id,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,Jdate $jdate): JsonResponse + public function app_cheque_pass(string $id, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, Jdate $jdate): JsonResponse { $acc = $access->hasRole('cheque'); - if(!$acc) + if (!$acc) throw $this->createAccessDeniedException(); $params = []; if ($content = $request->getContent()) { $params = json_decode($content, true); } - if(! array_key_exists('bank',$params) || ! array_key_exists('date',$params)) + if (! array_key_exists('bank', $params) || ! array_key_exists('date', $params)) $this->createNotFoundException(); $cheque = $entityManager->getRepository(Cheque::class)->findOneBy([ - 'bid'=>$acc['bid'], - 'type'=>'input', + 'bid' => $acc['bid'], + 'type' => 'input', 'id' => $id ]); $bank = $entityManager->getRepository(BankAccount::class)->findOneBy([ - 'bid'=>$acc['bid'], + 'bid' => $acc['bid'], 'code' => $params['bank']['code'] ]); - if(!$cheque || !$bank) + if (!$cheque || !$bank) throw $this->createNotFoundException(); - if($cheque->isLocked()) + if ($cheque->isLocked()) throw $this->createAccessDeniedException('cheque operation not permitted'); //edit cheque info @@ -136,7 +142,7 @@ class ChequeController extends AbstractController $hesabdariDoc->setDateSubmit(time()); $hesabdariDoc->setDate($params['date']); $hesabdariDoc->setType('pass_cheque'); - $hesabdariDoc->setCode($provider->getAccountingCode($acc['bid'],'accounting')); + $hesabdariDoc->setCode($provider->getAccountingCode($acc['bid'], 'accounting')); $hesabdariDoc->setDes($params['des']); $hesabdariDoc->setAmount($cheque->getAmount()); $entityManager->persist($hesabdariDoc); @@ -148,7 +154,7 @@ class ChequeController extends AbstractController $hesabdariRow1->setPerson($cheque->getPerson()); $hesabdariRow1->setYear($acc['year']); $hesabdariRow1->setBs($cheque->getAmount()); - $hesabdariRow1->setRef($entityManager->getRepository(HesabdariTable::class)->findOneBy(['code'=>3])); + $hesabdariRow1->setRef($entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 3])); $hesabdariRow1->setBd(0); $hesabdariRow1->setBid($acc['bid']); $hesabdariRow1->setDes('پاس شدن چک و انتقال به بانک'); @@ -160,21 +166,297 @@ class ChequeController extends AbstractController $hesabdariRow2->setBank($bank); $hesabdariRow2->setYear($acc['year']); $hesabdariRow2->setBs(0); - $hesabdariRow2->setRef($entityManager->getRepository(HesabdariTable::class)->findOneBy(['code'=>5])); + $hesabdariRow2->setRef($entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 5])); $hesabdariRow2->setBd($cheque->getAmount()); $hesabdariRow2->setBid($acc['bid']); $hesabdariRow2->setDes('پاس شدن چک و انتقال به بانک'); $entityManager->persist($hesabdariRow2); $entityManager->flush(); $log->insert( - 'حسابداری','ثبت چک پاس شده شماره ' . $cheque->getNumber() . ' و ثبت واریز به بانک ' . $bank->getName(), + 'حسابداری', + 'ثبت چک پاس شده شماره ' . $cheque->getNumber() . ' و ثبت واریز به بانک ' . $bank->getName(), $this->getUser(), $acc['bid']->getId(), $hesabdariDoc ); return $this->json([ - 'result'=>'ok' + 'result' => 'ok' ]); } + + #[Route('/api/cheque/modify/input/{id}', name: 'app_cheque_modify_input')] + public function app_cheque_modify_input(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, Jdate $jdate, SMS $SMS, PluginService $pluginService, RegistryMGR $registryMGR, string $id = '0'): JsonResponse + { + $acc = $access->hasRole('cheque'); + if (!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + if ($id == '0') { + $cheque = new Cheque; + $cheque->setLocked(false); + $cheque->setDateSubmit(time()); + $cheque->setDateStamp(time()); + $cheque->setSubmitter($this->getUser()); + $cheque->setBid($acc['bid']); + $cheque->setStatus('پاس نشده'); + $cheque->setRef($entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 125])); + } else { + $cheque = $entityManager->getRepository(Cheque::class)->findOneBy(['id' => $id, 'bid' => $acc['bid']]); + if (!$cheque) + throw $this->createNotFoundException('cheque not found'); + if ($cheque->isRejected() || $cheque->getStatus() === 'پاس شده') + throw $this->createAccessDeniedException('امکان ویرایش این چک وجود ندارد'); + } + $cheque->setNumber($params['number']); + if (!is_numeric($params['amount'])) { + throw new \Exception('مبلغ باید عددی باشد'); + } + $cheque->setAmount(strpos($params['amount'], '.') === false ? (int)$params['amount'] : (float)$params['amount']); + $cheque->setType('input'); + $cheque->setBankoncheque($params['bankoncheque']); + $cheque->setPerson($entityManager->getRepository(Person::class)->findOneBy(['id' => $params['person']['code'], 'bid' => $acc['bid']])); + $cheque->setSayadNum($params['sayadNumber']); + $cheque->setDate($params['date']); + $cheque->setDes($params['description']); + $entityManager->persist($cheque); + + // ارسال پیامک در صورت درخواست + if (isset($params['sendSms']) && $params['sendSms'] == true) { + $person = $cheque->getPerson(); + if ($person && $person->getMobile()) { + if ($pluginService->isActive('accpro', $acc['bid']) && $person->getMobile() != '' && $acc['bid']->getTel()) { + $SMS->sendByBalance( + [$person->getNikename(), $cheque->getNumber(), number_format($cheque->getAmount()), $cheque->getBankoncheque(), $cheque->getDate(), $acc['bid']->getName(), $acc['bid']->getName()], + $registryMGR->get('sms', 'plugAccproChequeInput'), + $person->getMobile(), + $acc['bid'], + $this->getUser(), + 3 + ); + } else { + $SMS->sendByBalance( + [$person->getNikename(), $cheque->getNumber(), number_format($cheque->getAmount()), $cheque->getBankoncheque(), $cheque->getDate(), $acc['bid']->getName(), $acc['bid']->getName()], + $registryMGR->get('sms', 'chequeInput'), + $person->getMobile(), + $acc['bid'], + $this->getUser(), + 2 + ); + } + $log->insert( + 'بانکداری', + 'ارسال پیامک به ' . $person->getNikename() . ' برای چک شماره ' . $cheque->getNumber(), + $this->getUser(), + $acc['bid']->getId() + ); + } + } + + // اگر چک موجود است، سند حسابداری قبلی را پیدا و به‌روزرسانی می‌کنیم + if ($id != '0') { + $hesabdariRow = $entityManager->getRepository(HesabdariRow::class)->findOneBy([ + 'cheque' => $cheque, + 'bid' => $acc['bid'] + ]); + $hesabdariDoc = $hesabdariRow ? $hesabdariRow->getDoc() : null; + + if ($hesabdariDoc) { + // حذف سطرهای حسابداری قبلی + $oldRows = $hesabdariDoc->getHesabdariRows(); + foreach ($oldRows as $row) { + $entityManager->remove($row); + } + } else { + $hesabdariDoc = new HesabdariDoc; + } + } else { + $hesabdariDoc = new HesabdariDoc; + } + + $hesabdariDoc->setBid($acc['bid']); + $hesabdariDoc->setSubmitter($this->getUser()); + $hesabdariDoc->setYear($acc['year']); + $hesabdariDoc->setMoney($acc['money']); + $hesabdariDoc->setDateSubmit(time()); + $hesabdariDoc->setType('modify_cheque'); + $hesabdariDoc->setCode($provider->getAccountingCode($acc['bid'], 'accounting')); + $hesabdariDoc->setDate($params['date']); + $hesabdariDoc->setDes($params['description']); + $hesabdariDoc->setAmount($cheque->getAmount()); + $entityManager->persist($hesabdariDoc); + $entityManager->persist($hesabdariDoc); + + + + // ایجاد سطرهای حسابداری جدید + $hesabdariRow1 = new HesabdariRow; + $hesabdariRow1->setDoc($hesabdariDoc); + $hesabdariRow1->setCheque($cheque); + $hesabdariRow1->setPerson($cheque->getPerson()); + $hesabdariRow1->setYear($acc['year']); + $hesabdariRow1->setBs($cheque->getAmount()); + $hesabdariRow1->setRef($entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 125])); + $hesabdariRow1->setBd(0); + $hesabdariRow1->setBid($acc['bid']); + $hesabdariRow1->setCheque($cheque); + $hesabdariRow1->setDes('دریافت چک شماره ' . $cheque->getNumber() . ' از ' . $cheque->getPerson()->getNikename()); + $entityManager->persist($hesabdariRow1); + + $hesabdariRow2 = new HesabdariRow; + $hesabdariRow2->setDoc($hesabdariDoc); + $hesabdariRow2->setCheque($cheque); + $hesabdariRow2->setBank($cheque->getBank()); + $hesabdariRow2->setYear($acc['year']); + $hesabdariRow2->setBs(0); + $hesabdariRow2->setRef($entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => 126])); + $hesabdariRow2->setBd($cheque->getAmount()); + $hesabdariRow2->setBid($acc['bid']); + $hesabdariRow2->setCheque($cheque); + $hesabdariRow2->setDes('دریافت چک شماره ' . $cheque->getNumber() . ' از ' . $cheque->getPerson()->getNikename()); + $entityManager->persist($hesabdariRow2); + + $entityManager->flush(); + + $log->insert( + 'بانکداری', + 'دریافت چک شماره ' . $cheque->getNumber() . ' بانک ' . $cheque->getBankoncheque() . ' از ' . $cheque->getPerson()->getNikename(), + $this->getUser(), + $acc['bid']->getId(), + $hesabdariDoc + ); + return $this->json(['result' => 'ok']); + } + + #[Route('/api/cheque/input/get/{id}', name: 'app_cheque_input_get')] + public function app_cheque_input_get(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('چک مورد نظر یافت نشد'); + + $chequeData = [ + 'id' => $cheque->getId(), + 'number' => $cheque->getNumber(), + 'amount' => $cheque->getAmount(), + 'type' => $cheque->getType(), + 'status' => $cheque->getStatus(), + 'bankoncheque' => $cheque->getBankoncheque(), + 'sayadNumber' => $cheque->getSayadNum(), + 'dueDate' => $cheque->getPayDate(), + 'description' => $cheque->getDes(), + 'locked' => $cheque->isLocked(), + 'rejected' => $cheque->isRejected(), + 'dateSubmit' => $cheque->getDateSubmit(), + 'dateStamp' => $cheque->getDateStamp(), + 'person' => [ + 'id' => $cheque->getPerson()->getId(), + 'name' => $cheque->getPerson()->getNikename() + ], + 'bank' => $cheque->getBank() ? [ + 'id' => $cheque->getBank()->getId(), + 'name' => $cheque->getBank()->getName(), + 'code' => $cheque->getBank()->getCode() + ] : null + ]; + + return $this->json($chequeData); + } + + #[Route('/api/cheque/unreject/{id}', name: 'app_cheque_unreject')] + public function app_cheque_unreject(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('چک مورد نظر یافت نشد'); + + if (!$cheque->isRejected()) + throw $this->createAccessDeniedException('این چک برگشت نخورده است'); + + $cheque->setStatus('پاس نشده'); + $cheque->setRejected(false); + + $log->insert( + 'بانکداری', + 'رفع برگشت چک شماره ' . $cheque->getNumber() . ' از ' . $cheque->getPerson()->getNikename(), + $this->getUser(), + $acc['bid']->getId() + ); + + $entityManager->persist($cheque); + $entityManager->flush(); + + return $this->json(['result' => 'ok']); + } + + #[Route('/api/cheque/input/delete/{id}', name: 'app_cheque_input_delete')] + public function app_cheque_input_delete(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' => $request->headers->get('activeBid'), 'id' => $id]); + if (!$cheque) { + throw new NotFoundHttpException('چک مورد نظر یافت نشد'); + } + + if ($cheque->isLocked() || $cheque->isRejected()) { + throw new AccessDeniedException('امکان حذف این چک وجود ندارد'); + } + + $hesabdariRow = $entityManager->getRepository(HesabdariRow::class)->findOneBy([ + 'cheque' => $cheque, + 'bid' => $acc['bid'] + ]); + $hesabdariDoc = $hesabdariRow ? $hesabdariRow->getDoc() : null; + if ($hesabdariDoc) { + // حذف سطرهای حسابداری + $oldRows = $entityManager->getRepository(HesabdariRow::class)->findBy(['doc' => $hesabdariDoc]); + foreach ($oldRows as $row) { + $entityManager->remove($row); + } + + // به‌روزرسانی لاگ‌های مرتبط با سند + $logs = $entityManager->getRepository(\App\Entity\Log::class)->findBy(['doc' => $hesabdariDoc]); + foreach ($logs as $logEntry) { + $logEntry->setDoc(null); + $entityManager->persist($logEntry); + } + + // حذف سند حسابداری + $code = $hesabdariDoc->getCode(); + $entityManager->remove($hesabdariDoc); + } + $entityManager->remove($cheque); + $entityManager->flush(); + + $log->insert( + 'بانکداری', + 'حذف چک شماره ' . $cheque->getNumber() . ' از ' . $cheque->getPerson()->getNikename() . ' و سند حسابداری ' . $code, + $this->getUser(), + $request->headers->get('activeBid') + ); + + return $this->json(['result' => 'ok']); + } } diff --git a/webUI/src/components/forms/Hpersonsearch.vue b/webUI/src/components/forms/Hpersonsearch.vue index a8c00b7..ab1251b 100644 --- a/webUI/src/components/forms/Hpersonsearch.vue +++ b/webUI/src/components/forms/Hpersonsearch.vue @@ -482,9 +482,7 @@ export default { transactionFilters: null, sortBy: null }); - - console.log('پاسخ API:', response.data); - + if (response.data && Array.isArray(response.data)) { this.items = response.data; this.totalItems = response.data.length; diff --git a/webUI/src/i18n/fa_lang.ts b/webUI/src/i18n/fa_lang.ts index 7f2621b..3c56b5f 100644 --- a/webUI/src/i18n/fa_lang.ts +++ b/webUI/src/i18n/fa_lang.ts @@ -666,8 +666,16 @@ const fa_lang = { sms_settings_repservice_get: "دریافت کالا", sms_settings_repservice_repired: "اعلام تعمیر", sms_settings_repservice_unrepaired: "اعلام غیر قابل تعمیر", - sms_settings_repservice_getback: "تخویل کالا", + sms_settings_repservice_getback: "تحویل کالا", sms_settings_repservice_creating: "در حال ساخت", + sms_settings_repservice_repaired: "تعمیر شده", + sms_settings_repservice_repaired_accpro: "تعمیر شده", + sms_settings_cheque_input: "دریافت چک", + sms_settings_pass_cheque_input: "واگذاری چک", + sms_settings_plug_accpro_cheque_input: "دریافت چک", + sms_settings_plug_accpro_pass_cheque_input: "واگذاری چک", + sms_settings_reject_cheque_input: "برگشت چک", + sms_settings_plug_accpro_reject_cheque_input: "برگشت چک", app_site: "آدرس اینترفیس(رابط کاربری)", keywords: "کلیدواژه‌ها با کاما (,) از هم جدا شوند", zarinpal_api: "کد API زرین‌پال", diff --git a/webUI/src/router/index.ts b/webUI/src/router/index.ts index 5552e7e..62384ca 100644 --- a/webUI/src/router/index.ts +++ b/webUI/src/router/index.ts @@ -575,6 +575,12 @@ const router = createRouter({ component: () => import('../views/acc/cheque/list.vue'), }, + { + path: 'cheque/transfer/:id', + name: 'cheque_transfer', + component: () => + import('../views/acc/cheque/transfer.vue'), + }, { path: 'buy/mod/:id?', name: 'buy_mod', diff --git a/webUI/src/views/acc/cheque/input.vue b/webUI/src/views/acc/cheque/input.vue index 994cb63..3b113ae 100644 --- a/webUI/src/views/acc/cheque/input.vue +++ b/webUI/src/views/acc/cheque/input.vue @@ -9,6 +9,18 @@