From 227767b0d674f444d8c24f0c85a7ab3a94b072da Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Wed, 16 Jul 2025 15:11:53 +0000 Subject: [PATCH] progress in inquery panel --- .../src/Controller/AdminController.php | 8 + .../src/Controller/BusinessController.php | 3 + .../Plugins/TaxSettingsController.php | 201 ++++++ .../inquiry/PlugInquiryMainController.php | 2 - hesabixCore/src/Entity/Permission.php | 15 + .../src/Entity/PluginTaxsettingsKey.php | 53 ++ webUI/src/i18n/en_lang.ts | 1 + webUI/src/i18n/fa_lang.ts | 10 +- webUI/src/router/index.ts | 18 + webUI/src/views/acc/App.vue | 31 +- webUI/src/views/acc/inquiry/panel.vue | 24 + webUI/src/views/acc/router/index.js | 6 + webUI/src/views/acc/settings/tax-settings.vue | 321 +++++++++ .../src/views/acc/settings/user_perm_edit.vue | 29 +- webUI/src/views/acc/tax/invoices/list.vue | 173 +++++ webUI/src/views/acc/tax/tax-settings.vue | 321 +++++++++ .../views/user/manager/settings/system.vue | 613 +++++++++++++++--- 17 files changed, 1742 insertions(+), 87 deletions(-) create mode 100644 hesabixCore/src/Controller/Plugins/TaxSettingsController.php create mode 100644 hesabixCore/src/Entity/PluginTaxsettingsKey.php create mode 100644 webUI/src/views/acc/inquiry/panel.vue create mode 100644 webUI/src/views/acc/settings/tax-settings.vue create mode 100644 webUI/src/views/acc/tax/invoices/list.vue create mode 100644 webUI/src/views/acc/tax/tax-settings.vue diff --git a/hesabixCore/src/Controller/AdminController.php b/hesabixCore/src/Controller/AdminController.php index 230dab44..26414b7a 100644 --- a/hesabixCore/src/Controller/AdminController.php +++ b/hesabixCore/src/Controller/AdminController.php @@ -455,6 +455,10 @@ class AdminController extends AbstractController $resp['enablePostalCodeToAddress'] = $registryMGR->get('system', key: 'enablePostalCodeToAddress'); $resp['inquiryPanelEnable'] = $registryMGR->get('system', key: 'inquiryPanelEnable'); $resp['postalCodeToAddressFee'] = $registryMGR->get('system', key: 'postalCodeToAddressFee'); + $resp['enableCardToSheba'] = $registryMGR->get('system', key: 'enableCardToSheba'); + $resp['cardToShebaFee'] = $registryMGR->get('system', key: 'cardToShebaFee'); + $resp['enableAccountToSheba'] = $registryMGR->get('system', key: 'enableAccountToSheba'); + $resp['accountToShebaFee'] = $registryMGR->get('system', key: 'accountToShebaFee'); return $this->json($resp); } @@ -484,6 +488,10 @@ class AdminController extends AbstractController $registryMGR->update('system', 'enablePostalCodeToAddress', $params['enablePostalCodeToAddress']); $registryMGR->update('system', 'inquiryPanelEnable', $params['inquiryPanelEnable']); $registryMGR->update('system', 'postalCodeToAddressFee', $params['postalCodeToAddressFee']); + $registryMGR->update('system', 'enableCardToSheba', $params['enableCardToSheba']); + $registryMGR->update('system', 'cardToShebaFee', $params['cardToShebaFee']); + $registryMGR->update('system', 'enableAccountToSheba', $params['enableAccountToSheba']); + $registryMGR->update('system', 'accountToShebaFee', $params['accountToShebaFee']); $entityManager->persist($item); $entityManager->flush(); return $this->json(['result' => 1]); diff --git a/hesabixCore/src/Controller/BusinessController.php b/hesabixCore/src/Controller/BusinessController.php index b04d04d2..400aebbc 100644 --- a/hesabixCore/src/Controller/BusinessController.php +++ b/hesabixCore/src/Controller/BusinessController.php @@ -544,6 +544,7 @@ class BusinessController extends AbstractController 'plugRepservice' => true, 'plugHrmDocs' => true, 'plugGhestaManager' => true, + 'plugTaxSettings' => true, ]; } elseif ($perm) { $result = [ @@ -587,6 +588,7 @@ class BusinessController extends AbstractController 'plugAccproPresell' => $perm->isPlugAccproPresell(), 'plugHrmDocs' => $perm->isPlugHrmDocs(), 'plugGhestaManager' => $perm->isPlugGhestaManager(), + 'plugTaxSettings' => $perm->isPlugTaxSettings(), ]; } return $this->json($result); @@ -656,6 +658,7 @@ class BusinessController extends AbstractController $perm->setPlugRepservice($params['plugRepservice']); $perm->setPlugHrmDocs($params['plugHrmDocs']); $perm->setPlugGhestaManager($params['plugGhestaManager']); + $perm->setPlugTaxSettings($params['plugTaxSettings']); $entityManager->persist($perm); $entityManager->flush(); $log->insert('تنظیمات پایه', 'ویرایش دسترسی‌های کاربر با پست الکترونیکی ' . $user->getEmail(), $this->getUser(), $business); diff --git a/hesabixCore/src/Controller/Plugins/TaxSettingsController.php b/hesabixCore/src/Controller/Plugins/TaxSettingsController.php new file mode 100644 index 00000000..9e0d2e44 --- /dev/null +++ b/hesabixCore/src/Controller/Plugins/TaxSettingsController.php @@ -0,0 +1,201 @@ +hasRole('plugTaxSettings'); + if (!$acc) { + throw $this->createAccessDeniedException('شما دسترسی لازم را ندارید.'); + } + + $businessId = is_object($acc['bid']) ? $acc['bid']->getId() : $acc['bid']; + $userId = $this->getUser()->getId(); + + // دریافت تنظیمات از جدول اختصاصی + $repo = $em->getRepository(PluginTaxsettingsKey::class); + $entity = $repo->findOneBy(['business_id' => $businessId, 'user_id' => $userId]); + + $settings = [ + 'taxMemoryId' => $entity ? $entity->getTaxMemoryId() : '', + 'economicCode' => $entity ? $entity->getEconomicCode() : '', + 'privateKey' => $entity ? $entity->getPrivateKey() : '', + ]; + + return $this->json($settings); + } + + #[Route('/api/plugins/tax/settings/save', name: 'plugin_tax_settings_save', methods: ['POST'])] + public function plugin_tax_settings_save(Request $request, registryMGR $registryMGR, Access $access, Log $log, EntityManagerInterface $em): JsonResponse + { + $acc = $access->hasRole('plugTaxSettings'); + if (!$acc) { + throw $this->createAccessDeniedException('شما دسترسی لازم را ندارید.'); + } + + $params = $request->getPayload()->all(); + $businessId = is_object($acc['bid']) ? $acc['bid']->getId() : $acc['bid']; + $userId = $this->getUser()->getId(); + + // بررسی وجود رکورد قبلی + $repo = $em->getRepository(PluginTaxsettingsKey::class); + $entity = $repo->findOneBy(['business_id' => $businessId, 'user_id' => $userId]); + if (!$entity) { + $entity = new PluginTaxsettingsKey(); + $entity->setBusinessId($businessId); + $entity->setUserId($userId); + $entity->setCreatedAt(new \DateTime()); + } + $entity->setPrivateKey($params['privateKey'] ?? ''); + $entity->setTaxMemoryId($params['taxMemoryId'] ?? null); + $entity->setEconomicCode($params['economicCode'] ?? null); + $entity->setUpdatedAt(new \DateTime()); + + $em->persist($entity); + $em->flush(); + + $log->insert('تنظیمات مالیاتی', 'تنظیمات مالیاتی ذخیره شد (در جدول اختصاصی)', $this->getUser(), $businessId); + + return $this->json(['success' => true, 'message' => 'تنظیمات با موفقیت ذخیره شد']); + } + + private function generatePrivateKey(): string + { + // تولید کلید خصوصی واقعی با OpenSSL + $config = [ + "private_key_bits" => 2048, + "private_key_type" => OPENSSL_KEYTYPE_RSA, + ]; + + $res = openssl_pkey_new($config); + if (!$res) { + throw new \Exception('خطا در تولید کلید خصوصی: ' . openssl_error_string()); + } + + $privateKey = ''; + if (!openssl_pkey_export($res, $privateKey)) { + throw new \Exception('خطا در استخراج کلید خصوصی: ' . openssl_error_string()); + } + + openssl_pkey_free($res); + return $privateKey; + } + + private function generatePublicKey(string $privateKey): string + { + // استخراج کلید عمومی از کلید خصوصی + $res = openssl_pkey_get_private($privateKey); + if (!$res) { + throw new \Exception('خطا در خواندن کلید خصوصی: ' . openssl_error_string()); + } + + $keyDetails = openssl_pkey_get_details($res); + if (!$keyDetails) { + throw new \Exception('خطا در استخراج جزئیات کلید: ' . openssl_error_string()); + } + + openssl_pkey_free($res); + return $keyDetails['key']; + } + + #[Route('/api/plugins/tax/settings/generate-csr', name: 'plugin_tax_settings_generate_csr', methods: ['POST'])] + public function plugin_tax_settings_generate_csr(Request $request, registryMGR $registryMGR, Access $access, Log $log): JsonResponse + { + $acc = $access->hasRole('plugTaxSettings'); + if (!$acc) { + throw $this->createAccessDeniedException('شما دسترسی لازم را ندارید.'); + } + + $params = $request->getPayload()->all(); + + // بررسی فیلدهای اجباری + if (empty($params['nationalId']) || empty($params['nameFa']) || empty($params['nameEn']) || empty($params['email'])) { + return $this->json([ + 'success' => false, + 'message' => 'تمام فیلدها الزامی هستند' + ]); + } + + try { + $privateKey = $this->generatePrivateKey(); + $publicKey = $this->generatePublicKey($privateKey); + $csr = $this->generateCSR($privateKey, $params); + + // هیچ ذخیره‌ای در دیتابیس انجام نمی‌شود + $businessId = is_object($acc['bid']) ? $acc['bid']->getId() : $acc['bid']; + $log->insert('تنظیمات مالیاتی', 'کلید و CSR تولید شد (بدون ذخیره)', $this->getUser(), $businessId); + + return $this->json([ + 'success' => true, + 'message' => 'کلید و CSR با موفقیت تولید شد', + 'privateKey' => $privateKey, + 'publicKey' => $publicKey, + 'csr' => $csr + ]); + } catch (\Exception $e) { + return $this->json([ + 'success' => false, + 'message' => 'خطا در تولید کلید و CSR: ' . $e->getMessage() + ]); + } + } + + private function generateCSR(string $privateKey, array $params): string + { + // تولید CSR واقعی با OpenSSL + $dn = [ + "countryName" => "IR", + "stateOrProvinceName" => "Tehran", + "localityName" => "Tehran", + "organizationName" => $params['nameEn'], + "organizationalUnitName" => "Tax Department", + "commonName" => $params['nameFa'], + "emailAddress" => $params['email'] + ]; + + // اضافه کردن شناسه ملی به عنوان extension + $config = [ + "req" => [ + "distinguished_name" => $dn, + "req_extensions" => "v3_req", + "x509_extensions" => "v3_req" + ], + "v3_req" => [ + "subjectAltName" => "email:" . $params['email'], + "subjectKeyIdentifier" => "hash" + ] + ]; + + // ایجاد CSR + $res = openssl_csr_new($dn, $privateKey, [ + 'config' => $config, + 'digest_alg' => 'sha256', + 'req_extensions' => 'v3_req' + ]); + + if (!$res) { + throw new \Exception('خطا در تولید CSR: ' . openssl_error_string()); + } + + $csr = ''; + if (!openssl_csr_export($res, $csr)) { + throw new \Exception('خطا در استخراج CSR: ' . openssl_error_string()); + } + + return $csr; + } +} \ No newline at end of file diff --git a/hesabixCore/src/Controller/Plugins/inquiry/PlugInquiryMainController.php b/hesabixCore/src/Controller/Plugins/inquiry/PlugInquiryMainController.php index 5d915a65..575f9c02 100644 --- a/hesabixCore/src/Controller/Plugins/inquiry/PlugInquiryMainController.php +++ b/hesabixCore/src/Controller/Plugins/inquiry/PlugInquiryMainController.php @@ -128,6 +128,4 @@ class PlugInquiryMainController extends AbstractController ]); } } - - } \ No newline at end of file diff --git a/hesabixCore/src/Entity/Permission.php b/hesabixCore/src/Entity/Permission.php index e5631356..47aedd1b 100644 --- a/hesabixCore/src/Entity/Permission.php +++ b/hesabixCore/src/Entity/Permission.php @@ -129,6 +129,9 @@ class Permission #[ORM\Column(nullable: true)] private ?bool $plugGhestaManager = null; + #[ORM\Column(nullable: true)] + private ?bool $plugTaxSettings = null; + public function getId(): ?int { return $this->id; @@ -590,4 +593,16 @@ class Permission return $this; } + public function isPlugTaxSettings(): ?bool + { + return $this->plugTaxSettings; + } + + public function setPlugTaxSettings(?bool $plugTaxSettings): static + { + $this->plugTaxSettings = $plugTaxSettings; + + return $this; + } + } diff --git a/hesabixCore/src/Entity/PluginTaxsettingsKey.php b/hesabixCore/src/Entity/PluginTaxsettingsKey.php new file mode 100644 index 00000000..5a2e67c2 --- /dev/null +++ b/hesabixCore/src/Entity/PluginTaxsettingsKey.php @@ -0,0 +1,53 @@ +id; } + public function getBusinessId() { return $this->business_id; } + public function setBusinessId($val) { $this->business_id = $val; } + public function getUserId() { return $this->user_id; } + public function setUserId($val) { $this->user_id = $val; } + public function getPrivateKey() { return $this->private_key; } + public function setPrivateKey($val) { $this->private_key = $val; } + public function getTaxMemoryId() { return $this->tax_memory_id; } + public function setTaxMemoryId($val) { $this->tax_memory_id = $val; } + public function getEconomicCode() { return $this->economic_code; } + public function setEconomicCode($val) { $this->economic_code = $val; } + public function getCreatedAt() { return $this->created_at; } + public function setCreatedAt($val) { $this->created_at = $val; } + public function getUpdatedAt() { return $this->updated_at; } + public function setUpdatedAt($val) { $this->updated_at = $val; } +} \ No newline at end of file diff --git a/webUI/src/i18n/en_lang.ts b/webUI/src/i18n/en_lang.ts index e0613b5a..e087b459 100644 --- a/webUI/src/i18n/en_lang.ts +++ b/webUI/src/i18n/en_lang.ts @@ -86,6 +86,7 @@ const en_lang = { cheque_output: "Cheque Output", presells: "Presells", presell_view: "View Presell", + inquiry: "Inquiries", hrm: 'HR & Payroll', hrm_docs: 'Payroll Document', }, diff --git a/webUI/src/i18n/fa_lang.ts b/webUI/src/i18n/fa_lang.ts index 07db4548..69816622 100644 --- a/webUI/src/i18n/fa_lang.ts +++ b/webUI/src/i18n/fa_lang.ts @@ -173,6 +173,7 @@ const fa_lang = { reports: "گزارشات", settings: "تنظیمات", bid_settings: "تنظیمات کسب‌و‌کار", + tax_settings: "تنظیمات مالیاتی", print_settings: "چاپ اسناد", user_perms: "کاربران و دسترسی‌ها", avatar_settings: "نمایه و مهر کسب‌و‌کار", @@ -193,13 +194,16 @@ const fa_lang = { plugins_invoices: "صورت حساب‌ها", repservice: "مدیریت تعمیرگاه", repservice_reqs: "درخواست‌ها", + inquiry: "استعلامات", hrm: 'منابع انسانی', hrm_docs: 'سند حقوق', buysellByPerson: "گزارش خرید و فروش های اشخاص", + tax_system: "سامانه مودیان مالیاتی", + tax_invoices: "صورتحساب‌ ها", }, time: { month: "{id} ماه", - }, + }, calendar: { shamsi: "هجری شمسی", gregorian: "میلادی", @@ -818,6 +822,10 @@ const fa_lang = { inquiry_zohal_api_key_label: "کلید API زحل", enable_postalcode_to_address: "تبدیل کد پستی به آدرس", postalcode_to_address_fee: "کارمزد تبدیل کد پستی به آدرس", + enable_card_to_sheba: "تبدیل شماره کارت به شبا", + card_to_sheba_fee: "کارمزد تبدیل شماره کارت به شبا", + enable_account_to_sheba: "تبدیل حساب به شبا", + account_to_sheba_fee: "کارمزد تبدیل حساب به شبا", inquiry_panel_enable: "فعال سازی پنل سامانه استعلامات", inquiry_panel: "پنل سامانه استعلامات", inquiry_panel_zohal: "زحل", diff --git a/webUI/src/router/index.ts b/webUI/src/router/index.ts index 9c3d0b36..49519b08 100644 --- a/webUI/src/router/index.ts +++ b/webUI/src/router/index.ts @@ -510,6 +510,18 @@ const router = createRouter({ component: () => import('../views/acc/settings/extramoneys.vue'), }, + { + path: 'plugins/tax/settings', + name: 'business_tax_settings', + component: () => + import('../views/acc/tax/tax-settings.vue'), + }, + { + path: 'plugins/tax/invoices/list', + name: 'tax_invoices_list', + component: () => + import('../views/acc/tax/invoices/list.vue'), + }, { path: 'business/logs', name: 'business_logs', @@ -988,6 +1000,12 @@ const router = createRouter({ component: () => import('../views/acc/plugins/hrm/docs/view.vue'), }, + { + path: 'inquiry/panel', + name: 'inquiry_panel', + component: () => + import('../views/acc/inquiry/panel.vue'), + }, ], }, { diff --git a/webUI/src/views/acc/App.vue b/webUI/src/views/acc/App.vue index 452c610a..e98424f8 100644 --- a/webUI/src/views/acc/App.vue +++ b/webUI/src/views/acc/App.vue @@ -169,8 +169,9 @@ export default { { path: '/acc/business/extramoneys', key: '-', label: this.$t('drawer.extra_moneys'), ctrl: true, shift: true, permission: () => this.permissions.settings && this.isPluginActive('accpro') }, { path: '/acc/business/logs', key: '=', label: this.$t('drawer.history'), ctrl: true, shift: true, permission: () => this.permissions.log }, { path: '/acc/plugin/repservice/order/list', key: '[', label: this.$t('drawer.repservice_reqs'), ctrl: true, shift: true, permission: () => this.permissions.plugRepservice && this.isPluginActive('repservice') }, - { path: '/acc/sms/panel', key: ']', label: this.$t('drawer.sms_panel'), ctrl: true, shift: true, permission: () => this.permissions.owner }, + { path: '/acc/inquiry/panel', key: ']', label: this.$t('drawer.inquiry'), ctrl: true, shift: true, permission: () => true }, { path: '/acc/printers/list', key: ';', label: this.$t('drawer.cloud_printers'), ctrl: true, shift: true, permission: () => this.permissions.owner }, + { path: '/acc/sms/panel', key: '`', label: this.$t('drawer.sms_panel'), ctrl: true, shift: true, permission: () => this.permissions.owner }, { path: '/acc/archive/list', key: '\'', label: this.$t('drawer.archive_files'), ctrl: true, shift: true, permission: () => this.permissions.archiveUpload || this.permissions.archiveMod || this.permissions.archiveDelete }, { path: '/acc/archive/order/new', key: ',', label: this.$t('drawer.archive_order'), ctrl: true, shift: true, permission: () => this.permissions.owner }, { path: '/acc/archive/order/list', key: '.', label: this.$t('drawer.archive_log'), ctrl: true, shift: true, permission: () => this.permissions.owner }, @@ -179,6 +180,8 @@ export default { { path: '/acc/plugin-center/invoice', key: '`', label: this.$t('drawer.plugins_invoices'), ctrl: true, shift: true, permission: () => this.permissions.owner }, { path: '/acc/hrm/docs/list', key: 'H', label: this.$t('drawer.hrm_docs'), ctrl: true, shift: true, permission: () => this.isPluginActive('hrm') && this.permissions.plugHrmDocs }, { path: '/acc/plugins/ghesta/list', key: 'G', label: this.$t('drawer.ghesta_invoices'), ctrl: true, shift: true, permission: () => this.isPluginActive('ghesta') && this.permissions.plugGhestaManager }, + { path: '/acc/plugins/tax/invoices/list', key: 'L', label: this.$t('drawer.tax_invoices'), ctrl: true, shift: true, permission: () => this.permissions.settings && this.isPluginActive('taxsettings') }, + { path: '/acc/plugins/tax/settings', key: 'T', label: this.$t('drawer.tax_settings'), ctrl: true, shift: true, permission: () => this.permissions.settings && this.isPluginActive('taxsettings') }, ]; }, restorePermissions(shortcuts) { @@ -741,7 +744,7 @@ export default { {{ $t('drawer.user_perms') }} {{ getShortcutKey('/acc/business/users') }} - + @@ -788,6 +791,13 @@ export default { + + + + {{ $t('drawer.inquiry') }} + {{ getShortcutKey('/acc/inquiry/panel') }} + + + + + + + {{ $t('drawer.tax_invoices') }} + + + + + {{ $t('drawer.tax_settings') }} + + + diff --git a/webUI/src/views/acc/inquiry/panel.vue b/webUI/src/views/acc/inquiry/panel.vue new file mode 100644 index 00000000..30cc2cc3 --- /dev/null +++ b/webUI/src/views/acc/inquiry/panel.vue @@ -0,0 +1,24 @@ + + + + + + diff --git a/webUI/src/views/acc/router/index.js b/webUI/src/views/acc/router/index.js index dea1a69c..43cd189b 100644 --- a/webUI/src/views/acc/router/index.js +++ b/webUI/src/views/acc/router/index.js @@ -241,6 +241,12 @@ const router = createRouter({ component: () => import ('../views/settings/extramoneys.vue'), }, + { + path: '/acc/business/tax-settings', + name: 'business_tax_settings', + component: () => + import ('../views/settings/tax-settings.vue'), + }, { path: '/acc/business/logs', name: 'business_logs', diff --git a/webUI/src/views/acc/settings/tax-settings.vue b/webUI/src/views/acc/settings/tax-settings.vue new file mode 100644 index 00000000..5be06e21 --- /dev/null +++ b/webUI/src/views/acc/settings/tax-settings.vue @@ -0,0 +1,321 @@ + + + \ No newline at end of file diff --git a/webUI/src/views/acc/settings/user_perm_edit.vue b/webUI/src/views/acc/settings/user_perm_edit.vue index fda5de75..f54e41cc 100644 --- a/webUI/src/views/acc/settings/user_perm_edit.vue +++ b/webUI/src/views/acc/settings/user_perm_edit.vue @@ -601,6 +601,32 @@ + + + + افزونه تنظیمات مالیاتی + + + + + + + + + + + + + @@ -679,7 +705,8 @@ export default { plugNoghreSell: false, plugCCAdmin: false, plugHrmDocs: false, - plugGhestaManager: false + plugGhestaManager: false, + plugTaxSettings: false }; axios.post('/api/business/get/user/permissions', diff --git a/webUI/src/views/acc/tax/invoices/list.vue b/webUI/src/views/acc/tax/invoices/list.vue new file mode 100644 index 00000000..dc2d0da5 --- /dev/null +++ b/webUI/src/views/acc/tax/invoices/list.vue @@ -0,0 +1,173 @@ + + + \ No newline at end of file diff --git a/webUI/src/views/acc/tax/tax-settings.vue b/webUI/src/views/acc/tax/tax-settings.vue new file mode 100644 index 00000000..eda7804b --- /dev/null +++ b/webUI/src/views/acc/tax/tax-settings.vue @@ -0,0 +1,321 @@ + + + \ No newline at end of file diff --git a/webUI/src/views/user/manager/settings/system.vue b/webUI/src/views/user/manager/settings/system.vue index 9b9bd296..b8e2ac6f 100644 --- a/webUI/src/views/user/manager/settings/system.vue +++ b/webUI/src/views/user/manager/settings/system.vue @@ -7,6 +7,12 @@ export default defineComponent({ name: "system", data: () => { return { + activeTab: 0, + tabs: [ + { title: 'تنظیمات پایه', icon: 'mdi-cog' }, + { title: 'درگاه‌های پرداخت', icon: 'mdi-credit-card' }, + { title: 'پنل استعلامات', icon: 'mdi-magnify' } + ], gatepays: [ { title: 'زرین‌پال', @@ -50,6 +56,10 @@ export default defineComponent({ enablePostalCodeToAddress: false, inquiryPanelEnable: false, postalCodeToAddressFee: 0, + enableCardToSheba: false, + cardToShebaFee: 0, + enableAccountToSheba: false, + accountToShebaFee: 0, }, loading: true, } @@ -65,6 +75,8 @@ export default defineComponent({ ...data, enablePostalCodeToAddress: data.enablePostalCodeToAddress === '1' || data.enablePostalCodeToAddress === true, inquiryPanelEnable: data.inquiryPanelEnable === '1' || data.inquiryPanelEnable === true, + enableCardToSheba: data.enableCardToSheba === '1' || data.enableCardToSheba === true, + enableAccountToSheba: data.enableAccountToSheba === '1' || data.enableAccountToSheba === true, activeGateway: data.activeGateway || 'zarinpal', inquiryPanel: data.inquiryPanel || 'zohal' }; @@ -85,6 +97,39 @@ export default defineComponent({ return; } + // Validation: if postal code to address is enabled, fee must be set + if (this.systemInfo.enablePostalCodeToAddress && this.systemInfo.postalCodeToAddressFee < 0) { + Swal.fire({ + text: 'کارمزد تبدیل کد پستی به آدرس نمی‌تواند منفی باشد.', + icon: 'error', + confirmButtonText: 'قبول', + }); + this.loading = false; + return; + } + + // Validation: if card to sheba is enabled, fee must be set + if (this.systemInfo.enableCardToSheba && this.systemInfo.cardToShebaFee < 0) { + Swal.fire({ + text: 'کارمزد تبدیل شماره کارت به شبا نمی‌تواند منفی باشد.', + icon: 'error', + confirmButtonText: 'قبول', + }); + this.loading = false; + return; + } + + // Validation: if account to sheba is enabled, fee must be set + if (this.systemInfo.enableAccountToSheba && this.systemInfo.accountToShebaFee < 0) { + Swal.fire({ + text: 'کارمزد تبدیل حساب به شبا نمی‌تواند منفی باشد.', + icon: 'error', + confirmButtonText: 'قبول', + }); + this.loading = false; + return; + } + axios.post('/api/admin/settings/system/info/save', this.systemInfo).then((resp) => { this.loading = false; if (resp.data.result == 1) { @@ -94,6 +139,13 @@ export default defineComponent({ confirmButtonText: 'قبول', }); } + }).catch((error) => { + this.loading = false; + Swal.fire({ + text: 'خطا در ذخیره تنظیمات. لطفاً دوباره تلاش کنید.', + icon: 'error', + confirmButtonText: 'قبول', + }); }) } @@ -107,92 +159,491 @@ export default defineComponent({ - \ No newline at end of file + \ No newline at end of file