12 lines
455 B
TypeScript
12 lines
455 B
TypeScript
import { Account } from './types.js';
|
|
|
|
export function calculateAccountHealth(account: Account): 'healthy' | 'warning' | 'at-risk' {
|
|
if (account.dealCount > 5 && account.totalRevenue > 50000) return 'healthy';
|
|
if (account.dealCount > 2 || account.totalRevenue > 20000) return 'warning';
|
|
return 'at-risk';
|
|
}
|
|
|
|
export function sortAccountsByRevenue(accounts: Account[]): Account[] {
|
|
return accounts.sort((a, b) => b.totalRevenue - a.totalRevenue);
|
|
}
|