Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,10 +120,23 @@ def generate_balance_sheet(ledger_df, net_income):
|
|
| 120 |
equity = net_income # Retained earnings
|
| 121 |
|
| 122 |
for index, row in ledger_df.iterrows():
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
balance_sheet = pd.DataFrame({
|
| 129 |
"Category": ["Total Assets", "Total Liabilities", "Total Equity"],
|
|
|
|
| 120 |
equity = net_income # Retained earnings
|
| 121 |
|
| 122 |
for index, row in ledger_df.iterrows():
|
| 123 |
+
account_name = row["Account"]
|
| 124 |
+
balance = row["Balance"]
|
| 125 |
+
|
| 126 |
+
if any(keyword in account_name.lower() for keyword in ["cash", "inventory", "equipment", "accounts receivable"]):
|
| 127 |
+
assets += balance
|
| 128 |
+
elif any(keyword in account_name.lower() for keyword in ["loan", "accounts payable"]):
|
| 129 |
+
liabilities += abs(balance)
|
| 130 |
+
elif any(keyword in account_name.lower() for keyword in ["capital", "equity"]):
|
| 131 |
+
equity += balance
|
| 132 |
+
|
| 133 |
+
# Ensuring the balance equation holds: Assets = Liabilities + Equity
|
| 134 |
+
if assets != (liabilities + equity):
|
| 135 |
+
difference = assets - (liabilities + equity)
|
| 136 |
+
if difference > 0:
|
| 137 |
+
liabilities += difference
|
| 138 |
+
else:
|
| 139 |
+
assets += abs(difference)
|
| 140 |
|
| 141 |
balance_sheet = pd.DataFrame({
|
| 142 |
"Category": ["Total Assets", "Total Liabilities", "Total Equity"],
|