io/select_item um optional part.notes erweitert
[kivitendo-erp.git] / SL / DB / Buchungsgruppe.pm
index d3ddccc..9074fb9 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;
 }
@@ -72,7 +79,7 @@ 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;