X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/e2013e83d2ada0ba4ca439d972dbeaf56cbc16c0..93b69b192a3dcd39d09b7a7e24b1482bdfa69e6b:/SL/DB/Chart.pm?ds=sidebyside diff --git a/SL/DB/Chart.pm b/SL/DB/Chart.pm index 42cd6c947..40ac530d4 100644 --- a/SL/DB/Chart.pm +++ b/SL/DB/Chart.pm @@ -3,7 +3,7 @@ package SL::DB::Chart; use strict; use SL::DB::MetaSetup::Chart; -use SL::DB::TaxKey; +use SL::DB::Manager::Chart; __PACKAGE__->meta->add_relationships(taxkeys => { type => 'one to many', class => 'SL::DB::TaxKey', @@ -12,14 +12,19 @@ __PACKAGE__->meta->add_relationships(taxkeys => { type => 'one to many', ); __PACKAGE__->meta->initialize; -__PACKAGE__->meta->make_manager_class; sub get_active_taxkey { my ($self, $date) = @_; $date ||= DateTime->today_local; - return SL::DB::Manager::TaxKey->get_all(where => [ and => [ chart_id => $self->id, - startdate => { le => $date } ] ], - sort_by => "startdate DESC")->[0]; + + my $cache = $::request->cache("get_active_taxkey")->{$date} //= {}; + return $cache->{$self->id} if $cache->{$self->id}; + + require SL::DB::TaxKey; + return $cache->{$self->id} = SL::DB::Manager::TaxKey->get_all( + query => [ and => [ chart_id => $self->id, + startdate => { le => $date } ] ], + sort_by => "startdate DESC")->[0]; } 1;