Spaces:
Runtime error
Runtime error
Create app.py
#2
by
Gan1-V - opened
app.py
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
def current_ratio_calculator(
|
| 5 |
+
cash,
|
| 6 |
+
marketable_securities,
|
| 7 |
+
accounts_receivable,
|
| 8 |
+
inventory,
|
| 9 |
+
prepaid_expenses,
|
| 10 |
+
accounts_payable,
|
| 11 |
+
short_term_debt,
|
| 12 |
+
accrued_liabilities,
|
| 13 |
+
unearned_revenue,
|
| 14 |
+
current_portion_ltd
|
| 15 |
+
):
|
| 16 |
+
# Totals
|
| 17 |
+
total_current_assets = (
|
| 18 |
+
cash
|
| 19 |
+
+ marketable_securities
|
| 20 |
+
+ accounts_receivable
|
| 21 |
+
+ inventory
|
| 22 |
+
+ prepaid_expenses
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
total_current_liabilities = (
|
| 26 |
+
accounts_payable
|
| 27 |
+
+ short_term_debt
|
| 28 |
+
+ accrued_liabilities
|
| 29 |
+
+ unearned_revenue
|
| 30 |
+
+ current_portion_ltd
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
# Metrics
|
| 34 |
+
working_capital = total_current_assets - total_current_liabilities
|
| 35 |
+
current_ratio = (
|
| 36 |
+
total_current_assets / total_current_liabilities
|
| 37 |
+
if total_current_liabilities != 0
|
| 38 |
+
else float("inf")
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
# Table data
|
| 42 |
+
data = pd.DataFrame({
|
| 43 |
+
"Component": [
|
| 44 |
+
"Cash & Cash Equivalents",
|
| 45 |
+
"Marketable Securities",
|
| 46 |
+
"Accounts Receivable",
|
| 47 |
+
"Inventory",
|
| 48 |
+
"Prepaid Expenses",
|
| 49 |
+
"Accounts Payable",
|
| 50 |
+
"Short-Term Debt/Loans",
|
| 51 |
+
"Accrued Liabilities/Expenses",
|
| 52 |
+
"Unearned Revenue",
|
| 53 |
+
"Current Portion of Long-Term Debt",
|
| 54 |
+
"Total Current Assets",
|
| 55 |
+
"Total Current Liabilities",
|
| 56 |
+
],
|
| 57 |
+
"Amount": [
|
| 58 |
+
cash,
|
| 59 |
+
marketable_securities,
|
| 60 |
+
accounts_receivable,
|
| 61 |
+
inventory,
|
| 62 |
+
prepaid_expenses,
|
| 63 |
+
accounts_payable,
|
| 64 |
+
short_term_debt,
|
| 65 |
+
accrued_liabilities,
|
| 66 |
+
unearned_revenue,
|
| 67 |
+
current_portion_ltd,
|
| 68 |
+
total_current_assets,
|
| 69 |
+
total_current_liabilities,
|
| 70 |
+
],
|
| 71 |
+
})
|
| 72 |
+
|
| 73 |
+
summary = f"""
|
| 74 |
+
### 📊 Current Ratio Analysis
|
| 75 |
+
|
| 76 |
+
- **Working Capital:** ₹ {working_capital:,.2f}
|
| 77 |
+
- **Current Ratio:** {current_ratio:.2f}
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
return summary, data
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
with gr.Blocks() as demo:
|
| 84 |
+
gr.Markdown("## CURRENT RATIO Calculator")
|
| 85 |
+
|
| 86 |
+
with gr.Row():
|
| 87 |
+
with gr.Column():
|
| 88 |
+
gr.Markdown("### Current Assets")
|
| 89 |
+
cash = gr.Number(label="Cash & Cash Equivalents", value=0)
|
| 90 |
+
marketable_securities = gr.Number(label="Marketable Securities", value=0)
|
| 91 |
+
accounts_receivable = gr.Number(label="Accounts Receivable", value=0)
|
| 92 |
+
inventory = gr.Number(label="Inventory", value=0)
|
| 93 |
+
prepaid_expenses = gr.Number(label="Prepaid Expenses", value=0)
|
| 94 |
+
|
| 95 |
+
with gr.Column():
|
| 96 |
+
gr.Markdown("### Current Liabilities")
|
| 97 |
+
accounts_payable = gr.Number(label="Accounts Payable", value=0)
|
| 98 |
+
short_term_debt = gr.Number(label="Short-Term Debt / Loans", value=0)
|
| 99 |
+
accrued_liabilities = gr.Number(label="Accrued Liabilities / Expenses", value=0)
|
| 100 |
+
unearned_revenue = gr.Number(label="Unearned Revenue", value=0)
|
| 101 |
+
current_portion_ltd = gr.Number(label="Current Portion of Long-Term Debt", value=0)
|
| 102 |
+
|
| 103 |
+
btn = gr.Button("Calculate")
|
| 104 |
+
|
| 105 |
+
summary_output = gr.Markdown()
|
| 106 |
+
table_output = gr.Dataframe()
|
| 107 |
+
|
| 108 |
+
btn.click(
|
| 109 |
+
current_ratio_calculator,
|
| 110 |
+
inputs=[
|
| 111 |
+
cash,
|
| 112 |
+
marketable_securities,
|
| 113 |
+
accounts_receivable,
|
| 114 |
+
inventory,
|
| 115 |
+
prepaid_expenses,
|
| 116 |
+
accounts_payable,
|
| 117 |
+
short_term_debt,
|
| 118 |
+
accrued_liabilities,
|
| 119 |
+
unearned_revenue,
|
| 120 |
+
current_portion_ltd,
|
| 121 |
+
],
|
| 122 |
+
outputs=[summary_output, table_output],
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
demo.launch()
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
|