7 use SL::DB::MetaSetup::Note;
 
  10 __PACKAGE__->meta->add_relationships(
 
  13     class        => 'SL::DB::FollowUp',
 
  14     column_map   => { id => 'note_id' },
 
  18 __PACKAGE__->meta->initialize;
 
  20 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
 
  21 __PACKAGE__->meta->make_manager_class;
 
  26   croak "Method is not a setter" if @_;
 
  28   return undef if !$self->trans_id || !$self->trans_module;
 
  30   if ($self->trans_module eq 'fu') {
 
  31     require SL::DB::FollowUp;
 
  32     return SL::DB::Manager::FollowUp->find_by(id => $self->trans_id);
 
  35   if ($self->trans_module eq 'ct') {
 
  36     require SL::DB::Customer;
 
  37     require SL::DB::Vendor;
 
  38     return SL::DB::Manager::Customer->find_by(id => $self->trans_id)
 
  39         || SL::DB::Manager::Vendor  ->find_by(id => $self->trans_id);
 
  62 A note object is always attached to another database entity. Which one
 
  63 is determined by the columns C<trans_module> and C<trans_id>. This
 
  64 function looks at both, retrieves the corresponding object from the
 
  65 database and returns it.
 
  67 Currently the following three types are supported:
 
  71 =item * C<SL::DB::FollowUp> for C<trans_module == 'fu'>
 
  73 =item * C<SL::DB::Customer> or C<SL::DB::Vendor> for C<trans_module ==
 
  74 'ct'> (which class is used depends on the value of C<trans_id>;
 
  75 customers are looked up first)
 
  79 The method returns C<undef> in three cases: if no C<trans_id> or no
 
  80 C<trans_module> has been assigned yet; if C<trans_module> is unknown;
 
  81 if the referenced object doesn't exist.
 
  83 This method is a getter only, not a setter.
 
  93 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>