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;
29 my ($self, $taxzone) = @_;
31 require SL::DB::TaxZone;
32 require SL::DB::TaxzoneChart;
34 my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone;
35 my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id);
36 return $taxzone_chart->income_accno_id if $taxzone_chart;
39 sub expense_accno_id {
40 my ($self, $taxzone) = @_;
41 require SL::DB::TaxZone;
42 require SL::DB::TaxzoneChart;
44 my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone;
45 my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id);
46 return $taxzone_chart->expense_accno_id if $taxzone_chart;
50 my ($self, $taxzone) = @_;
52 require SL::DB::TaxZone;
53 require SL::DB::TaxzoneChart;
55 my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone;
56 my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id);
57 return $taxzone_chart->income_accno if $taxzone_chart;
61 my ($self, $taxzone) = @_;
63 require SL::DB::TaxZone;
64 require SL::DB::TaxzoneChart;
66 my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone;
67 my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id);
68 return $taxzone_chart->expense_accno if $taxzone_chart;
73 return SL::DB::Manager::TaxzoneChart->get_all(where => [ buchungsgruppen_id => $self->id ]);
85 SL::DB::Buchungsgruppe - RDBO wrapper for the C<buchungsgruppen> table
91 =item C<expense_accno_id $taxzone>
93 Return the chart ID for the expense account for the given taxzone
94 (either the DB id or an instance of L<SL::DB::TaxZone>).
96 =item C<expense_account>
98 Return the chart (an instance of L<SL::DB::Chart>) for the expense
99 account for the given taxzone (either the DB id or an instance of
102 =item C<income_accno_id>
104 Return the chart ID for the income account for the given taxzone
105 (either the DB id or an instance of L<SL::DB::TaxZone>).
108 =item C<income_account>
110 Return the chart (an instance of L<SL::DB::Chart>) for the income
111 account for the given taxzone (either the DB id or an instance of
122 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>,
123 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>