X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/d3801bc92648bd7284b543162299fa31a0a0eb77..53593baa211863fbf66540cf1bcc36c8fb37257f:/SL/DB/Buchungsgruppe.pm 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;