Merge branch 'b-3.6.1' of ../kivitendo-erp_20220811
[kivitendo-erp.git] / SL / DB / PartClassification.pm
1
2 package SL::DB::PartClassification;
3
4 use strict;
5
6 use SL::DB::MetaSetup::PartClassification;
7 use SL::DB::Manager::PartClassification;
8
9 __PACKAGE__->meta->initialize;
10 __PACKAGE__->before_delete('can_be_deleted');
11
12 # check if the description and abbreviation is present
13 #
14 sub validate {
15   my ($self) = @_;
16
17   my @errors;
18   push @errors, $::locale->text('The description is missing.')  if !$self->description;
19   push @errors, $::locale->text('The abbreviation is missing.') if !$self->abbreviation;
20
21   return @errors;
22 }
23
24 sub can_be_deleted {
25   my ($self) = @_;
26
27   # The first five part classifications must not be deleted.
28   return defined($self->id) && ($self->id >= 5);
29 }
30
31 1;
32
33 __END__
34
35 =encoding utf-8
36
37 =head1 NAME
38
39 SL::DB::PartClassification
40
41 =head1 SYNOPSIS
42
43 Additional to the article types "part", "assembly", "service" and "assortement"
44 the parts classification specifies other ortogonal attributes
45
46 =head1 DESCRIPTION
47
48 The primary attributes are the rule
49 of the article as "used_for_sales" or "used_for_purchase".
50
51 Another attribute is "report_separate". This attribute may be used for some additional costs like
52 transport, packaging. These article are reported separate in the list of an invoice if
53 the print template is using the variables <%separate_XXX_subtotal%>  and XXX is the shortcut of the parts classification.
54 The variables <%non_separate_subtotal%> has the sum of all other parts of an invoice.
55 (See also LaTeX Documentation).
56
57 Additional other attributes may follow
58
59 To see this attributes in a short way there are shortcuts of one (or two characters, if needed for compare )
60 which may be translated in the specified language
61
62 The type of the article is also as shortcut available, so this combined type and classification shortcut
63 is used short as "Type"
64
65 English type shortcuts are 'P','A','S'
66 German  type shortcuts are 'W','E','D'
67 The can set in the language-files
68
69 To get the localized abbreviations you can use L<SL::Presenter::Part> .
70
71 =head1 METHODS
72
73 =head2 validate
74
75  $self->validate();
76
77 check if the description and abbreviation is present
78
79
80 =head1 AUTHOR
81
82 Martin Helmling E<lt>martin.helmling@opendynamic.deE<gt>
83
84
85 =cut