1 package SL::DB::Customer;
5 use Rose::DB::Object::Helpers qw(as_tree);
7 use SL::DB::MetaSetup::Customer;
8 use SL::DB::Manager::Customer;
9 use SL::DB::Helper::TransNumberGenerator;
10 use SL::DB::Helper::CustomVariables (
17 __PACKAGE__->meta->add_relationship(
19 type => 'one to many',
20 class => 'SL::DB::Shipto',
21 column_map => { id => 'trans_id' },
22 manager_args => { sort_by => 'lower(shipto.shiptoname)' },
23 query_args => [ module => 'CT' ],
26 type => 'one to many',
27 class => 'SL::DB::Contact',
28 column_map => { id => 'cp_cv_id' },
29 manager_args => { sort_by => 'lower(contacts.cp_name)' },
33 __PACKAGE__->meta->initialize;
35 __PACKAGE__->before_save('_before_save_set_customernumber');
37 sub _before_save_set_customernumber {
40 $self->create_trans_number if !defined $self->customernumber || $self->customernumber eq '';
47 return join ', ', grep { $_ } $self->street, $self->zipcode, $self->city;
50 sub displayable_name {
53 return join ' ', grep $_, $self->customernumber, $self->name;
56 sub is_customer { 1 };
58 sub payment_terms { goto &payment }