X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FBuchungsgruppe.pm;h=cad8bb628605d0a6ad2403d0872ff4fc83984b29;hb=68f05425f0189affa3a9e75d3d7e43d2405dd21f;hp=d3ddcccb14b55843dce420a907ddd7660dac755a;hpb=d3801bc92648bd7284b543162299fa31a0a0eb77;p=kivitendo-erp.git diff --git a/SL/DB/Buchungsgruppe.pm b/SL/DB/Buchungsgruppe.pm index d3ddcccb1..cad8bb628 100644 --- a/SL/DB/Buchungsgruppe.pm +++ b/SL/DB/Buchungsgruppe.pm @@ -6,21 +6,22 @@ use SL::DB::MetaSetup::Buchungsgruppe; use SL::DB::Manager::Buchungsgruppe; use SL::DB::Helper::ActsAsList; -__PACKAGE__->meta->add_relationship( - inventory_account => { - type => 'many to one', - class => 'SL::DB::Chart', - column_map => { inventory_accno_id => 'id' }, - }, -); - __PACKAGE__->meta->initialize; +sub inventory_account { goto &inventory_accno; } + sub validate { my ($self) = @_; 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('Booking group #1 needs a valid inventory account', $self->description)) unless $inventory_accno; + } else { + push @errors, $::locale->text('The booking group needs an inventory account.'); + }; return @errors; } @@ -72,7 +73,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;