]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/DB/Buchungsgruppe.pm
Typos in Doku
[kivitendo-erp.git] / SL / DB / Buchungsgruppe.pm
index 3504e2a41dbd594c885f73f41ae22612f6ae7b89..9074fb90bfd41ed4a9bbea001b94bbaf3a8c7237 100644 (file)
@@ -21,6 +21,13 @@ sub validate {
 
   my @errors;
   push @errors, $::locale->text('The description is missing.') if !$self->description;
+  if( $self->inventory_accno_id ) {
+    require SL::DB::Chart;
+    my $inventory_accno = SL::DB::Manager::Chart->find_by( id => $self->inventory_accno_id );
+    push(@errors, $::locale->text('Buchungsgruppe #1 needs a valid inventory account', $self->description)) unless $inventory_accno;
+  } else {
+    push @errors, $::locale->text('The Buchungsgruppe needs an inventory account.');
+  };
 
   return @errors;
 }
@@ -73,6 +80,15 @@ sub taxzonecharts {
   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__
 
@@ -111,6 +127,10 @@ Return the chart (an instance of L<SL::DB::Chart>) for the income
 account for the given taxzone (either the DB id or an instance of
 L<SL::DB::TaxZone>).
 
+=item C<orphaned>
+
+Checks whether this Buchungsgruppe is assigned to any parts.
+
 =back
 
 =head1 BUGS