Projekt

Allgemein

Profil

Herunterladen (1,28 KB) Statistiken
| Zweig: | Markierung: | Revision:
82515b2d Sven Schöling
package SL::DB::Chart;

use strict;

use SL::DB::MetaSetup::Chart;
da61b6b1 Moritz Bunkus
use SL::DB::Manager::Chart;
82515b2d Sven Schöling
e2013e83 Moritz Bunkus
__PACKAGE__->meta->add_relationships(taxkeys => { type => 'one to many',
class => 'SL::DB::TaxKey',
column_map => { id => 'chart_id' },
},
);

__PACKAGE__->meta->initialize;
82515b2d Sven Schöling
e2013e83 Moritz Bunkus
sub get_active_taxkey {
my ($self, $date) = @_;
$date ||= DateTime->today_local;
96717bed Sven Schöling
0a8ac1f3 Moritz Bunkus
my $cache = $::request->cache("get_active_taxkey")->{$date} //= {};
bba2bff3 Moritz Bunkus
return $cache->{$self->id} if $cache->{$self->id};
96717bed Sven Schöling
ff338f61 Sven Schöling
require SL::DB::TaxKey;
bba2bff3 Moritz Bunkus
return $cache->{$self->id} = SL::DB::Manager::TaxKey->get_all(
query => [ and => [ chart_id => $self->id,
startdate => { le => $date } ] ],
sort_by => "startdate DESC")->[0];
e2013e83 Moritz Bunkus
}

82515b2d Sven Schöling
1;
e2013e83 Moritz Bunkus
__END__

=pod

=encoding utf8

=head1 NAME

SL::DB::Chart - Rose database model for the "chart" table

=head1 FUNCTIONS

=over 4

=item C<get_active_taxkey $date>

Returns the active tax key object for a given date. C<$date> defaults
to the current date if undefined.

=back

=head1 BUGS

Nothing here yet.

=head1 AUTHOR

Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>

=cut