Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 361a3f88

Von Tamino Steinert vor 6 Tagen hinzugefügt

  • ID 361a3f88c2234b4678c0d644032677fb61ba15bb
  • Vorgänger 930fcc0f
  • Nachfolger 8e6ec576

Varianten: Schnellbearbeitung von Varianten (EAN, Auf Lager)

Unterschiede anzeigen:

SL/DB/Part.pm
4 4

  
5 5
use Carp;
6 6
use List::MoreUtils qw(any uniq pairwise);
7
use List::Util qw(sum max);
7
use List::Util qw(sum max first);
8 8
use Rose::DB::Object::Helpers qw(as_tree);
9 9

  
10 10
use SL::Locale::String qw(t8);
......
100 100
    map_from  => 'part',
101 101
    map_to    => 'variant_property',
102 102
    type      => 'many to many',
103
    manager_args => { sort_by => 'sortkey ASC' }
103 104
  },
104 105
  variant_property_values => {
105 106
    map_class => 'SL::DB::VariantPropertyValuePart',
......
107 108
    map_to    => 'variant_property_value',
108 109
    type      => 'many to many',
109 110
  },
110
  parent_variant => {
111
  parent_variants => { # access through parent_variant
111 112
    map_class => 'SL::DB::PartParentVariantPartVariant',
112 113
    map_from  => 'variant',
113 114
    map_to    => 'parent_variant',
......
156 157
  my ($self) = @_;
157 158
  if ($self->is_variant) {
158 159
    my @property_value_ids = sort map {$_->id} $self->variant_property_values;
159
    my ($parent_variant) = $self->parent_variant;
160
    my $parent_variant = $self->parent_variant;
160 161
    my $other_variants = $parent_variant->variants;
161 162
    foreach my $variant (@$other_variants) {
162 163
      next if $variant->id == $self->id;
......
338 339
  shift->buchungsgruppen(@_);
339 340
}
340 341

  
342
sub parent_variant {
343
  my ($parent_variant) = shift->parent_variants(@_);
344
  return $parent_variant;
345
}
346

  
341 347
sub get_variant_property_value_by_unique_name {
342 348
  my ($self, $variant_property_unique_name) = @_;
343 349

  
......
687 693
  return unless $self->is_variant;
688 694
  return "[" .join("|",
689 695
    map {$_->variant_property->abbreviation . ":" . $_->abbreviation}
690
    $self->variant_property_values)  . "]";
696
    sort {$a->variant_property->sortkey <=> $b->variant_property->sortkey}
697
    $self->variant_property_values
698
  )  . "]";
691 699
}
692 700

  
693 701
sub variant_value {
......
695 703
  die "only callable on parts of type parent_variant"     unless $self->is_variant;
696 704
  die "only callable with SL::DB::VariantProperty object" unless ref $variant_property eq 'SL::DB::VariantProperty';
697 705

  
698
  my %property_id_to_values =
699
    map {$_->variant_property_id => $_}
706
  my $property_value =
707
    first {$variant_property->id == $_->variant_property_id}
700 708
    @{$self->variant_property_values};
701 709

  
702
  my $property_value = $property_id_to_values{$variant_property->id};
703

  
704
  return $property_value && $property_value->displayable_name();
710
  return $property_value;
705 711
}
706 712

  
707 713
sub init_onhandqty {

Auch abrufbar als: Unified diff