1 package SL::DB::Vendor;
5 use SL::DB::MetaSetup::Vendor;
6 use SL::DB::Helper::TransNumberGenerator;
7 use SL::DB::Helper::CustomVariables (
14 __PACKAGE__->meta->add_relationship(
16 type => 'one to many',
17 class => 'SL::DB::Shipto',
18 column_map => { id => 'trans_id' },
19 manager_args => { sort_by => 'lower(shipto.shiptoname)' },
20 query_args => [ module => 'CT' ],
23 type => 'one to many',
24 class => 'SL::DB::Contact',
25 column_map => { id => 'cp_cv_id' },
26 manager_args => { sort_by => 'lower(contacts.cp_name)' },
30 class => 'SL::DB::Business',
31 column_map => { business_id => 'id' },
34 type => 'one to many',
35 class => 'SL::DB::CustomVariable',
36 column_map => { id => 'trans_id' },
37 query_args => [ config_id => [ \"(SELECT custom_variable_configs.id FROM custom_variable_configs WHERE custom_variable_configs.module = 'CT')" ] ],
41 __PACKAGE__->meta->make_manager_class;
42 __PACKAGE__->meta->initialize;
44 __PACKAGE__->before_save('_before_save_set_vendornumber');
46 sub _before_save_set_vendornumber {
49 $self->create_trans_number if $self->vendornumber eq '';