From: Moritz Bunkus Date: Tue, 15 Jan 2013 10:03:37 +0000 (+0100) Subject: SL::DB::Buchungsgruppen: Verknüpfungen und Hilfsmethoden X-Git-Tag: release-3.1.0beta1~696 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=04bfdc112567932e056aad505b79b4bf7dc6b4b4;p=kivitendo-erp.git SL::DB::Buchungsgruppen: Verknüpfungen und Hilfsmethoden --- diff --git a/SL/DB/Buchungsgruppe.pm b/SL/DB/Buchungsgruppe.pm index 5a486796d..1045ac190 100644 --- a/SL/DB/Buchungsgruppe.pm +++ b/SL/DB/Buchungsgruppe.pm @@ -5,6 +5,57 @@ use strict; use SL::DB::MetaSetup::Buchungsgruppe; use SL::DB::Manager::Buchungsgruppe; +__PACKAGE__->meta->add_relationship( + inventory_account => { + type => 'many to one', + class => 'SL::DB::Chart', + column_map => { income_accno_id_0 => 'id' }, + }, + income_account_0 => { + type => 'many to one', + class => 'SL::DB::Chart', + column_map => { income_accno_id_0 => 'id' }, + }, + income_account_1 => { + type => 'many to one', + class => 'SL::DB::Chart', + column_map => { income_accno_id_1 => 'id' }, + }, + income_account_2 => { + type => 'many to one', + class => 'SL::DB::Chart', + column_map => { income_accno_id_2 => 'id' }, + }, + income_account_3 => { + type => 'many to one', + class => 'SL::DB::Chart', + column_map => { income_accno_id_3 => 'id' }, + }, + expense_account_0 => { + type => 'many to one', + class => 'SL::DB::Chart', + column_map => { expense_accno_id_0 => 'id' }, + }, + expense_account_1 => { + type => 'many to one', + class => 'SL::DB::Chart', + column_map => { expense_accno_id_1 => 'id' }, + }, + expense_account_2 => { + type => 'many to one', + class => 'SL::DB::Chart', + column_map => { expense_accno_id_2 => 'id' }, + }, + expense_account_3 => { + type => 'many to one', + class => 'SL::DB::Chart', + column_map => { expense_accno_id_3 => 'id' }, + }, +); + +__PACKAGE__->meta->initialize; + + sub income_accno_id { my ($self, $taxzone) = @_; my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone; @@ -21,4 +72,70 @@ sub expense_accno_id { return $self->$method; } +sub income_account { + my ($self, $taxzone) = @_; + my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone; + my $method = 'income_account_' . $taxzone_id; + + return $self->$method; +} + +sub expense_account { + my ($self, $taxzone) = @_; + my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone; + my $method = 'expense_account_' . $taxzone_id; + + return $self->$method; +} + 1; +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::DB::Buchungsgruppe - RDBO wrapper for the C table + +=head1 FUNCTIONS + +=over 4 + +=item C + +Return the chart ID for the expense account for the given taxzone +(either an integer between 0 and 3 inclusively or an instance of +L). + +=item C + +Return the chart (an instance of L) for the expense +account for the given taxzone (either an integer between 0 and 3 +inclusively or an instance of L). + +=item C + +Return the chart ID for the income account for the given taxzone +(either an integer between 0 and 3 inclusively or an instance of +L). + +=item C + +Return the chart (an instance of L) for the income +account for the given taxzone (either an integer between 0 and 3 +inclusively or an instance of L). + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Sven Schöling Es.schoeling@linet-services.deE, +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut