walaa2022 commited on
Commit
c518467
·
verified ·
1 Parent(s): 6339dac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -93,9 +93,9 @@ class FinancialAnalyzer:
93
 
94
  def extract_metrics(self, income_data, balance_data):
95
  """Extract and calculate key financial metrics"""
96
- try:
97
  # Get current and previous year values for growth calculations
98
- metrics = {
99
  "Revenue": {
100
  "2025": self.get_nested_value(income_data, "Revenue", "Total Net Revenue", "2025"),
101
  "2024": self.get_nested_value(income_data, "Revenue", "Total Net Revenue", "2024"),
@@ -124,8 +124,8 @@ class FinancialAnalyzer:
124
  }
125
 
126
  # Calculate financial ratios
127
- revenue_2025 = metrics["Revenue"]["2025"]
128
- if revenue_2025 != 0:
129
  # Profitability Ratios
130
  metrics["Ratios"] = {
131
  "Gross_Margin": (metrics["Profitability"]["Gross_Profit_2025"] / revenue_2025) * 100,
@@ -149,10 +149,10 @@ class FinancialAnalyzer:
149
  "5Year_Revenue_CAGR": ((metrics["Revenue"]["2025"] / metrics["Revenue"]["2021"]) ** (1/4) - 1) * 100
150
  }
151
 
152
- return metrics
153
- except Exception as e:
154
- print(f"Error extracting metrics: {str(e)}")
155
- return {}
156
 
157
  def generate_analysis(self, prompt):
158
  """Generate analysis using TinyLlama"""
 
93
 
94
  def extract_metrics(self, income_data, balance_data):
95
  """Extract and calculate key financial metrics"""
96
+ try:
97
  # Get current and previous year values for growth calculations
98
+ metrics = {
99
  "Revenue": {
100
  "2025": self.get_nested_value(income_data, "Revenue", "Total Net Revenue", "2025"),
101
  "2024": self.get_nested_value(income_data, "Revenue", "Total Net Revenue", "2024"),
 
124
  }
125
 
126
  # Calculate financial ratios
127
+ revenue_2025 = metrics["Revenue"]["2025"]
128
+ if revenue_2025 != 0:
129
  # Profitability Ratios
130
  metrics["Ratios"] = {
131
  "Gross_Margin": (metrics["Profitability"]["Gross_Profit_2025"] / revenue_2025) * 100,
 
149
  "5Year_Revenue_CAGR": ((metrics["Revenue"]["2025"] / metrics["Revenue"]["2021"]) ** (1/4) - 1) * 100
150
  }
151
 
152
+ return metrics
153
+ except Exception as e:
154
+ print(f"Error extracting metrics: {str(e)}")
155
+ return {}
156
 
157
  def generate_analysis(self, prompt):
158
  """Generate analysis using TinyLlama"""