]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/Chart.pm
SL::DB::{Chart,Part}: Verwendung von $::request->cache()
[mfinanz.git] / SL / DB / Chart.pm
index bda45128c584aec1234163fc190c79da8115ae4f..7c50b43d3f548b3407474c0cbd1245f94a59359d 100644 (file)
@@ -4,7 +4,6 @@ use strict;
 
 use SL::DB::MetaSetup::Chart;
 use SL::DB::Manager::Chart;
-use SL::DB::TaxKey;
 
 __PACKAGE__->meta->add_relationships(taxkeys => { type         => 'one to many',
                                                   class        => 'SL::DB::TaxKey',
@@ -17,7 +16,14 @@ __PACKAGE__->meta->initialize;
 sub get_active_taxkey {
   my ($self, $date) = @_;
   $date ||= DateTime->today_local;
-  return SL::DB::Manager::TaxKey->get_all(where   => [ and => [ chart_id  => $self->id,
+
+  my $cache = $::request->cache("get_active_taxkey")->{$date} //= {};
+  if ($cache->{$self->id}) {
+    return $cache->{$self->id};
+  }
+
+  require SL::DB::TaxKey;
+  return SL::DB::Manager::TaxKey->get_all(query   => [ and => [ chart_id  => $self->id,
                                                                 startdate => { le => $date } ] ],
                                           sort_by => "startdate DESC")->[0];
 }