1 package SL::DB::Customer;
5 use SL::DB::MetaSetup::Customer;
6 use SL::DB::Manager::Customer;
7 use SL::DB::Helper::TransNumberGenerator;
8 use SL::DB::Helper::CustomVariables (
15 __PACKAGE__->meta->add_relationship(
17 type => 'one to many',
18 class => 'SL::DB::Shipto',
19 column_map => { id => 'trans_id' },
20 manager_args => { sort_by => 'lower(shipto.shiptoname)' },
21 query_args => [ module => 'CT' ],
24 type => 'one to many',
25 class => 'SL::DB::Contact',
26 column_map => { id => 'cp_cv_id' },
27 manager_args => { sort_by => 'lower(contacts.cp_name)' },
31 __PACKAGE__->meta->initialize;
33 __PACKAGE__->before_save('_before_save_set_customernumber');
35 sub _before_save_set_customernumber {
38 $self->create_trans_number if $self->customernumber eq '';
45 return join ', ', grep { $_ } $self->street, $self->zipcode, $self->city;
48 sub displayable_name {
51 return join ' ', grep $_, $self->customernumber, $self->name;
54 sub is_customer { 1 };