Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| # Title and Description | |
| st.title('Operational Cash Flow Analysis') | |
| st.write(""" | |
| This application allows you to analyze and visualize your company's operational cash flow. | |
| """) | |
| # Data Input Section | |
| st.header('Input Financial Data') | |
| # Input fields for financial data | |
| net_income = st.number_input('Net Income', value=0) | |
| depreciation = st.number_input('Depreciation and Amortization', value=0) | |
| change_ar = st.number_input('Change in Accounts Receivable', value=0) | |
| change_inventory = st.number_input('Change in Inventory', value=0) | |
| change_ap = st.number_input('Change in Accounts Payable', value=0) | |
| # Calculating Operational Cash Flow | |
| ocf = net_income + depreciation - change_ar - change_inventory + change_ap | |
| # Displaying the result | |
| st.subheader('Calculated Operational Cash Flow') | |
| st.write(f'Operational Cash Flow: ${ocf}') | |
| # DataFrame for historical data visualization (example data) | |
| data = { | |
| 'Year': ['2020', '2021', '2022'], | |
| 'Net Income': [100000, 120000, 130000], | |
| 'Depreciation and Amortization': [20000, 25000, 27000], | |
| 'Change in AR': [-5000, -6000, -5500], | |
| 'Change in Inventory': [-8000, -7500, -9000], | |
| 'Change in AP': [7000, 8500, 9000], | |
| 'Operational Cash Flow': [114000, 137500, 149500] | |
| } | |
| df = pd.DataFrame(data) | |
| # Display the historical data table | |
| st.subheader('Historical Data') | |
| st.dataframe(df) | |
| # Visualize the historical operational cash flow | |
| st.subheader('Operational Cash Flow Over Years') | |
| st.line_chart(df[['Year', 'Operational Cash Flow']].set_index('Year')) | |
| # Scenario Analysis Section | |
| st.header('Scenario Analysis') | |
| # Interactive widgets for scenario analysis | |
| new_net_income = st.slider('New Net Income', min_value=0, max_value=200000, value=net_income) | |
| new_depreciation = st.slider('New Depreciation and Amortization', min_value=0, max_value=50000, value=depreciation) | |
| new_change_ar = st.slider('New Change in Accounts Receivable', min_value=-10000, max_value=10000, value=change_ar) | |
| new_change_inventory = st.slider('New Change in Inventory', min_value=-15000, max_value=15000, value=change_inventory) | |
| new_change_ap = st.slider('New Change in Accounts Payable', min_value=-10000, max_value=10000, value=change_ap) | |
| # Recalculate OCF based on new inputs | |
| new_ocf = new_net_income + new_depreciation - new_change_ar - new_change_inventory + new_change_ap | |
| # Display the new result | |
| st.subheader('Scenario Analysis Result') | |
| st.write(f'New Operational Cash Flow: ${new_ocf}') | |
| # Button to download data as CSV | |
| st.download_button( | |
| label="Download Data as CSV", | |
| data=df.to_csv().encode('utf-8'), | |
| file_name='operational_cash_flow.csv', | |
| mime='text/csv', | |
| ) | |