Ankushbl6 commited on
Commit
5a8516a
Β·
verified Β·
1 Parent(s): 5ae15b4

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +10 -5
src/streamlit_app.py CHANGED
@@ -865,6 +865,7 @@ def flatten_invoice_to_rows(invoice_data) -> list:
865
  "Item Amount": 0.0,
866
  "Item Tax": 0.0,
867
  "Item Line Total": 0.0,
 
868
  })
869
  rows.append(row)
870
  return rows
@@ -880,6 +881,7 @@ def flatten_invoice_to_rows(invoice_data) -> list:
880
  "Item Amount": format_amount_field(item.get("Amount", 0.0) if isinstance(item, dict) else 0.0),
881
  "Item Tax": format_amount_field(item.get("Tax", 0.0) if isinstance(item, dict) else 0.0),
882
  "Item Line Total": format_amount_field(item.get("Line Total", item.get("Amount", 0.0)) if isinstance(item, dict) else 0.0),
 
883
  })
884
  rows.append(row)
885
  return rows
@@ -1237,15 +1239,15 @@ elif len(st.session_state.batch_results) > 0:
1237
  total_tax = edited_df["Tax"].sum()
1238
  total_line_total = edited_df["Line Total"].sum()
1239
 
1240
- # Create totals display - styled to look like part of the table
1241
  totals_df = pd.DataFrame([{
1242
  "Description": "──── TOTAL ────",
1243
  "Quantity": "",
1244
  "Unit Price": "",
1245
- "Amount": f"${total_amount:,.2f}",
1246
  "IO Number/Cost Centre": "", # Empty for totals row
1247
- "Tax": f"${total_tax:,.2f}",
1248
- "Line Total": f"${total_line_total:,.2f}"
1249
  }])
1250
 
1251
  st.dataframe(
@@ -1254,6 +1256,9 @@ elif len(st.session_state.batch_results) > 0:
1254
  hide_index=True,
1255
  height=38 # Single row height
1256
  )
 
 
 
1257
 
1258
  saved = st.form_submit_button("πŸ’Ύ Save All Edits")
1259
  # ----------------- FORM END -----------------
@@ -1327,7 +1332,7 @@ elif len(st.session_state.batch_results) > 0:
1327
  st.session_state.batch_results[selected_hash]["edited_data"] = updated
1328
 
1329
  # Show success message
1330
- st.success(f"βœ… Saved: {current['file_name']} | Updated totals: Subtotal=${calculated_subtotal:,.2f}, Tax=${calculated_total_tax:,.2f}, Total=${calculated_total:,.2f}")
1331
 
1332
  # Per-file CSV download (ALWAYS visible, uses current edited values)
1333
  download_data = {
 
865
  "Item Amount": 0.0,
866
  "Item Tax": 0.0,
867
  "Item Line Total": 0.0,
868
+ "IO Number/Cost Centre": "NA", # Add as last column
869
  })
870
  rows.append(row)
871
  return rows
 
881
  "Item Amount": format_amount_field(item.get("Amount", 0.0) if isinstance(item, dict) else 0.0),
882
  "Item Tax": format_amount_field(item.get("Tax", 0.0) if isinstance(item, dict) else 0.0),
883
  "Item Line Total": format_amount_field(item.get("Line Total", item.get("Amount", 0.0)) if isinstance(item, dict) else 0.0),
884
+ "IO Number/Cost Centre": format_text_field(item.get("IO Number/Cost Centre", "") if isinstance(item, dict) else ""), # Add as last column
885
  })
886
  rows.append(row)
887
  return rows
 
1239
  total_tax = edited_df["Tax"].sum()
1240
  total_line_total = edited_df["Line Total"].sum()
1241
 
1242
+ # Create totals display - styled to look like part of the table (no currency symbols)
1243
  totals_df = pd.DataFrame([{
1244
  "Description": "──── TOTAL ────",
1245
  "Quantity": "",
1246
  "Unit Price": "",
1247
+ "Amount": f"{total_amount:,.2f}",
1248
  "IO Number/Cost Centre": "", # Empty for totals row
1249
+ "Tax": f"{total_tax:,.2f}",
1250
+ "Line Total": f"{total_line_total:,.2f}"
1251
  }])
1252
 
1253
  st.dataframe(
 
1256
  hide_index=True,
1257
  height=38 # Single row height
1258
  )
1259
+
1260
+ # Add spacing before save button to prevent overlap
1261
+ st.write("") # Empty line for spacing
1262
 
1263
  saved = st.form_submit_button("πŸ’Ύ Save All Edits")
1264
  # ----------------- FORM END -----------------
 
1332
  st.session_state.batch_results[selected_hash]["edited_data"] = updated
1333
 
1334
  # Show success message
1335
+ st.success("βœ… Saved")
1336
 
1337
  # Per-file CSV download (ALWAYS visible, uses current edited values)
1338
  download_data = {