Bhuvi13 commited on
Commit
ffa140c
·
verified ·
1 Parent(s): c7194d8

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +5 -2
src/streamlit_app.py CHANGED
@@ -2697,14 +2697,17 @@ elif len(st.session_state.batch_results) > 0:
2697
  updated_data["Itemized Data"] = edited_df.to_dict("records")
2698
 
2699
  # Recalculate subtotal + line totals
2700
-
 
 
 
2701
 
2702
  # Save back immediately (no Save button needed)
2703
  st.session_state.batch_results[selected_hash]["edited_data"] = updated_data
2704
 
2705
  # Optional: keep subtotal widget in sync
2706
  subtotal_calc_key = f"Subtotal_calc_{selected_hash}"
2707
- st.session_state[subtotal_calc_key] = updated_data["Subtotal"]
2708
 
2709
  # Display non-editable totals row immediately below (looks integrated)
2710
  if len(edited_df) > 0:
 
2697
  updated_data["Itemized Data"] = edited_df.to_dict("records")
2698
 
2699
  # Recalculate subtotal + line totals
2700
+ if len(edited_df) > 0 and "Amount" in edited_df.columns:
2701
+ updated_data["Subtotal"] = round(edited_df["Amount"].apply(clean_float).sum(), 2)
2702
+ else:
2703
+ updated_data["Subtotal"] = updated_data.get("Subtotal", 0.0)
2704
 
2705
  # Save back immediately (no Save button needed)
2706
  st.session_state.batch_results[selected_hash]["edited_data"] = updated_data
2707
 
2708
  # Optional: keep subtotal widget in sync
2709
  subtotal_calc_key = f"Subtotal_calc_{selected_hash}"
2710
+ st.session_state[subtotal_calc_key] = updated_data.get("Subtotal", 0.0)
2711
 
2712
  # Display non-editable totals row immediately below (looks integrated)
2713
  if len(edited_df) > 0: