Ankushbl6 commited on
Commit
15c3cd0
Β·
verified Β·
1 Parent(s): 3cd4a9e

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +9 -9
src/streamlit_app.py CHANGED
@@ -1496,26 +1496,26 @@ elif len(st.session_state.batch_results) > 0:
1496
 
1497
  # Display non-editable totals row immediately below (looks integrated)
1498
  if len(edited_df) > 0:
1499
- total_amount = edited_df["Amount"].sum()
1500
- total_tax = edited_df["Tax"].sum()
1501
- total_line_total = edited_df["Line Total"].sum()
1502
-
1503
- # Create totals display - styled to look like part of the table (no currency symbols)
1504
  totals_df = pd.DataFrame([{
1505
  "Description": "──── TOTAL ────",
1506
  "Quantity": "",
1507
  "Unit Price": "",
1508
  "Amount": f"{total_amount:,.2f}",
1509
- "IO Number/Cost Centre": "", # Empty for totals row
1510
  "Tax": f"{total_tax:,.2f}",
1511
  "Line Total": f"{total_line_total:,.2f}"
1512
  }])
1513
-
1514
  st.dataframe(
1515
  totals_df,
1516
- use_container_width=True,
1517
  hide_index=True,
1518
- height=38 # Single row height
1519
  )
1520
 
1521
  # Add spacing before save button to prevent overlap
 
1496
 
1497
  # Display non-editable totals row immediately below (looks integrated)
1498
  if len(edited_df) > 0:
1499
+ # Use clean_float so weird types (lists, strings, etc.) don't break things
1500
+ total_amount = sum(clean_float(v) for v in edited_df["Amount"])
1501
+ total_tax = sum(clean_float(v) for v in edited_df["Tax"])
1502
+ total_line_total = sum(clean_float(v) for v in edited_df["Line Total"])
1503
+
1504
  totals_df = pd.DataFrame([{
1505
  "Description": "──── TOTAL ────",
1506
  "Quantity": "",
1507
  "Unit Price": "",
1508
  "Amount": f"{total_amount:,.2f}",
1509
+ "IO Number/Cost Centre": "",
1510
  "Tax": f"{total_tax:,.2f}",
1511
  "Line Total": f"{total_line_total:,.2f}"
1512
  }])
1513
+
1514
  st.dataframe(
1515
  totals_df,
1516
+ width="stretch", # <- see note below
1517
  hide_index=True,
1518
+ height=38
1519
  )
1520
 
1521
  # Add spacing before save button to prevent overlap