fix bugs and added some feature for withdraw handling

This commit is contained in:
2026-07-19 15:49:52 +03:30
parent b446c21afc
commit 3cb1e1a0b0
17 changed files with 442 additions and 58 deletions
+17
View File
@@ -0,0 +1,17 @@
/** کدهای نامعتبر که پرگار/ته‌حساب گاهی به‌جای کد واقعی می‌فرستند */
const INVALID_ACCOUNTING_CODES = new Set(['', '0', '-1', 'null', 'undefined'])
export function normalizeAccountingCode(value: unknown): string | null {
if (value === null || value === undefined) return null
const trimmed = String(value).trim()
if (INVALID_ACCOUNTING_CODES.has(trimmed.toLowerCase())) return null
return trimmed
}
export function isValidAccountingCode(value: unknown): boolean {
return normalizeAccountingCode(value) !== null
}
export function displayAccountingCode(value: unknown): string {
return normalizeAccountingCode(value) ?? '-'
}
+16
View File
@@ -28,6 +28,9 @@ let settingsBootstrapped = false
/** reactive — برای فیلتر منوی «بنرها» در پیکربندی */
export const bannerEnabledSetting = ref(false)
/** reactive — برای فیلتر منوی «سایت‌های ری‌گیری» در پیکربندی */
export const trackingSystemsEnabledSetting = ref(false)
/** reactive — نمایش UI ته‌حساب در حسابداری و ... */
export const tahesabEnabledSetting = ref(false)
@@ -90,6 +93,10 @@ export function setBannerEnabledFromSettings(value: boolean): void {
bannerEnabledSetting.value = value
}
export function setTrackingSystemsEnabledFromSettings(value: boolean): void {
trackingSystemsEnabledSetting.value = value
}
export function setTahesabEnabledFromSettings(value: boolean): void {
tahesabEnabledFromSettings = value
tahesabEnabledSetting.value = value
@@ -110,6 +117,13 @@ export function applyBannerEnabledFromRows(rows: Array<{ key?: string; value?: s
setBannerEnabledFromSettings(row ? isSwitchOn(row.value) : false)
}
export function applyTrackingSystemsEnabledFromRows(
rows: Array<{ key?: string; value?: string | null }>
) {
const row = rows.find((item) => item.key === 'tracking_systems_enabled')
setTrackingSystemsEnabledFromSettings(row ? isSwitchOn(row.value) : false)
}
export function applyCustomerDirectSmsFromRows(rows: Array<{ key?: string; value?: string | null }>) {
const row = rows.find((item) => item.key === 'customer_direct_sms')
setCustomerDirectSmsEnabledFromSettings(row ? isSwitchOn(row.value) : false)
@@ -129,6 +143,7 @@ async function bootstrapSettingsFromApi(): Promise<void> {
storeModeFromSettings = isStoreRow ? isSwitchOn(isStoreRow.value) : false
applyAccountingProviderFromRows(list)
applyBannerEnabledFromRows(list)
applyTrackingSystemsEnabledFromRows(list)
applyCustomerDirectSmsFromRows(list)
setCachedMainMetal(mainMetalRow?.value)
const { setCachedMainWalletProductIds } = await import('@/components/mobile/utils/wallet')
@@ -136,6 +151,7 @@ async function bootstrapSettingsFromApi(): Promise<void> {
} catch {
storeModeFromSettings = false
setBannerEnabledFromSettings(false)
setTrackingSystemsEnabledFromSettings(false)
setCustomerDirectSmsEnabledFromSettings(false)
applyAccountingProviderFromRows([])
setCachedMainMetal(null)