X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FBuchungsgruppe.pm;h=eb467c541b5791ed5aca4c235fd52b0a16d09e2a;hb=5bc87ade7044239fa9e893b9d7cbd476dc627eea;hp=65f75a534d5beca83383b5eaa5ba19aa94b3ab52;hpb=b989d7cfb4bd8de5c3e290b8df0519ad34d5dd0c;p=kivitendo-erp.git diff --git a/SL/DB/Buchungsgruppe.pm b/SL/DB/Buchungsgruppe.pm index 65f75a534..eb467c541 100644 --- a/SL/DB/Buchungsgruppe.pm +++ b/SL/DB/Buchungsgruppe.pm @@ -4,6 +4,7 @@ use strict; use SL::DB::MetaSetup::Buchungsgruppe; use SL::DB::Manager::Buchungsgruppe; +use SL::DB::Helper::ActsAsList; __PACKAGE__->meta->add_relationship( inventory_account => { @@ -15,9 +16,21 @@ __PACKAGE__->meta->add_relationship( __PACKAGE__->meta->initialize; +sub validate { + my ($self) = @_; + + my @errors; + push @errors, $::locale->text('The description is missing.') if !$self->description; + + return @errors; +} sub income_accno_id { my ($self, $taxzone) = @_; + + require SL::DB::TaxZone; + require SL::DB::TaxzoneChart; + my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone; my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id); return $taxzone_chart->income_accno_id if $taxzone_chart; @@ -25,6 +38,9 @@ sub income_accno_id { sub expense_accno_id { my ($self, $taxzone) = @_; + require SL::DB::TaxZone; + require SL::DB::TaxzoneChart; + my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone; my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id); return $taxzone_chart->expense_accno_id if $taxzone_chart; @@ -32,6 +48,10 @@ sub expense_accno_id { sub income_account { my ($self, $taxzone) = @_; + + require SL::DB::TaxZone; + require SL::DB::TaxzoneChart; + my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone; my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id); return $taxzone_chart->income_accno if $taxzone_chart; @@ -39,11 +59,29 @@ sub income_account { sub expense_account { my ($self, $taxzone) = @_; + + require SL::DB::TaxZone; + require SL::DB::TaxzoneChart; + my $taxzone_id = ref $taxzone && $taxzone->isa('SL::DB::TaxZone') ? $taxzone->id : $taxzone; my $taxzone_chart = SL::DB::Manager::TaxzoneChart->find_by(taxzone_id => $taxzone_id, buchungsgruppen_id => $self->id); return $taxzone_chart->expense_accno if $taxzone_chart; } +sub taxzonecharts { + my ($self) = @_; + return SL::DB::Manager::TaxzoneChart->get_all(where => [ buchungsgruppen_id => $self->id ]); +} + +sub orphaned { + my ($self) = @_; + die 'not an accessor' if @_ > 1; + + require SL::DB::Part; + return 0 if SL::DB::Manager::Part->get_all_count(query => [ buchungsgruppen_id => $self->id ]); + return 1; +} + 1; __END__ @@ -62,26 +100,29 @@ SL::DB::Buchungsgruppe - RDBO wrapper for the C table =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). +(either the DB id 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). +account for the given taxzone (either the DB id 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 +(either the DB id or an instance of L). 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). +account for the given taxzone (either the DB id or an instance of +L). + +=item C + +Checks whether this Buchungsgruppe is assigned to any parts. =back