1 package SL::DB::Vendor;
5 use Rose::DB::Object::Helpers qw(as_tree);
7 use SL::DB::MetaSetup::Vendor;
8 use SL::DB::Manager::Vendor;
9 use SL::DB::Helper::IBANValidation;
10 use SL::DB::Helper::TransNumberGenerator;
11 use SL::DB::Helper::CustomVariables (
18 __PACKAGE__->meta->add_relationship(
20 type => 'one to many',
21 class => 'SL::DB::Shipto',
22 column_map => { id => 'trans_id' },
23 manager_args => { sort_by => 'lower(shipto.shiptoname)' },
24 query_args => [ module => 'CT' ],
27 type => 'one to many',
28 class => 'SL::DB::Contact',
29 column_map => { id => 'cp_cv_id' },
30 manager_args => { sort_by => 'lower(contacts.cp_name)' },
34 __PACKAGE__->meta->initialize;
36 __PACKAGE__->before_save('_before_save_set_vendornumber');
38 sub _before_save_set_vendornumber {
41 $self->create_trans_number if !defined $self->vendornumber || $self->vendornumber eq '';
49 push @errors, $::locale->text('The vendor name is missing.') if !$self->name;
50 push @errors, $self->validate_ibans;
55 sub displayable_name {
58 return join ' ', grep $_, $self->vendornumber, $self->name;
61 sub is_customer { 0 };
63 sub payment_terms { goto &payment }
64 sub number { goto &vendornumber }