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