Merge branch 'master' of github.com:kivitendo/kivitendo-erp
[kivitendo-erp.git] / SL / DB / Buchungsgruppe.pm
index 1b5bdad..eb467c5 100644 (file)
@@ -25,18 +25,6 @@ sub validate {
   return @errors;
 }
 
-sub inventory_accno {
-  my ($self) = @_;
-  require SL::DB::Manager::Chart;
-  return SL::DB::Manager::Chart->find_by(id => $self->inventory_accno_id) ? SL::DB::Manager::Chart->find_by(id => $self->inventory_accno_id)->accno() : undef;
-}
-
-sub inventory_accno_description {
-  my ($self) = @_;
-  require SL::DB::Manager::Chart;
-  return SL::DB::Manager::Chart->find_by(id => $self->inventory_accno_id) ? SL::DB::Manager::Chart->find_by(id => $self->inventory_accno_id)->description() : undef;
-}
-
 sub income_accno_id {
   my ($self, $taxzone) = @_;
 
@@ -85,6 +73,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__
 
@@ -123,6 +120,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