X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FCA.pm;h=7ef4134196a68cdca53b31597996ae6fb96f2f56;hb=b2945bf61775161f9ce9be9bdbd106ad44247a14;hp=460c5290b593bf0d6a50ae548ffd7cff2d2befd8;hpb=e3b43a8c921b96ebf56e15479ce28fefdac481c3;p=kivitendo-erp.git diff --git a/SL/CA.pm b/SL/CA.pm index 460c5290b..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 =