Update main.py
Browse files
main.py
CHANGED
|
@@ -243,7 +243,7 @@ def process_pdf_pages(pdf_file):
|
|
| 243 |
if isinstance(txns, list):
|
| 244 |
all_txns.extend(txns)
|
| 245 |
|
| 246 |
-
return all_txns
|
| 247 |
|
| 248 |
# --------- Chat Endpoint ---------
|
| 249 |
@app.route("/chat", methods=["POST"])
|
|
@@ -292,7 +292,7 @@ def upload_statements():
|
|
| 292 |
|
| 293 |
|
| 294 |
# extract + store transactions
|
| 295 |
-
txns = process_pdf_pages(f)
|
| 296 |
for txn in txns:
|
| 297 |
try:
|
| 298 |
dt = datetime.strptime(txn["Date"], "%d/%m/%Y")
|
|
@@ -312,7 +312,7 @@ def upload_statements():
|
|
| 312 |
fs.collection("transactions").add(record)
|
| 313 |
stored_count += 1
|
| 314 |
|
| 315 |
-
return jsonify({"message": f"Stored {stored_count} transactions", str(
|
| 316 |
|
| 317 |
# --------- Endpoint: Retrieve or Generate Financial Statement ---------
|
| 318 |
|
|
|
|
| 243 |
if isinstance(txns, list):
|
| 244 |
all_txns.extend(txns)
|
| 245 |
|
| 246 |
+
return all_txns, txt
|
| 247 |
|
| 248 |
# --------- Chat Endpoint ---------
|
| 249 |
@app.route("/chat", methods=["POST"])
|
|
|
|
| 292 |
|
| 293 |
|
| 294 |
# extract + store transactions
|
| 295 |
+
txns, txt = process_pdf_pages(f)
|
| 296 |
for txn in txns:
|
| 297 |
try:
|
| 298 |
dt = datetime.strptime(txn["Date"], "%d/%m/%Y")
|
|
|
|
| 312 |
fs.collection("transactions").add(record)
|
| 313 |
stored_count += 1
|
| 314 |
|
| 315 |
+
return jsonify({"message": f"Stored {stored_count} transactions", "file": str(txt)}), 200
|
| 316 |
|
| 317 |
# --------- Endpoint: Retrieve or Generate Financial Statement ---------
|
| 318 |
|