export interface GrowthMetrics {
revenueGrowth: number;
employeeGrowth: number;
assetGrowth: number;
overallGrowthScore: number;
growthCategory: 'high' | 'moderate' | 'stable' | 'declining';
}
export class GrowthScorer {
calculateGrowth(current: number, previous: number): number {
if (!previous || previous === 0) return 0;
return ((current - previous) / previous) * 100;
}
scoreGrowth(financialHistory: any[]): GrowthMetrics | null {
if (financialHistory.length < 2) return null;
const latest = financialHistory[0];
const previous = financialHistory[1];
const revenueGrowth = this.calculateGrowth(latest.revenue, previous.revenue);
const employeeGrowth = this.calculateGrowth(latest.employees, previous.employees);
const assetGrowth = this.calculateGrowth(latest.assets, previous.assets);
// Weighted average
const overallGrowthScore = (
revenueGrowth * 0.5 +
employeeGrowth * 0.3 +
assetGrowth * 0.2
);
let growthCategory: GrowthMetrics['growthCategory'];
if (overallGrowthScore >= 50) growthCategory = 'high';
else if (overallGrowthScore >= 20) growthCategory = 'moderate';
else if (overallGrowthScore >= 0) growthCategory = 'stable';
else growthCategory = 'declining';
return {
revenueGrowth: Math.round(revenueGrowth),
employeeGrowth: Math.round(employeeGrowth),
assetGrowth: Math.round(assetGrowth),
overallGrowthScore: Math.round(overallGrowthScore),
growthCategory
};
}
}