Tabelle anpassen
This commit is contained in:
parent
487722333a
commit
6d0701f911
24
main.py
24
main.py
|
|
@ -502,55 +502,44 @@ with col2:
|
|||
r_zip = st.text_input("PLZ (Kunde)", value=data.get("recipient_zip", ""))
|
||||
r_city = st.text_input("Stadt (Kunde)", value=data.get("recipient_city", ""))
|
||||
|
||||
# ==========================================
|
||||
# 6. MODULARES POSITIONEN-FRONTEND (VOLLBREITE OHNE TRUNCATION)
|
||||
# ==========================================
|
||||
if st.session_state.extracted_data:
|
||||
data = st.session_state.extracted_data
|
||||
|
||||
# 🔥 NEU: Die Positionen-Karten befinden sich ab jetzt genau hier innerhalb von Spalte 2!
|
||||
st.markdown("### 3. Positionen")
|
||||
|
||||
# Button zum manuellen Hinzufügen einer leeren Position
|
||||
if st.button("➕ Neue Position hinzufügen"):
|
||||
data["items"].append({"name": "Neue Dienstleistung", "description": "", "quantity": 1.0, "unit": "Stk.", "unit_price": 0.0})
|
||||
st.rerun()
|
||||
|
||||
edited_items = []
|
||||
|
||||
# Jede Position bekommt eine eigene, vollflächige Karte (Expander)
|
||||
for idx, item in enumerate(data.get("items", [])):
|
||||
with st.expander(f"📋 Position {idx+1}: {item.get('name', 'Dienstleistung')}", expanded=True):
|
||||
|
||||
# Löschen-Button für diese spezifische Position
|
||||
c_del, _ = st.columns([1, 11])
|
||||
c_del, _ = st.columns([1, 4])
|
||||
with c_del:
|
||||
if st.button("🗑️ Position löschen", key=f"del_btn_{idx}"):
|
||||
data["items"].pop(idx)
|
||||
st.rerun()
|
||||
|
||||
# Zeile 1: Name und Beschreibung nebeneinander (Beschreibung als echtes, umbrechendes Textfeld!)
|
||||
c_name, c_desc = st.columns([1, 2])
|
||||
c_name, c_desc = st.columns([1, 1])
|
||||
with c_name:
|
||||
item_name = st.text_input("Artikelname (BT-153)", value=item.get("name", ""), key=f"item_name_{idx}")
|
||||
with c_desc:
|
||||
item_description = st.text_area("Zusatzbeschreibung (BT-154)", value=item.get("description", ""), key=f"item_desc_{idx}", height=68)
|
||||
|
||||
# Zeile 2: Numerische Werte sauber aufgeteilt
|
||||
c_qty, c_unit, c_price, c_total = st.columns(4)
|
||||
with c_qty:
|
||||
item_quantity = st.number_input("Menge", value=float(item.get("quantity") or 0.0), format="%.4f", key=f"item_qty_{idx}")
|
||||
# 🔥 OPTIMIERUNG: Format auf %.1f gesetzt für genau eine Nachkommastelle
|
||||
item_quantity = st.number_input("Menge", value=float(item.get("quantity") or 0.0), format="%.1f", key=f"item_qty_{idx}")
|
||||
with c_unit:
|
||||
item_unit = st.text_input("Einheit", value=item.get("unit", "Stk."), key=f"item_unit_{idx}")
|
||||
with c_price:
|
||||
item_price = st.number_input("Einzelpreis (€)", value=float(item.get("unit_price") or 0.0), format="%.2f", key=f"item_price_{idx}")
|
||||
with c_total:
|
||||
# Automatische Live-Berechnung des Zeilen-Gesamtwerts
|
||||
raw_item_total = item_quantity * item_price
|
||||
item_total_amount = kaufmaennisches_runden(raw_item_total)
|
||||
st.markdown("**Gesamt betrag (€):**")
|
||||
st.markdown(f"#### {item_total_amount:.2f} €")
|
||||
st.markdown(f"**{item_total_amount:.2f} €**")
|
||||
|
||||
# Speichert den editierten Zustand dieses Blocks ab
|
||||
edited_items.append({
|
||||
"name": item_name,
|
||||
"description": item_description,
|
||||
|
|
@ -563,7 +552,6 @@ if st.session_state.extracted_data:
|
|||
st.markdown("---")
|
||||
vat_rate = st.number_input("Steuersatz (%)", value=float(data.get("vat_rate_percent") or 19.0))
|
||||
|
||||
# Globale Summenberechnung
|
||||
computed_net_amount = sum(item["total_amount"] for item in edited_items)
|
||||
raw_vat_amount = computed_net_amount * (vat_rate / 100.0)
|
||||
computed_vat_amount = kaufmaennisches_runden(raw_vat_amount)
|
||||
|
|
|
|||
Loading…
Reference in New Issue