X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/0eb8e2233994c12c3fc2f560bb1fac1428e9156e..c19b1e03fb03f195d86a5b78f8ce2338f745f599:/SL/DB/RequirementSpecItem.pm diff --git a/SL/DB/RequirementSpecItem.pm b/SL/DB/RequirementSpecItem.pm index dc7f5c1e6..8ed37b9d7 100644 --- a/SL/DB/RequirementSpecItem.pm +++ b/SL/DB/RequirementSpecItem.pm @@ -2,6 +2,8 @@ package SL::DB::RequirementSpecItem; use strict; +use Carp; + use SL::DB::MetaSetup::RequirementSpecItem; use SL::DB::Manager::RequirementSpecItem; use SL::DB::Helper::ActsAsList; @@ -60,7 +62,7 @@ sub _before_save_create_fb_number { $self->requirement_spec->update_attributes($method => $next_number) || return 0; - my $method = 'requirement_spec_' . ($self->parent_id ? 'function_block' : 'section') . '_number_format'; + $method = 'requirement_spec_' . ($self->parent_id ? 'function_block' : 'section') . '_number_format'; my $format = SL::DB::Default->get->$method; $self->fb_number(SL::PrefixedNumber->new(number => $format || 0)->set_to($next_number)); @@ -78,24 +80,28 @@ sub validate { } sub sorted_children { - my ($self) = @_; + my ($self, @args) = @_; + + croak "Not a writer" if @args; return [ sort { $a->position <=> $b->position } @{ $self->children } ]; } -sub get_section { - my ($self) = @_; +sub section { + my ($self, @args) = @_; + croak "Not a writer" if @args; $self = $self->parent while $self->parent_id; return $self; } -sub get_type { - my ($self) = @_; +sub child_type { + my ($self, @args) = @_; + + croak "Not a writer" if @args; - return 'section' if !$self->parent_id; - return $self->parent->parent_id ? 'sub-function-block' : 'function-block'; + return $self->item_type eq 'section' ? 'function-block' : 'sub-function-block'; } 1;