Revision 53ef5f90
Von Tamino Steinert vor 6 Tagen hinzugefügt
SL/DB/Part.pm | ||
---|---|---|
92 | 92 |
class => 'SL::DB::PurchaseBasketItem', |
93 | 93 |
column_map => { id => 'part_id' }, |
94 | 94 |
}, |
95 |
variant_properties => { |
|
96 |
map_class => 'SL::DB::VariantPropertyPart', |
|
97 |
map_from => 'part', |
|
98 |
map_to => 'variant_property', |
|
99 |
type => 'many to many', |
|
100 |
}, |
|
101 |
variant_porperty_values => { |
|
102 |
map_class => 'SL::DB::VariantPropertyValuePart', |
|
103 |
map_from => 'part', |
|
104 |
map_to => 'variant_property_value', |
|
105 |
type => 'many to many', |
|
106 |
}, |
|
107 |
parent_variant => { |
|
108 |
map_class => 'SL::DB::PartParentVariantPartVariant', |
|
109 |
map_from => 'variant', |
|
110 |
map_to => 'parent_variant', |
|
111 |
type => 'many to many', #should be 'many to one' but has no map_class |
|
112 |
}, |
|
113 |
variants => { |
|
114 |
map_class => 'SL::DB::PartParentVariantPartVariant', |
|
115 |
map_from => 'parent_variant', |
|
116 |
map_to => 'variant', |
|
117 |
type => 'many to many', #should be 'one to many' but has no map_class |
|
118 |
} |
|
95 | 119 |
); |
96 | 120 |
|
97 | 121 |
__PACKAGE__->meta->initialize; |
... | ... | |
179 | 203 |
sub is_type { |
180 | 204 |
my $self = shift; |
181 | 205 |
my $type = lc(shift || ''); |
182 |
die 'invalid type' unless $type =~ /^(?:part|service|assembly|assortment)$/; |
|
206 |
die 'invalid type' unless $type =~ /^(?:part|service|assembly|assortment|parent_variant|variant)$/;
|
|
183 | 207 |
|
184 | 208 |
return $self->type eq $type ? 1 : 0; |
185 | 209 |
} |
186 | 210 |
|
187 |
sub is_part { $_[0]->part_type eq 'part' } |
|
188 |
sub is_assembly { $_[0]->part_type eq 'assembly' } |
|
189 |
sub is_service { $_[0]->part_type eq 'service' } |
|
190 |
sub is_assortment { $_[0]->part_type eq 'assortment' } |
|
191 |
|
|
192 |
sub type { |
|
193 |
return $_[0]->part_type; |
|
194 |
# my ($self, $type) = @_; |
|
195 |
# if (@_ > 1) { |
|
196 |
# die 'invalid type' unless $type =~ /^(?:part|service|assembly)$/; |
|
197 |
# $self->assembly( $type eq 'assembly' ? 1 : 0); |
|
198 |
# $self->inventory_accno_id($type ne 'service' ? 1 : undef); |
|
199 |
# } |
|
211 |
sub is_part { $_[0]->part_type eq 'part' } |
|
212 |
sub is_assembly { $_[0]->part_type eq 'assembly' } |
|
213 |
sub is_service { $_[0]->part_type eq 'service' } |
|
214 |
sub is_assortment { $_[0]->part_type eq 'assortment' } |
|
215 |
sub is_parent_varient { $_[0]->part_type eq 'parent_variant' } |
|
216 |
sub is_varient { $_[0]->part_type eq 'variant' } |
|
200 | 217 |
|
201 |
# return 'assembly' if $self->assembly; |
|
202 |
# return 'part' if $self->inventory_accno_id; |
|
203 |
# return 'service'; |
|
204 |
} |
|
218 |
sub type { return $_[0]->part_type; } |
|
205 | 219 |
|
206 | 220 |
sub new_part { |
207 | 221 |
my ($class, %params) = @_; |
... | ... | |
223 | 237 |
$class->new(%params, part_type => 'assortment'); |
224 | 238 |
} |
225 | 239 |
|
240 |
sub new_parent_variant { |
|
241 |
my ($class, %params) = @_; |
|
242 |
$class->new(%params, part_type => 'parent_variant'); |
|
243 |
} |
|
244 |
|
|
245 |
sub new_variant { |
|
246 |
my ($class, %params) = @_; |
|
247 |
$class->new(%params, part_type => 'variant'); |
|
248 |
} |
|
249 |
|
|
226 | 250 |
sub last_modification { |
227 | 251 |
my ($self) = @_; |
228 | 252 |
return $self->mtime // $self->itime; |
Auch abrufbar als: Unified diff
Varianten: SQL-Scripte und ROSE-DB Dateien erstellt