]> wagnertech.de Git - kivitendo-erp.git/blob - SL/DB/Buchungsgruppe.pm
Auf Datenbankebene Steuerzonen konfigurierbar gemacht
[kivitendo-erp.git] / SL / DB / Buchungsgruppe.pm
1 package SL::DB::Buchungsgruppe;
2
3 use strict;
4
5 use SL::DB::MetaSetup::Buchungsgruppe;
6 use SL::DB::Manager::Buchungsgruppe;
7
8 __PACKAGE__->meta->add_relationship(
9   inventory_account => {
10     type          => 'many to one',
11     class         => 'SL::DB::Chart',
12     column_map    => { inventory_accno_id => 'id' },
13   },
14 );
15
16 __PACKAGE__->meta->initialize;
17
18
19 sub income_accno_id {
20   my ($self, $taxzone) = @_;
21   my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone;
22   my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id);
23   return $taxzone_chart->income_accno_id if $taxzone_chart;
24 }
25
26 sub expense_accno_id {
27   my ($self, $taxzone) = @_;
28   my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone;
29   my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id);
30   return $taxzone_chart->expense_accno_id if $taxzone_chart;
31 }
32
33 sub income_account {
34   my ($self, $taxzone) = @_;
35   my $taxzone_id       = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone;
36   my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id);
37   return $taxzone_chart->income_accno if $taxzone_chart;
38 }
39
40 sub expense_account {
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->expense_accno if $taxzone_chart;
45 }
46
47 1;
48 __END__
49
50 =pod
51
52 =encoding utf8
53
54 =head1 NAME
55
56 SL::DB::Buchungsgruppe - RDBO wrapper for the C<buchungsgruppen> table
57
58 =head1 FUNCTIONS
59
60 =over 4
61
62 =item C<expense_accno_id $taxzone>
63
64 Return the chart ID for the expense account for the given taxzone
65 (either an integer between 0 and 3 inclusively or an instance of
66 L<SL::DB::TaxZone>).
67
68 =item C<expense_account>
69
70 Return the chart (an instance of L<SL::DB::Chart>) for the expense
71 account for the given taxzone (either an integer between 0 and 3
72 inclusively or an instance of L<SL::DB::TaxZone>).
73
74 =item C<income_accno_id>
75
76 Return the chart ID for the income account for the given taxzone
77 (either an integer between 0 and 3 inclusively or an instance of
78 L<SL::DB::TaxZone>).
79
80 =item C<income_account>
81
82 Return the chart (an instance of L<SL::DB::Chart>) for the income
83 account for the given taxzone (either an integer between 0 and 3
84 inclusively or an instance of L<SL::DB::TaxZone>).
85
86 =back
87
88 =head1 BUGS
89
90 Nothing here yet.
91
92 =head1 AUTHOR
93
94 Sven Schöling E<lt>s.schoeling@linet-services.deE<gt>,
95 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
96
97 =cut