afca1900fb461acf08055d7d52cc7d971d10d5b2
[kivitendo-erp.git] / SL / DB / Department.pm
1 package SL::DB::Department;
2
3 use strict;
4
5 use SL::DB::MetaSetup::Department;
6 use SL::DB::Manager::Department;
7
8 use SL::DB::DptTrans;
9
10 __PACKAGE__->meta->initialize;
11
12 sub validate {
13   my ($self) = @_;
14
15   my @errors;
16   push @errors, $::locale->text('The description is missing.') if !$self->description;
17
18   return @errors;
19 }
20
21 sub is_used {
22   my ($self) = @_;
23
24   return undef if !$self->id;
25   my $is_used = SL::DB::Manager::DptTrans->find_by(department_id => $self->id);
26   return !!$is_used;
27 }
28
29 1;