1 package SL::DB::Vendor;
 
   5 use SL::DB::MetaSetup::Vendor;
 
   6 use SL::DB::Helper::TransNumberGenerator;
 
  10 __PACKAGE__->meta->add_relationship(
 
  12     type         => 'one to many',
 
  13     class        => 'SL::DB::Shipto',
 
  14     column_map   => { id      => 'trans_id' },
 
  15     manager_args => { sort_by => 'lower(shipto.shiptoname)' },
 
  16     query_args   => [ module  => 'CT' ],
 
  19     type         => 'one to many',
 
  20     class        => 'SL::DB::Contact',
 
  21     column_map   => { id      => 'cp_cv_id' },
 
  22     manager_args => { sort_by => 'lower(contacts.cp_name)' },
 
  26     class        => 'SL::DB::Business',
 
  27     column_map   => { business_id => 'id' },
 
  30     type           => 'one to many',
 
  31     class          => 'SL::DB::CustomVariable',
 
  32     column_map     => { id => 'trans_id' },
 
  33     query_args     => [ config_id => [ \"(SELECT custom_variable_configs.id FROM custom_variable_configs WHERE custom_variable_configs.module = 'CT')" ] ],
 
  37 __PACKAGE__->meta->make_manager_class;
 
  38 __PACKAGE__->meta->initialize;
 
  40 __PACKAGE__->before_save('_before_save_set_vendornumber');
 
  42 sub _before_save_set_vendornumber {
 
  45   $self->create_trans_number if $self->vendornumber eq '';