Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision c5d1e2ed

Von Bernd Bleßmann vor 28 Tagen hinzugefügt

  • ID c5d1e2ed5f0877bc6fea170553fc9dfd6553ae0a
  • Vorgänger 7dd9c5f7
  • Nachfolger 1758316c

S:D:StockCounting/Item: Methoden zum Validieren

Unterschiede anzeigen:

SL/DB/StockCountingItem.pm
5 5

  
6 6
use strict;
7 7

  
8
use List::Util qw(none);
9

  
8 10
use SL::DB::MetaSetup::StockCountingItem;
9 11
use SL::DB::Manager::StockCountingItem;
10 12

  
13
use SL::Locale::String qw(t8);
14

  
11 15
__PACKAGE__->meta->initialize;
12 16

  
17
sub validate {
18
  my ($self) = @_;
19

  
20
  my @errors;
21

  
22
  push @errors, t8('A Stock Counting must be set.') if !$self->counting_id;
23
  push @errors, t8('A part must be set.')           if !$self->part_id;
24
  push @errors, t8('A bin must be set.')            if !$self->bin_id;
25

  
26
  # If part in counting is given then it must match the part of the item to count.
27
  if ($self->counting->part_id && $self->part_id != $self->counting->part_id) {
28
    push @errors, t8('The part must match the part given in the counting.');
29
  }
30

  
31
  # If partsgroup in counting is given then the part of the item to count must belong to the partsgroup.
32
  if ($self->counting->partsgroup_id && $self->part->partsgroup_id != $self->counting->partsgroup_id) {
33
    push @errors, t8('The part must belong to the partsgroup given in the counting.');
34
  }
35

  
36
  # If vendor in counting is given then the vendor must be a make of the part of the item to count.
37
  if ($self->counting->vendor_id && none { $_->make == $self->counting->vendor_id } @{$self->part->makemodels}) {
38
    push @errors, t8('The vendor given in the counting must be a vendor of the part.');
39
  }
40

  
41
  return @errors;
42
}
43

  
13 44
1;

Auch abrufbar als: Unified diff