From e2013e83d2ada0ba4ca439d972dbeaf56cbc16c0 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 9 Nov 2010 08:45:11 +0100 Subject: [PATCH] =?utf8?q?Chart-Model:=20Hilfsfunktion=20zum=20Auslesen=20?= =?utf8?q?des=20an=20einem=20Datum=20g=C3=BCltigen=20Steuerschl=C3=BCssels?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/Chart.pm | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/SL/DB/Chart.pm b/SL/DB/Chart.pm index 2d865b55d..42cd6c947 100644 --- a/SL/DB/Chart.pm +++ b/SL/DB/Chart.pm @@ -3,7 +3,54 @@ package SL::DB::Chart; use strict; use SL::DB::MetaSetup::Chart; +use SL::DB::TaxKey; +__PACKAGE__->meta->add_relationships(taxkeys => { type => 'one to many', + class => 'SL::DB::TaxKey', + column_map => { id => 'chart_id' }, + }, + ); + +__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]; +} + 1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::DB::Chart - Rose database model for the "chart" table + +=head1 FUNCTIONS + +=over 4 + +=item C + +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 Em.bunkus@linet-services.deE + +=cut -- 2.20.1