From 0af7edac97968c56c40525f57eaf42ff8b14fddc Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Wed, 12 Mar 2025 22:09:00 +0000 Subject: [PATCH] progress in package manager and bug fix in captcha generator --- hesabixCore/src/Controller/HesabdariController.php | 11 ++++++++++- .../src/Service/AccountingPermissionService.php | 3 +-- hesabixCore/src/Service/CaptchaService.php | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hesabixCore/src/Controller/HesabdariController.php b/hesabixCore/src/Controller/HesabdariController.php index adc7763..91338cf 100644 --- a/hesabixCore/src/Controller/HesabdariController.php +++ b/hesabixCore/src/Controller/HesabdariController.php @@ -18,6 +18,7 @@ use App\Entity\PlugNoghreOrder; use App\Entity\Salary; use App\Entity\StoreroomTicket; use App\Service\Access; +use App\Service\AccountingPermissionService; use App\Service\Explore; use App\Service\Jdate; use App\Service\JsonResp; @@ -271,7 +272,7 @@ class HesabdariController extends AbstractController * @throws \ReflectionException */ #[Route('/api/accounting/insert', name: 'app_accounting_insert')] - public function app_accounting_insert(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, Jdate $jdate): JsonResponse + public function app_accounting_insert(AccountingPermissionService $accountingPermissionService, Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager, Jdate $jdate): JsonResponse { $params = []; if ($content = $request->getContent()) { @@ -279,6 +280,7 @@ class HesabdariController extends AbstractController } if (!array_key_exists('type', $params)) $this->createNotFoundException(); + $roll = ''; if ($params['type'] == 'person_receive' || $params['type'] == 'person_send') $roll = 'person'; @@ -295,6 +297,13 @@ class HesabdariController extends AbstractController if (!$acc) throw $this->createAccessDeniedException(); + $pkgcntr = $accountingPermissionService->canRegisterAccountingDoc($acc['bid']); + if ($pkgcntr['code'] == 4) { + return $this->json([ + 'result' => 4, + 'msg' => $pkgcntr['message'] + ]); + } if (!array_key_exists('rows', $params) || count($params['rows']) < 2) throw $this->createNotFoundException('rows is to short'); if (!array_key_exists('date', $params) || !array_key_exists('des', $params)) diff --git a/hesabixCore/src/Service/AccountingPermissionService.php b/hesabixCore/src/Service/AccountingPermissionService.php index 0831941..f8f564d 100644 --- a/hesabixCore/src/Service/AccountingPermissionService.php +++ b/hesabixCore/src/Service/AccountingPermissionService.php @@ -20,7 +20,7 @@ class AccountingPermissionService private function getAccountingDocPrice(): int { $rootSystem = 'system_settings'; - return (int) $this->registryMGR->get($rootSystem, 'accountingDocPrice'); + return (int) $this->registryMGR->get($rootSystem, 'accounting_doc_price'); } /** @@ -62,7 +62,6 @@ class AccountingPermissionService // ۳. چک کردن اعتبار موجود (smsCharge) و کسر هزینه $accountingDocPrice = $this->getAccountingDocPrice(); $smsCharge = (int) $business->getSmsCharge(); - if ($smsCharge >= $accountingDocPrice) { // کسر هزینه از اعتبار $business->setSmsCharge((string) ($smsCharge - $accountingDocPrice)); diff --git a/hesabixCore/src/Service/CaptchaService.php b/hesabixCore/src/Service/CaptchaService.php index 6a20a8e..0026d2a 100644 --- a/hesabixCore/src/Service/CaptchaService.php +++ b/hesabixCore/src/Service/CaptchaService.php @@ -76,6 +76,7 @@ class CaptchaService $response->headers->set('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0'); $response->headers->set('Pragma', 'no-cache'); $response->headers->set('Expires', '0'); + return $response; } public function isCaptchaRequired(string $attemptKey): bool