X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FBuchungsgruppe.pm;h=addbe33ad36bf95f75f4b9bfff8aead7f0af2348;hb=d05e1443a5514d24bf0cfc6833c6f06d2adf6df7;hp=d3ddcccb14b55843dce420a907ddd7660dac755a;hpb=d3801bc92648bd7284b543162299fa31a0a0eb77;p=kivitendo-erp.git diff --git a/SL/DB/Buchungsgruppe.pm b/SL/DB/Buchungsgruppe.pm index d3ddcccb1..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; } @@ -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;