fix: Jahresabschluss-Buchungen (closure) aus Kontenauswertung ausschließen

Closure-Einträge (Saldovorträge) wurden fälschlicherweise als echte
Buchungsdaten erkannt, was zu negativen Ausgaben und fehlenden Einnahmen
führte wenn nur Abschlussbuchungen für ein Jahr existierten.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Eduard Wisch 2026-03-13 11:52:46 +01:00
parent 927ed2ec07
commit 13ff3b5962
2 changed files with 10 additions and 2 deletions

View file

@ -315,6 +315,7 @@ class box_gewinn_verlust extends ModeleBoxes
$sql .= " WHERE b.entity = ".((int) $conf->entity);
$sql .= " AND YEAR(b.doc_date) = ".((int) $year);
$sql .= " AND b.numero_compte LIKE '8%'"; // Erlöskonten
$sql .= " AND b.doc_type != 'closure'";
$sql .= " GROUP BY MONTH(b.doc_date)";
$resql = $this->db->query($sql);
@ -331,6 +332,7 @@ class box_gewinn_verlust extends ModeleBoxes
$sql .= " WHERE b.entity = ".((int) $conf->entity);
$sql .= " AND YEAR(b.doc_date) = ".((int) $year);
$sql .= " AND b.numero_compte LIKE '3%'"; // Wareneinsatz/Materialkosten
$sql .= " AND b.doc_type != 'closure'";
$sql .= " GROUP BY MONTH(b.doc_date)";
$resql = $this->db->query($sql);
@ -381,7 +383,8 @@ class box_gewinn_verlust extends ModeleBoxes
}
/**
* Check if accounting data exists for the given year
* Check if real accounting data exists for the given year
* Excludes closure/opening balance entries (doc_type = 'closure')
*/
private function hasAccountingData($year)
{
@ -390,6 +393,7 @@ class box_gewinn_verlust extends ModeleBoxes
$sql = "SELECT COUNT(*) as cnt FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " WHERE entity = ".((int) $conf->entity);
$sql .= " AND YEAR(doc_date) = ".((int) $year);
$sql .= " AND doc_type != 'closure'";
$sql .= " LIMIT 1";
$resql = $this->db->query($sql);

View file

@ -326,6 +326,7 @@ class box_rentabilitaet extends ModeleBoxes
$sql .= " WHERE b.entity = ".((int) $conf->entity);
$sql .= " AND YEAR(b.doc_date) = ".((int) $year);
$sql .= " AND b.numero_compte LIKE '8%'"; // Erlöskonten
$sql .= " AND b.doc_type != 'closure'";
$sql .= " GROUP BY MONTH(b.doc_date)";
$resql = $this->db->query($sql);
@ -342,6 +343,7 @@ class box_rentabilitaet extends ModeleBoxes
$sql .= " WHERE b.entity = ".((int) $conf->entity);
$sql .= " AND YEAR(b.doc_date) = ".((int) $year);
$sql .= " AND (b.numero_compte LIKE '3%' OR b.numero_compte LIKE '4%')"; // Wareneinsatz + Betriebskosten
$sql .= " AND b.doc_type != 'closure'";
$sql .= " GROUP BY MONTH(b.doc_date)";
$resql = $this->db->query($sql);
@ -388,7 +390,8 @@ class box_rentabilitaet extends ModeleBoxes
}
/**
* Check if accounting data exists for the given year
* Check if real accounting data exists for the given year
* Excludes closure/opening balance entries (doc_type = 'closure')
*/
private function hasAccountingData($year)
{
@ -397,6 +400,7 @@ class box_rentabilitaet extends ModeleBoxes
$sql = "SELECT COUNT(*) as cnt FROM ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " WHERE entity = ".((int) $conf->entity);
$sql .= " AND YEAR(doc_date) = ".((int) $year);
$sql .= " AND doc_type != 'closure'";
$sql .= " LIMIT 1";
$resql = $this->db->query($sql);