Pflichtenhefte: zusätzliche Artikel zuweisen und bearbeiten können
[kivitendo-erp.git] / SL / DB / RequirementSpec.pm
index e5dae7e..2354440 100644 (file)
@@ -43,6 +43,11 @@ __PACKAGE__->meta->add_relationship(
     class          => 'SL::DB::RequirementSpecOrder',
     column_map     => { id => 'requirement_spec_id' },
   },
+  parts            => {
+    type           => 'one to many',
+    class          => 'SL::DB::RequirementSpecPart',
+    column_map     => { id => 'requirement_spec_id' },
+  },
 );
 
 __PACKAGE__->meta->initialize;
@@ -119,6 +124,14 @@ sub versioned_copies_sorted {
   return \@copies;
 }
 
+sub parts_sorted {
+  my ($self, @rest) = @_;
+
+  croak "This sub is not a writer" if @rest;
+
+  return [ sort { $a->position <=> $b->position } @{ $self->parts } ];
+}
+
 sub create_copy {
   my ($self, %params) = @_;
 
@@ -519,6 +532,11 @@ column in ascending order. If the C<output_position> parameter is
 given then only the text blocks belonging to that C<output_position>
 are returned.
 
+=item C<parts_sorted>
+
+Returns an array reference of additional parts sorted by their
+positional column in ascending order.
+
 =item C<validate>
 
 Validate values before saving. Returns list or human-readable error