atifsial123 commited on
Commit
ac5e180
·
verified ·
1 Parent(s): 6539c9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -22,6 +22,10 @@ def add_invoice(head, company_name, sp_station, invoice_no, date, amount):
22
  "Amount": float(amount)
23
  }
24
  ledger = pd.concat([ledger, pd.DataFrame([new_row])], ignore_index=True)
 
 
 
 
25
 
26
  # Filter the ledger for the selected head
27
  filtered_ledger = ledger[ledger["Head"] == head]
@@ -41,6 +45,9 @@ def search_by_head(head):
41
  # Filter the ledger for the selected head
42
  filtered_ledger = ledger[ledger["Head"] == head]
43
 
 
 
 
44
  # Calculate the total for the selected head
45
  total_amount = filtered_ledger["Amount"].sum()
46
 
@@ -62,6 +69,9 @@ def generate_ledger_pdf(head):
62
  print(f"No records found for {head}")
63
  return None
64
 
 
 
 
65
  # Use a temporary directory to save the file
66
  with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp_file:
67
  pdf_file_path = tmp_file.name # Get the temporary file path
@@ -100,6 +110,7 @@ def generate_ledger_pdf(head):
100
  pdf.output(pdf_file_path)
101
 
102
  # Return the file path for download
 
103
  return pdf_file_path
104
 
105
  except Exception as e:
 
22
  "Amount": float(amount)
23
  }
24
  ledger = pd.concat([ledger, pd.DataFrame([new_row])], ignore_index=True)
25
+
26
+ # Debugging output
27
+ print("New row added:", new_row)
28
+ print("Updated ledger:", ledger)
29
 
30
  # Filter the ledger for the selected head
31
  filtered_ledger = ledger[ledger["Head"] == head]
 
45
  # Filter the ledger for the selected head
46
  filtered_ledger = ledger[ledger["Head"] == head]
47
 
48
+ # Debugging output
49
+ print(f"Records for {head}:", filtered_ledger)
50
+
51
  # Calculate the total for the selected head
52
  total_amount = filtered_ledger["Amount"].sum()
53
 
 
69
  print(f"No records found for {head}")
70
  return None
71
 
72
+ # Debugging output
73
+ print(f"Generating PDF for {head}")
74
+
75
  # Use a temporary directory to save the file
76
  with tempfile.NamedTemporaryFile(delete=False, suffix=".pdf") as tmp_file:
77
  pdf_file_path = tmp_file.name # Get the temporary file path
 
110
  pdf.output(pdf_file_path)
111
 
112
  # Return the file path for download
113
+ print(f"PDF generated at: {pdf_file_path}")
114
  return pdf_file_path
115
 
116
  except Exception as e: