Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def time_value_of_money_calculator(capital_expenditure, annual_revenue, operating_expenditure, project_years, minimum_attractive_rate_of_return): | |
| capital_expenditure = float(capital_expenditure) | |
| annual_revenue = float(annual_revenue) | |
| operating_expenditure = float(operating_expenditure) | |
| project_years = int(project_years) | |
| minimum_attractive_rate_of_return = float(minimum_attractive_rate_of_return)/100 | |
| cash_flows = [-capital_expenditure] + [annual_revenue - operating_expenditure] * project_years | |
| net_present_value = sum(cf/(1+minimum_attractive_rate_of_return)**i for i,cf in enumerate(cash_flows)) | |
| cumulative_cash_flow = 0 | |
| payback_period = 0 | |
| for i in range(1, len(cash_flows)): | |
| cumulative_cash_flow += cash_flows[i] | |
| payback_period = i | |
| if cumulative_cash_flow >= capital_expenditure: break | |
| profitability_index = abs(net_present_value/capital_expenditure)*100 | |
| project_status = "β PROJECT VIABLE" if net_present_value>0 else "β PROJECT REVIEW NEEDED" | |
| return f"""π§ͺ **Time Value of Money Analysis** | |
| **INPUTS:** | |
| - **CAPEX:** ${capital_expenditure:,.0f} | |
| - **REV:** ${annual_revenue:,.0f} | |
| - **OPEX:** ${operating_expenditure:,.0f} | |
| **OUTPUTS:** | |
| - **NPV:** ${net_present_value:,.0f} | |
| - **PAYBACK:** {payback_period} years | |
| - **PI:** {profitability_index:.1f}% | |
| - **STATUS:** {project_status} | |
| --- | |
| **π¨βπΌ App Builder: M.Kamran Liaqat** | |
| **π ID: 2k23-chE-05** | |
| """ | |
| gr.Interface(time_value_of_money_calculator, | |
| [gr.Number(10000000, label="CAPEX ($)"), | |
| gr.Number(5000000, label="Annual Revenue ($)"), | |
| gr.Number(3500000, label="Operating Expenditure ($)"), | |
| gr.Slider(5,30,15, label="Project Years"), | |
| gr.Slider(8,20,12, label="MARR (%)")], | |
| gr.Textbox(), | |
| title="π§ͺ ChemEng TVM Calculator").launch() |