Revision 53d15b75
Von Kivitendo Admin vor etwa 8 Jahren hinzugefügt
SL/DB/Part.pm | ||
---|---|---|
58 | 58 |
return 1; |
59 | 59 |
} |
60 | 60 |
|
61 |
sub validate { |
|
62 |
my ($self) = @_; |
|
63 |
|
|
64 |
my @errors; |
|
65 |
push @errors, $::locale->text('The partnumber is missing.') unless $self->partnumber; |
|
66 |
push @errors, $::locale->text('The unit is missing.') unless $self->unit; |
|
67 |
push @errors, $::locale->text('The buchungsgruppe is missing.') unless $self->buchungsgruppen_id or $self->buchungsgruppe; |
|
68 |
|
|
69 |
unless ( $self->id ) { |
|
70 |
push @errors, $::locale->text('The partnumber already exists.') if SL::DB::Manager::Part->get_all_count(where => [ partnumber => $self->partnumber ]); |
|
71 |
}; |
|
72 |
|
|
73 |
if ($self->is_assortment && scalar @{$self->assortment_items} == 0) { |
|
74 |
push @errors, $::locale->text('The assortment doesn\'t have any items.'); |
|
75 |
} |
|
76 |
|
|
77 |
if ($self->is_assembly && scalar @{$self->assemblies} == 0) { |
|
78 |
push @errors, $::locale->text('The assembly doesn\'t have any items.'); |
|
79 |
} |
|
80 |
|
|
81 |
return @errors; |
|
82 |
} |
|
83 |
|
|
61 | 84 |
sub is_type { |
62 | 85 |
my $self = shift; |
63 | 86 |
my $type = lc(shift || ''); |
Auch abrufbar als: Unified diff
SL::DB::Part - neue Methode validate