Revision dfdaa70d
Von Tamino Steinert vor etwa 1 Jahr hinzugefügt
| SL/DB/Part.pm | ||
|---|---|---|
|  | ||
| use Carp;
 | ||
| use List::MoreUtils qw(any uniq pairwise);
 | ||
| use List::Util qw(sum max);
 | ||
| use List::Util qw(sum max first);
 | ||
| use Rose::DB::Object::Helpers qw(as_tree);
 | ||
|  | ||
| use SL::Locale::String qw(t8);
 | ||
| ... | ... | |
|     map_from  => 'part',
 | ||
|     map_to    => 'variant_property',
 | ||
|     type      => 'many to many',
 | ||
|     manager_args => { sort_by => 'sortkey ASC' }
 | ||
|   },
 | ||
|   variant_property_values => {
 | ||
|     map_class => 'SL::DB::VariantPropertyValuePart',
 | ||
| ... | ... | |
|     map_to    => 'variant_property_value',
 | ||
|     type      => 'many to many',
 | ||
|   },
 | ||
|   parent_variant => {
 | ||
|   parent_variants => { # access through parent_variant
 | ||
|     map_class => 'SL::DB::PartParentVariantPartVariant',
 | ||
|     map_from  => 'variant',
 | ||
|     map_to    => 'parent_variant',
 | ||
| ... | ... | |
|   my ($self) = @_;
 | ||
|   if ($self->is_variant) {
 | ||
|     my @property_value_ids = sort map {$_->id} $self->variant_property_values;
 | ||
|     my ($parent_variant) = $self->parent_variant;
 | ||
|     my $parent_variant = $self->parent_variant;
 | ||
|     my $other_variants = $parent_variant->variants;
 | ||
|     foreach my $variant (@$other_variants) {
 | ||
|       next if $variant->id == $self->id;
 | ||
| ... | ... | |
|   shift->buchungsgruppen(@_);
 | ||
| }
 | ||
|  | ||
| sub parent_variant {
 | ||
|   my ($parent_variant) = shift->parent_variants(@_);
 | ||
|   return $parent_variant;
 | ||
| }
 | ||
|  | ||
| sub get_variant_property_value_by_unique_name {
 | ||
|   my ($self, $variant_property_unique_name) = @_;
 | ||
|  | ||
| ... | ... | |
|   return unless $self->is_variant;
 | ||
|   return "[" .join("|",
 | ||
|     map {$_->variant_property->abbreviation . ":" . $_->abbreviation}
 | ||
|     $self->variant_property_values)  . "]";
 | ||
|     sort {$a->variant_property->sortkey <=> $b->variant_property->sortkey}
 | ||
|     $self->variant_property_values
 | ||
|   )  . "]";
 | ||
| }
 | ||
|  | ||
| sub variant_value {
 | ||
| ... | ... | |
|   die "only callable on parts of type parent_variant"     unless $self->is_variant;
 | ||
|   die "only callable with SL::DB::VariantProperty object" unless ref $variant_property eq 'SL::DB::VariantProperty';
 | ||
|  | ||
|   my %property_id_to_values =
 | ||
|     map {$_->variant_property_id => $_}
 | ||
|   my $property_value =
 | ||
|     first {$variant_property->id == $_->variant_property_id}
 | ||
|     @{$self->variant_property_values};
 | ||
|  | ||
|   my $property_value = $property_id_to_values{$variant_property->id};
 | ||
|  | ||
|   return $property_value && $property_value->displayable_name();
 | ||
|   return $property_value;
 | ||
| }
 | ||
|  | ||
| sub init_onhandqty {
 | ||
Auch abrufbar als: Unified diff
Varianten: Schnellbearbeitung von Varianten (EAN, Auf Lager)