diff --git a/hesabixCore/src/Controller/HesabdariController.php b/hesabixCore/src/Controller/HesabdariController.php index 68d9be1..020c634 100644 --- a/hesabixCore/src/Controller/HesabdariController.php +++ b/hesabixCore/src/Controller/HesabdariController.php @@ -882,12 +882,14 @@ class HesabdariController extends AbstractController $temp[$node->getCode()] = [ 'text' => $node->getName(), 'id' => $node->getCode() ?? $node->getId(), + 'type' => $node->getType(), 'children' => $this->getFilteredChildsLabel($entityManager, $node, $business), ]; } else { $temp[$node->getCode()] = [ 'text' => $node->getName(), 'id' => $node->getCode() ?? $node->getId(), + 'type' => $node->getType(), ]; } $temp[$node->getCode()]['is_public'] = $nodeBid === null; @@ -1033,6 +1035,13 @@ class HesabdariController extends AbstractController return $this->json(['result' => 0, 'message' => 'نام ردیف حساب و آیدی والد الزامی است'], 400); } + // بررسی نوع تفضیل حساب + $allowedTypes = ['calc', 'person', 'commodity', 'bank', 'salary', 'cashdesk']; + $accountType = $params['accountType'] ?? 'calc'; + if (!in_array($accountType, $allowedTypes)) { + return $this->json(['result' => 0, 'message' => 'نوع تفضیل حساب نامعتبر است'], 400); + } + $parentNode = $entityManager->getRepository(HesabdariTable::class)->findOneBy(['code' => $params['parentId']]); if (!$parentNode) { return $this->json(['result' => 0, 'message' => 'ردیف حساب والد پیدا نشد'], 404); @@ -1058,18 +1067,19 @@ class HesabdariController extends AbstractController $newNode->setCode($uniqueCode); $newNode->setBid($acc['bid']); $newNode->setUpper($parentNode); - $newNode->setType('calc'); + $newNode->setType($accountType); $entityManager->persist($newNode); $entityManager->flush(); - $log->insert('حسابداری', 'ردیف حساب جدید با کد ' . $newNode->getCode() . ' اضافه شد.', $this->getUser(), $acc['bid']); + $log->insert('حسابداری', 'ردیف حساب جدید با کد ' . $newNode->getCode() . ' و نوع ' . $accountType . ' اضافه شد.', $this->getUser(), $acc['bid']); return $this->json([ 'result' => 1, 'node' => [ 'id' => $newNode->getCode(), 'text' => $newNode->getName(), + 'type' => $newNode->getType(), 'children' => [], 'is_public' => $newNode->getBid() ? false : true, ] @@ -1110,6 +1120,7 @@ class HesabdariController extends AbstractController 'node' => [ 'id' => $node->getCode(), 'text' => $node->getName(), + 'type' => $node->getType(), 'children' => $this->getChildsLabel($entityManager, $node), 'is_public' => $node->getBid() ? false : true, ] diff --git a/webUI/src/views/acc/accounting/table.vue b/webUI/src/views/acc/accounting/table.vue index 48225fc..8098725 100755 --- a/webUI/src/views/acc/accounting/table.vue +++ b/webUI/src/views/acc/accounting/table.vue @@ -17,6 +17,9 @@ {{ node.text }} ({{ node.id }}) + + {{ getAccountTypeLabel(node.type) }} +