5 use SL::DB::MetaSetup::Chart;
6 use SL::DB::Manager::Chart;
8 __PACKAGE__->meta->add_relationships(taxkeys => { type => 'one to many',
9 class => 'SL::DB::TaxKey',
10 column_map => { id => 'chart_id' },
14 __PACKAGE__->meta->initialize;
16 sub get_active_taxkey {
17 my ($self, $date) = @_;
18 $date ||= DateTime->today_local;
20 my $cache = $::request->cache("get_active_taxkey")->{$date} //= {};
21 return $cache->{$self->id} if $cache->{$self->id};
23 require SL::DB::TaxKey;
24 return $cache->{$self->id} = SL::DB::Manager::TaxKey->get_all(
25 query => [ and => [ chart_id => $self->id,
26 startdate => { le => $date } ] ],
27 sort_by => "startdate DESC")->[0];
40 SL::DB::Chart - Rose database model for the "chart" table
46 =item C<get_active_taxkey $date>
48 Returns the active tax key object for a given date. C<$date> defaults
49 to the current date if undefined.
59 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>