Consolidate sync buttons into one flow on ????? ????????, deduplicate treasury vs invoice and customer vouchers, add FunZone inventory lifecycle views, and improve stat card number display. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
/** Human-readable label for a FunZone event name (wallet → کیف پول). */
|
|
export function formatEventName(eventName: string | null | undefined): string {
|
|
if (!eventName?.trim()) return '—'
|
|
return eventName.toLowerCase() === 'wallet' ? 'کیف پول' : eventName.trim()
|
|
}
|
|
|
|
/** Raw event name stored on records (wallet stays as wallet). */
|
|
export function normalizeEventName(value: string): string {
|
|
const trimmed = value.trim()
|
|
if (!trimmed) return ''
|
|
if (trimmed === 'کیف پول') return 'wallet'
|
|
return trimmed
|
|
}
|
|
|
|
/** Parses event name from a FunZone treasury import description block. */
|
|
export function eventNameFromTreasuryDescription(description: string): string | undefined {
|
|
const line = description.split('\n').find((l) => l.startsWith('رویداد:'))
|
|
if (!line) return undefined
|
|
const raw = line.replace(/^رویداد:\s*/, '').trim()
|
|
if (!raw || raw === '—') return undefined
|
|
return raw === 'کیف پول' ? 'wallet' : raw
|
|
}
|
|
|
|
/** Event label with category context for accounting "regarding" fields. */
|
|
export function eventNameWithCategory(
|
|
eventName: string | null | undefined,
|
|
categoryName: string | null | undefined,
|
|
): string {
|
|
const rawEvent = eventName?.trim() ?? ''
|
|
const rawCategory = categoryName?.trim() ?? ''
|
|
if (!rawEvent) return ''
|
|
if (rawEvent.toLowerCase() === 'wallet') return 'wallet'
|
|
if (!rawCategory) return rawEvent
|
|
return `${rawEvent} (${rawCategory})`
|
|
}
|