X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FCA.pm;h=7ef4134196a68cdca53b31597996ae6fb96f2f56;hb=0fba3edda47fca21bedb14eb88e0f5f8d983bb38;hp=4f66c9b2b8b05be145a32662c868878d8f2f1174;hpb=c621a9187eb258019fa540490de21b248c709516;p=kivitendo-erp.git diff --git a/SL/CA.pm b/SL/CA.pm index 4f66c9b2b..7ef413419 100644 --- a/SL/CA.pm +++ b/SL/CA.pm @@ -1,4 +1,4 @@ -#===================================================================== + #===================================================================== # LX-Office ERP # Copyright (C) 2004 # Based on SQL-Ledger Version 2.1.9 @@ -50,10 +50,22 @@ sub all_accounts { # connect to database my $dbh = $form->dbconnect($myconfig); - if ($form->{method} eq "cash") { - $acc_cash_where = qq| AND (a.trans_id IN (SELECT id FROM ar WHERE datepaid>=(select date_trunc('year', current_date)) UNION SELECT id FROM ap WHERE datepaid>=(select date_trunc('year', current_date)) UNION SELECT id FROM gl WHERE transdate>=(select date_trunc('year', current_date)))) |; - } else { - $acc_cash_where = " AND ((select date_trunc('year', a.transdate::date)) >= (select date_trunc('year', current_date)))"; + # bug 1071 Warum sollte bei Erreichen eines neuen Jahres die Kontenübersicht nur noch die + # bereits bebuchten Konten anzeigen? + # Folgende Erweiterung: + # 1.) Gehe zurück bis zu dem Datum an dem die Bücher geschlossen wurden + # 2.) Falls die Bücher noch nie geschlossen wurden, gehe zurück bis zum Bearbeitungsstart + # COALESCE((SELECT closedto FROM defaults),(SELECT itime FROM defaults)) + + my $closedto_sql = "COALESCE((SELECT closedto FROM defaults),(SELECT itime FROM defaults))"; + + if ($form->{method} eq "cash") { # EÜR + $acc_cash_where = qq| AND (a.trans_id IN (SELECT id FROM ar WHERE datepaid>= $closedto_sql + UNION SELECT id FROM ap WHERE datepaid>= $closedto_sql + UNION SELECT id FROM gl WHERE transdate>= $closedto_sql + )) |; + } else { # Bilanzierung + $acc_cash_where = " AND ((select date_trunc('year', a.transdate::date)) >= $closedto_sql) "; } my $query = @@ -304,7 +316,7 @@ sub all_transactions { qq| AND ac.chart_id = ? | . qq| AND ac.trans_id = a.id | . qq| AND a.vendor_id = v.id | . - qq| AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)| . + qq| AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)|; push(@values, @where_values, @department_values, @project_values, $id, @where_values, @department_values, @project_values, $id,