changes of boursecu
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
const BANK_ACCENT_COLORS: Record<string, string> = {
|
||||
'بانک پاسارگاد': '#1f7a54',
|
||||
'پاسارگاد': '#1f7a54',
|
||||
'بانک سامان': '#2f63d8',
|
||||
'سامان': '#2f63d8',
|
||||
'SAMAN': '#2f63d8',
|
||||
'بانک پارسیان': '#c9a227',
|
||||
'پارسیان': '#c9a227',
|
||||
'بانک ملی': '#4b5e96',
|
||||
'ملی': '#4b5e96',
|
||||
'بانک ملت': '#c0392b',
|
||||
'ملت': '#c0392b',
|
||||
'بانک صادرات': '#1a6fb3',
|
||||
'صادرات': '#1a6fb3',
|
||||
}
|
||||
|
||||
export function formatShebaForDisplay(value?: string | number | null): string {
|
||||
if (value == null || value === '') {
|
||||
return ''
|
||||
}
|
||||
|
||||
const normalized = String(value).replace(/\s/g, '').toUpperCase()
|
||||
const digits = normalized.startsWith('IR') ? normalized.slice(2) : normalized
|
||||
|
||||
if (digits.length < 24) {
|
||||
return normalized.startsWith('IR') ? normalized : `IR${normalized}`
|
||||
}
|
||||
|
||||
return [
|
||||
'IR',
|
||||
digits.slice(0, 4),
|
||||
digits.slice(4, 8),
|
||||
digits.slice(8, 12),
|
||||
digits.slice(12, 16),
|
||||
digits.slice(16, 20),
|
||||
digits.slice(20, 24),
|
||||
].join(' ')
|
||||
}
|
||||
|
||||
export function getBankAccentColor(bankName?: string): string {
|
||||
if (!bankName) {
|
||||
return '#64748b'
|
||||
}
|
||||
|
||||
const trimmed = bankName.trim()
|
||||
if (BANK_ACCENT_COLORS[trimmed]) {
|
||||
return BANK_ACCENT_COLORS[trimmed]
|
||||
}
|
||||
|
||||
const matched = Object.entries(BANK_ACCENT_COLORS).find(([name]) => trimmed.includes(name))
|
||||
return matched?.[1] ?? '#64748b'
|
||||
}
|
||||
|
||||
export function getBankMonogram(bankName?: string): string {
|
||||
if (!bankName?.trim()) {
|
||||
return 'بانک'
|
||||
}
|
||||
|
||||
const normalized = bankName.replace(/^بانک\s+/u, '').trim()
|
||||
return normalized.slice(0, 2) || 'بانک'
|
||||
}
|
||||
Reference in New Issue
Block a user