projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Paginating: Visibility auch berechnen...
[kivitendo-erp.git]
/
SL
/
DB
/
Customer.pm
diff --git
a/SL/DB/Customer.pm
b/SL/DB/Customer.pm
index
27683b3
..
f9f8901
100644
(file)
--- a/
SL/DB/Customer.pm
+++ b/
SL/DB/Customer.pm
@@
-3,6
+3,12
@@
package SL::DB::Customer;
use strict;
use SL::DB::MetaSetup::Customer;
use strict;
use SL::DB::MetaSetup::Customer;
+use SL::DB::Manager::Customer;
+use SL::DB::Helper::TransNumberGenerator;
+use SL::DB::Helper::CustomVariables (
+ module => 'CT',
+ cvars_alias => 1,
+);
use SL::DB::VC;
use SL::DB::VC;
@@
-12,7
+18,13
@@
__PACKAGE__->meta->add_relationship(
class => 'SL::DB::Shipto',
column_map => { id => 'trans_id' },
manager_args => { sort_by => 'lower(shipto.shiptoname)' },
class => 'SL::DB::Shipto',
column_map => { id => 'trans_id' },
manager_args => { sort_by => 'lower(shipto.shiptoname)' },
- query_args => [ 'module' => 'CT' ],
+ query_args => [ module => 'CT' ],
+ },
+ contacts => {
+ type => 'one to many',
+ class => 'SL::DB::Contact',
+ column_map => { id => 'cp_cv_id' },
+ manager_args => { sort_by => 'lower(contacts.cp_name)' },
},
business => {
type => 'one to one',
},
business => {
type => 'one to one',
@@
-21,13
+33,27
@@
__PACKAGE__->meta->add_relationship(
},
);
},
);
-__PACKAGE__->meta->make_manager_class;
__PACKAGE__->meta->initialize;
__PACKAGE__->meta->initialize;
+__PACKAGE__->before_save('_before_save_set_customernumber');
+
+sub _before_save_set_customernumber {
+ my ($self) = @_;
+
+ $self->create_trans_number if $self->customernumber eq '';
+ return 1;
+}
+
sub short_address {
my ($self) = @_;
return join ', ', grep { $_ } $self->street, $self->zipcode, $self->city;
}
sub short_address {
my ($self) = @_;
return join ', ', grep { $_ } $self->street, $self->zipcode, $self->city;
}
+sub displayable_name {
+ my $self = shift;
+
+ return join ' ', grep $_, $self->customernumber, $self->name;
+}
+
1;
1;