X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/6b935d522a38e1a20802c25ed51a15e0cd292c1d..3a45c5ca624f39ebbab4fffcbc7ccb1c96e0f3e0:/SL/DB/Manager/Chart.pm diff --git a/SL/DB/Manager/Chart.pm b/SL/DB/Manager/Chart.pm index a0167fd23..f7728aef1 100644 --- a/SL/DB/Manager/Chart.pm +++ b/SL/DB/Manager/Chart.pm @@ -6,6 +6,8 @@ use SL::DB::Helper::Manager; use base qw(SL::DB::Helper::Manager); use SL::DB::Helper::Sorted; +use DateTime; +use SL::DBUtils; sub object_class { 'SL::DB::Chart' } @@ -20,6 +22,27 @@ sub link_filter { link => { like => "\%:${link}:\%" } ]); } +sub cache_taxkeys { + my ($self, %params) = @_; + + my $date = $params{date} || DateTime->today; + my $cache = $::request->cache('::SL::DB::Chart::get_active_taxkey')->{$date} //= {}; + + require SL::DB::TaxKey; + my $tks = SL::DB::Manager::TaxKey->get_all; + my %tks_by_id = map { $_->id => $_ } @$tks; + + my $rows = selectall_hashref_query($::form, $::form->get_standard_dbh, <<"", $date); + SELECT DISTINCT ON (chart_id) chart_id, startdate, id + FROM taxkeys + WHERE startdate < ? + ORDER BY chart_id, startdate DESC; + + for (@$rows) { + $cache->{$_->{chart_id}} = $tks_by_id{$_->{id}}; + } +} + 1; __END__