kivitendo/SL/DB/PartsGroup.pm @ 2df98929
4fd22b56 | Sven Schöling | # This file has been auto-generated only because it didn't exist.
|
||
# Feel free to modify it at will; it will not be overwritten automatically.
|
||||
f97b0778 | Sven Schöling | package SL::DB::PartsGroup;
|
||
4fd22b56 | Sven Schöling | |||
use strict;
|
||||
f97b0778 | Sven Schöling | use SL::DB::MetaSetup::PartsGroup;
|
||
4ad8ecea | Geoffrey Richardson | use SL::DB::Manager::PartsGroup;
|
||
9c785acd | Geoffrey Richardson | use SL::DB::Helper::ActsAsList;
|
||
4fd22b56 | Sven Schöling | |||
36703a86 | Bernd Bleßmann | __PACKAGE__->meta->add_relationship(
|
||
custom_variable_configs => {
|
||||
type => 'many to many',
|
||||
map_class => 'SL::DB::CustomVariableConfigPartsgroup',
|
||||
},
|
||||
36927d81 | Geoffrey Richardson | parts => {
|
||
type => 'one to many',
|
||||
class => 'SL::DB::Part',
|
||||
column_map => { id => 'partsgroup_id' },
|
||||
},
|
||||
36703a86 | Bernd Bleßmann | );
|
||
2d7e4203 | Sven Schöling | __PACKAGE__->meta->initialize;
|
||
818a31fa | Sven Schöling | sub displayable_name {
|
||
my $self = shift;
|
||||
return join ' ', grep $_, $self->id, $self->partsgroup;
|
||||
}
|
||||
9c785acd | Geoffrey Richardson | sub validate {
|
||
my ($self) = @_;
|
||||
require SL::DB::Customer;
|
||||
my @errors;
|
||||
push @errors, $::locale->text('The description is missing.') if $self->id and !$self->partsgroup;
|
||||
return @errors;
|
||||
}
|
||||
sub orphaned {
|
||||
my ($self) = @_;
|
||||
die 'not an accessor' if @_ > 1;
|
||||
return 1 unless $self->id;
|
||||
my @relations = qw(
|
||||
SL::DB::Part
|
||||
SL::DB::CustomVariableConfigPartsgroup
|
||||
);
|
||||
for my $class (@relations) {
|
||||
eval "require $class";
|
||||
return 0 if $class->_get_manager_class->get_all_count(query => [ partsgroup_id => $self->id ]);
|
||||
}
|
||||
4d823692 | Bernd Bleßmann | eval "require SL::DB::PriceRuleItem";
|
||
return 0 if SL::DB::Manager::PriceRuleItem->get_all_count(query => [ type => 'partsgroup', value_int => $self->id ]);
|
||||
9c785acd | Geoffrey Richardson | return 1;
|
||
}
|
||||
4fd22b56 | Sven Schöling | 1;
|