Tabelle anpassen
This commit is contained in:
parent
dff3c4471b
commit
487722333a
74
main.py
74
main.py
|
|
@ -23,7 +23,6 @@ class LLMClient:
|
|||
if not base_url:
|
||||
base_url = "http://10.192.0.140:8002" if self.backend_type == "vllm" else "http://localhost:11434"
|
||||
|
||||
# KUGELSICHERER REINIGER: Filtert versehentliche Markdown-Links [...] vorab heraus
|
||||
base_url = base_url.strip()
|
||||
if base_url.startswith("[") and ")" in base_url:
|
||||
match = re.search(r"\((https?://.*?)\)", base_url)
|
||||
|
|
@ -169,7 +168,6 @@ def extract_invoice_items_pure_python(text):
|
|||
|
||||
desc_lines.insert(0, prev_line)
|
||||
|
||||
# OPTIMIERUNG: Fügt die restlichen Zeilen jetzt als sauberen Fließtext (" ") statt untereinander (\n) zusammen
|
||||
if desc_lines:
|
||||
item_name = desc_lines[0].strip()
|
||||
item_description = " ".join(desc_lines[1:]).strip() if len(desc_lines) > 1 else ""
|
||||
|
|
@ -505,35 +503,67 @@ with col2:
|
|||
r_city = st.text_input("Stadt (Kunde)", value=data.get("recipient_city", ""))
|
||||
|
||||
# ==========================================
|
||||
# 6. ENTKOPPELTES POSITIONEN FRONTEND (VOLLBREITE OBERFLÄCHE)
|
||||
# 6. MODULARES POSITIONEN-FRONTEND (VOLLBREITE OHNE TRUNCATION)
|
||||
# ==========================================
|
||||
if st.session_state.extracted_data:
|
||||
data = st.session_state.extracted_data
|
||||
|
||||
st.markdown("### 3. Positionen")
|
||||
|
||||
# 🔥 FIX: Feste Pixelbreiten für die Spalten konfigurieren und 'use_container_width=True' nutzen!
|
||||
# Numerische Spalten bleiben kompakt (90px - 130px), Textspalten erhalten massiven Platz (250px - 500px).
|
||||
edited_items = st.data_editor(
|
||||
data.get("items", []),
|
||||
num_rows="dynamic",
|
||||
use_container_width=True,
|
||||
column_config={
|
||||
"name": st.column_config.TextColumn("Artikelname (BT-153)", width=250, required=True),
|
||||
"description": st.column_config.TextColumn("Zusatzbeschreibung (BT-154)", width=500),
|
||||
"quantity": st.column_config.NumberColumn("Menge", width=90, format="%.4f"),
|
||||
"unit": st.column_config.TextColumn("Einheit", width=90),
|
||||
"unit_price": st.column_config.NumberColumn("Einzelpreis (€)", width=110, format="%.2f"),
|
||||
"total_amount": st.column_config.NumberColumn("Gesamtbetrag (€)", width=130, format="%.2f", disabled=True)
|
||||
}
|
||||
)
|
||||
# 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])
|
||||
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])
|
||||
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}")
|
||||
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("**Gesamtbetrag (€):**")
|
||||
st.markdown(f"#### {item_total_amount:.2f} €")
|
||||
|
||||
# Speichert den editierten Zustand dieses Blocks ab
|
||||
edited_items.append({
|
||||
"name": item_name,
|
||||
"description": item_description,
|
||||
"quantity": item_quantity,
|
||||
"unit": item_unit,
|
||||
"unit_price": item_price,
|
||||
"total_amount": item_total_amount
|
||||
})
|
||||
|
||||
st.markdown("---")
|
||||
vat_rate = st.number_input("Steuersatz (%)", value=float(data.get("vat_rate_percent") or 19.0))
|
||||
|
||||
for item in edited_items:
|
||||
raw_total = float(item.get("quantity") or 0.0) * float(item.get("unit_price") or 0.0)
|
||||
item["total_amount"] = kaufmaennisches_runden(raw_total)
|
||||
|
||||
# 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