App lokal aktualisiert
This commit is contained in:
parent
11830c060a
commit
9523c7a74d
14
app.py
14
app.py
|
|
@ -5,8 +5,8 @@ import re
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from decimal import Decimal, ROUND_HALF_UP # Für finanzmathematisch exaktes Runden
|
from decimal import Decimal, ROUND_HALF_UP
|
||||||
import fitz # PyMuPDF
|
import fitz
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
from llama_cpp import Llama, LlamaGrammar
|
from llama_cpp import Llama, LlamaGrammar
|
||||||
|
|
||||||
|
|
@ -27,7 +27,7 @@ class InvoiceMetadata(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
# ==========================================
|
# ==========================================
|
||||||
# 2. PRÄZISE MATHEMATISCHE FUNKTIONEN
|
# 2. MATHEMATISCHE FUNKTIONEN
|
||||||
# ==========================================
|
# ==========================================
|
||||||
def kaufmaennisches_runden(betrag, nachkommastellen=2):
|
def kaufmaennisches_runden(betrag, nachkommastellen=2):
|
||||||
"""
|
"""
|
||||||
|
|
@ -128,7 +128,6 @@ def generate_compliant_xrechnung(data):
|
||||||
|
|
||||||
root = ET.Element(f"{{{INVOICE_NS}}}Invoice")
|
root = ET.Element(f"{{{INVOICE_NS}}}Invoice")
|
||||||
|
|
||||||
# BT-24 ID angepasst auf den exakten Core-String
|
|
||||||
ET.SubElement(root, f"{{{CBC}}}CustomizationID").text = "urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_3.0"
|
ET.SubElement(root, f"{{{CBC}}}CustomizationID").text = "urn:cen.eu:en16931:2017#compliant#urn:xoev-de:kosit:standard:xrechnung_3.0"
|
||||||
ET.SubElement(root, f"{{{CBC}}}ProfileID").text = "urn:fdc:peppol.eu:poacc:bis:invoice:3"
|
ET.SubElement(root, f"{{{CBC}}}ProfileID").text = "urn:fdc:peppol.eu:poacc:bis:invoice:3"
|
||||||
ET.SubElement(root, f"{{{CBC}}}ID").text = str(data["invoice_number"])
|
ET.SubElement(root, f"{{{CBC}}}ID").text = str(data["invoice_number"])
|
||||||
|
|
@ -170,7 +169,6 @@ def generate_compliant_xrechnung(data):
|
||||||
legal_supp = ET.SubElement(party_supp, f"{{{CAC}}}PartyLegalEntity")
|
legal_supp = ET.SubElement(party_supp, f"{{{CAC}}}PartyLegalEntity")
|
||||||
ET.SubElement(legal_supp, f"{{{CBC}}}RegistrationName").text = "scitech it solutions GmbH"
|
ET.SubElement(legal_supp, f"{{{CBC}}}RegistrationName").text = "scitech it solutions GmbH"
|
||||||
|
|
||||||
# FIX: Hinzufügen der Gruppe "SELLER CONTACT" (BG-6) zur Behebung von BR-DE-2
|
|
||||||
contact_supp = ET.SubElement(party_supp, f"{{{CAC}}}Contact")
|
contact_supp = ET.SubElement(party_supp, f"{{{CAC}}}Contact")
|
||||||
ET.SubElement(contact_supp, f"{{{CBC}}}Name").text = "Geschäftsführung"
|
ET.SubElement(contact_supp, f"{{{CBC}}}Name").text = "Geschäftsführung"
|
||||||
ET.SubElement(contact_supp, f"{{{CBC}}}Telephone").text = "+49 3302 4940537"
|
ET.SubElement(contact_supp, f"{{{CBC}}}Telephone").text = "+49 3302 4940537"
|
||||||
|
|
@ -245,7 +243,7 @@ def generate_compliant_xrechnung(data):
|
||||||
|
|
||||||
|
|
||||||
# ==========================================
|
# ==========================================
|
||||||
# 3. ABSOLUTE MODELL-LADUNG (QWEN 3.5 INSTRUCT)
|
# 3. KI MODELL (QWEN 3.5 INSTRUCT)
|
||||||
# ==========================================
|
# ==========================================
|
||||||
def get_cached_llm():
|
def get_cached_llm():
|
||||||
if "llm_instance" not in st.session_state:
|
if "llm_instance" not in st.session_state:
|
||||||
|
|
@ -328,7 +326,7 @@ with col2:
|
||||||
edited_items = st.data_editor(data.get("items", []), num_rows="dynamic", width="stretch")
|
edited_items = st.data_editor(data.get("items", []), num_rows="dynamic", width="stretch")
|
||||||
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))
|
||||||
|
|
||||||
# Live-Berechnung inklusive kaufmännischem Runden auf Positionsebene
|
# Berechnung inklusive kaufmännischem Runden auf Positionsebene
|
||||||
for item in edited_items:
|
for item in edited_items:
|
||||||
raw_total = float(item.get("quantity") or 0.0) * float(item.get("unit_price") or 0.0)
|
raw_total = float(item.get("quantity") or 0.0) * float(item.get("unit_price") or 0.0)
|
||||||
item["total_amount"] = kaufmaennisches_runden(raw_total)
|
item["total_amount"] = kaufmaennisches_runden(raw_total)
|
||||||
|
|
@ -339,7 +337,7 @@ with col2:
|
||||||
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)
|
||||||
|
|
||||||
# Brutto setzt sich sauber aus den gerundeten Netto- und MwSt-Werten zusammen
|
# Brutto aus den gerundeten Netto- und MwSt-Werten
|
||||||
computed_gross_amount = kaufmaennisches_runden(computed_net_amount + computed_vat_amount)
|
computed_gross_amount = kaufmaennisches_runden(computed_net_amount + computed_vat_amount)
|
||||||
|
|
||||||
st.markdown("**Berechnete Summen:**")
|
st.markdown("**Berechnete Summen:**")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue