X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=SL%2FDB%2FBuchungsgruppe.pm;h=addbe33ad36bf95f75f4b9bfff8aead7f0af2348;hb=0c09beb40eea289ceebb36aa53b447051fb82857;hp=eb467c541b5791ed5aca4c235fd52b0a16d09e2a;hpb=2f6a11fb5314d652152e0514bf5e5bf2735dc8fe;p=kivitendo-erp.git diff --git a/SL/DB/Buchungsgruppe.pm b/SL/DB/Buchungsgruppe.pm index eb467c541..addbe33ad 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('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; }