1 package SL::DB::Customer;
5 use SL::DB::MetaSetup::Customer;
6 use SL::DB::Manager::Customer;
7 use SL::DB::Helper::TransNumberGenerator;
11 __PACKAGE__->meta->add_relationship(
13 type => 'one to many',
14 class => 'SL::DB::Shipto',
15 column_map => { id => 'trans_id' },
16 manager_args => { sort_by => 'lower(shipto.shiptoname)' },
17 query_args => [ module => 'CT' ],
20 type => 'one to many',
21 class => 'SL::DB::Contact',
22 column_map => { id => 'cp_cv_id' },
23 manager_args => { sort_by => 'lower(contacts.cp_name)' },
27 class => 'SL::DB::Business',
28 column_map => { business_id => 'id' },
31 type => 'one to many',
32 class => 'SL::DB::CustomVariable',
33 column_map => { id => 'trans_id' },
34 query_args => [ config_id => [ \"(SELECT custom_variable_configs.id FROM custom_variable_configs WHERE custom_variable_configs.module = 'CT')" ] ],
38 __PACKAGE__->meta->make_manager_class;
39 __PACKAGE__->meta->initialize;
41 __PACKAGE__->before_save('_before_save_set_customernumber');
43 sub _before_save_set_customernumber {
46 $self->create_trans_number if $self->customernumber eq '';
53 return join ', ', grep { $_ } $self->street, $self->zipcode, $self->city;