1 package SL::DB::Buchungsgruppe;
5 use SL::DB::MetaSetup::Buchungsgruppe;
6 use SL::DB::Manager::Buchungsgruppe;
7 use SL::DB::Helper::ActsAsList;
9 __PACKAGE__->meta->add_relationship(
10 inventory_account => {
11 type => 'many to one',
12 class => 'SL::DB::Chart',
13 column_map => { inventory_accno_id => 'id' },
17 __PACKAGE__->meta->initialize;
23 push @errors, $::locale->text('The description is missing.') if !$self->description;
30 require SL::DB::Manager::Chart;
31 return SL::DB::Manager::Chart->find_by(id => $self->inventory_accno_id) ? SL::DB::Manager::Chart->find_by(id => $self->inventory_accno_id)->accno() : undef;
34 sub inventory_accno_description {
36 require SL::DB::Manager::Chart;
37 return SL::DB::Manager::Chart->find_by(id => $self->inventory_accno_id) ? SL::DB::Manager::Chart->find_by(id => $self->inventory_accno_id)->description() : undef;
41 my ($self, $taxzone) = @_;
42 my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone;
43 my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id);
44 return $taxzone_chart->income_accno_id if $taxzone_chart;
47 sub expense_accno_id {
48 my ($self, $taxzone) = @_;
49 my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone;
50 my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id);
51 return $taxzone_chart->expense_accno_id if $taxzone_chart;
55 my ($self, $taxzone) = @_;
56 my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone;
57 my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id);
58 return $taxzone_chart->income_accno if $taxzone_chart;
62 my ($self, $taxzone) = @_;
63 my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone;
64 my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id);
65 return $taxzone_chart->expense_accno if $taxzone_chart;
70 return SL::DB::Manager::TaxzoneChart->get_all(where => [ buchungsgruppen_id => $self->id ]);
82 SL::DB::Buchungsgruppe - RDBO wrapper for the C<buchungsgruppen> table
88 =item C<expense_accno_id $taxzone>
90 Return the chart ID for the expense account for the given taxzone
91 (either an integer between 0 and 3 inclusively or an instance of
94 =item C<expense_account>
96 Return the chart (an instance of L<SL::DB::Chart>) for the expense
97 account for the given taxzone (either an integer between 0 and 3
98 inclusively or an instance of L<SL::DB::TaxZone>).
100 =item C<income_accno_id>
102 Return the chart ID for the income account for the given taxzone
103 (either an integer between 0 and 3 inclusively or an instance of
106 =item C<income_account>
108 Return the chart (an instance of L<SL::DB::Chart>) for the income
109 account for the given taxzone (either an integer between 0 and 3
110 inclusively or an instance of L<SL::DB::TaxZone>).
120 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>,
121 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>