feat(accounting): Shayegan docs tab and fixed provider UI

Show Shayegan sync table/health in admin and always treat boursecu accounting as Shayegan.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-05 17:12:55 +03:30
co-authored by Cursor
parent 7e869902d6
commit 8a4f95da7d
5 changed files with 193 additions and 17 deletions
+19 -15
View File
@@ -1,7 +1,7 @@
import { ref } from 'vue'
import { setCachedMainMetal } from '@/utils/metalLabels'
export type AccountingProvider = 'none' | 'pargar' | 'tahesab' | 'zarin'
export type AccountingProvider = 'none' | 'pargar' | 'tahesab' | 'zarin' | 'shayegan'
export function getConfigApp(key: string) {
const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user : {}
@@ -47,6 +47,9 @@ export const zarinEnabledSetting = ref(false)
/** reactive — نمایش UI پرگار در حسابداری و ... */
export const pargarEnabledSetting = ref(false)
/** reactive — نمایش UI شایگان در حسابداری و ... */
export const shayeganEnabledSetting = ref(false)
/** reactive — دکمه پیامک تکی در لیست مشتریان */
export const customerDirectSmsEnabledSetting = ref(false)
@@ -100,6 +103,7 @@ export const accountingProviderSetting = ref<AccountingProvider>('none')
let tahesabEnabledFromSettings: boolean | null = null
let zarinEnabledFromSettings: boolean | null = null
let pargarEnabledFromSettings: boolean | null = null
let shayeganEnabledFromSettings: boolean | null = null
let customerDirectSmsFromSettings: boolean | null = null
let accountingProviderFromSettings: AccountingProvider | null = null
@@ -113,25 +117,15 @@ function isSwitchOn(value: string | number | boolean | undefined | null): boolea
function normalizeAccountingProvider(value: string | undefined | null): AccountingProvider {
const v = (value ?? '').trim().toLowerCase()
if (v === 'pargar' || v === 'tahesab' || v === 'zarin') return v
if (v === 'pargar' || v === 'tahesab' || v === 'zarin' || v === 'shayegan') return v
return 'none'
}
/** بورس مس: UI حسابداری همیشه شایگان — settings/legacy نادیده گرفته می‌شود. */
function resolveAccountingProviderFromRows(
list: Array<{ key?: string; value?: string | null }>
_list: Array<{ key?: string; value?: string | null }>
): AccountingProvider {
const row = list.find((item) => item.key === 'accounting_provider')
if (row?.value !== undefined && row?.value !== null && String(row.value).trim() !== '') {
return normalizeAccountingProvider(row.value)
}
const pargarLegacy = list.find((item) => item.key === 'send_to_pargar')
if (pargarLegacy && isSwitchOn(pargarLegacy.value)) return 'pargar'
const tahesabLegacy = list.find((item) => item.key === 'send_to_tahesab')
if (tahesabLegacy && isSwitchOn(tahesabLegacy.value)) return 'tahesab'
return 'none'
return 'shayegan'
}
export function applyAccountingProviderFromRows(
@@ -143,6 +137,7 @@ export function applyAccountingProviderFromRows(
setTahesabEnabledFromSettings(provider === 'tahesab')
setZarinEnabledFromSettings(provider === 'zarin')
setPargarEnabledFromSettings(provider === 'pargar')
setShayeganEnabledFromSettings(provider === 'shayegan')
}
export function setStoreModeFromSettings(value: boolean): void {
@@ -172,6 +167,11 @@ export function setPargarEnabledFromSettings(value: boolean): void {
pargarEnabledSetting.value = value
}
export function setShayeganEnabledFromSettings(value: boolean): void {
shayeganEnabledFromSettings = value
shayeganEnabledSetting.value = value
}
export function setCustomerDirectSmsEnabledFromSettings(value: boolean): void {
customerDirectSmsFromSettings = value
customerDirectSmsEnabledSetting.value = value
@@ -491,6 +491,10 @@ export function isPargarEnabled(): boolean {
return pargarEnabledFromSettings === true
}
export function isShayeganEnabled(): boolean {
return shayeganEnabledFromSettings === true
}
export function getAccountingProvider(): AccountingProvider {
return accountingProviderFromSettings ?? 'none'
}