Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,7 +43,45 @@ def parse_assumptions(assumptions_text):
|
|
| 43 |
params[key] = value
|
| 44 |
|
| 45 |
return params
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
def generate_financials(assumptions_text):
|
| 48 |
params = parse_assumptions(assumptions_text)
|
| 49 |
print("halo mulai", params)
|
|
@@ -113,7 +151,7 @@ def generate_financials(assumptions_text):
|
|
| 113 |
|
| 114 |
print("Excel file 'output.xlsx' created with two sheets.")
|
| 115 |
|
| 116 |
-
return 'financial_projections.xlsx'
|
| 117 |
|
| 118 |
# Gradio interface
|
| 119 |
with gr.Blocks() as demo:
|
|
|
|
| 43 |
params[key] = value
|
| 44 |
|
| 45 |
return params
|
| 46 |
+
|
| 47 |
+
def generate_charts(pl_df, cf_df):
|
| 48 |
+
# Create Profit Loss chart
|
| 49 |
+
plt.figure(figsize=(10, 6))
|
| 50 |
+
plt.plot(pl_df['Year'], pl_df['Revenue'], label='Revenue', marker='o')
|
| 51 |
+
plt.plot(pl_df['Year'], pl_df['Net Income'], label='Net Income', marker='s')
|
| 52 |
+
plt.title('Profit and Loss Trend')
|
| 53 |
+
plt.xlabel('Year')
|
| 54 |
+
plt.ylabel('Amount (Rp)')
|
| 55 |
+
plt.grid(True)
|
| 56 |
+
plt.legend()
|
| 57 |
+
plt.tight_layout()
|
| 58 |
+
|
| 59 |
+
# Save PL chart to BytesIO
|
| 60 |
+
pl_chart_io = BytesIO()
|
| 61 |
+
plt.savefig(pl_chart_io, format='png')
|
| 62 |
+
plt.close()
|
| 63 |
+
pl_chart_io.seek(0)
|
| 64 |
+
pl_chart_base64 = base64.b64encode(pl_chart_io.read()).decode('utf-8')
|
| 65 |
+
|
| 66 |
+
# Create Cashflow chart
|
| 67 |
+
plt.figure(figsize=(10, 6))
|
| 68 |
+
plt.plot(cf_df['Year'], cf_df['Net Cashflow'], label='Net Cashflow', marker='o', color='green')
|
| 69 |
+
plt.title('Cashflow Trend')
|
| 70 |
+
plt.xlabel('Year')
|
| 71 |
+
plt.ylabel('Amount (Rp)')
|
| 72 |
+
plt.grid(True)
|
| 73 |
+
plt.legend()
|
| 74 |
+
plt.tight_layout()
|
| 75 |
+
|
| 76 |
+
# Save CF chart to BytesIO
|
| 77 |
+
cf_chart_io = BytesIO()
|
| 78 |
+
plt.savefig(cf_chart_io, format='png')
|
| 79 |
+
plt.close()
|
| 80 |
+
cf_chart_io.seek(0)
|
| 81 |
+
cf_chart_base64 = base64.b64encode(cf_chart_io.read()).decode('utf-8')
|
| 82 |
+
|
| 83 |
+
return pl_chart_base64, cf_chart_base64
|
| 84 |
+
|
| 85 |
def generate_financials(assumptions_text):
|
| 86 |
params = parse_assumptions(assumptions_text)
|
| 87 |
print("halo mulai", params)
|
|
|
|
| 151 |
|
| 152 |
print("Excel file 'output.xlsx' created with two sheets.")
|
| 153 |
|
| 154 |
+
return 'financial_projections.xlsx', f"data:image/png;base64,{pl_chart_base64}", f"data:image/png;base64,{cf_chart_base64}"
|
| 155 |
|
| 156 |
# Gradio interface
|
| 157 |
with gr.Blocks() as demo:
|