Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9f666261

Von Sven Schöling vor mehr als 9 Jahren hinzugefügt

  • ID 9f66626118ec0cdcee8082b3d81f288bbfa23648
  • Vorgänger 226002b0
  • Nachfolger 30590722

PriceSource: Priorität auf Preisquellenebene verstehen und umsetzen.

Priorität kann jetzt von den einzelnen Preisquellen durchgereicht werden

Unterschiede anzeigen:

SL/PriceSource.pm
40 40
}
41 41

  
42 42
sub best_price {
43
  min_by { $_->price } grep { $_->price > 0 } grep { $_ } map { $_->best_price } $_[0]->all_price_sources;
43
  min_by { $_->price } max_by { $_->priority } grep { $_->price > 0 } grep { $_ } map { $_->best_price } $_[0]->all_price_sources;
44 44
}
45 45

  
46 46
sub best_discount {
47
  max_by { $_->discount } grep { $_->discount } grep { $_ } map { $_->best_discount } $_[0]->all_price_sources;
47
  max_by { $_->discount } max_by { $_->priority } grep { $_->discount } grep { $_ } map { $_->best_discount } $_[0]->all_price_sources;
48 48
}
49 49

  
50 50
sub empty_price {
SL/PriceSource/Discount.pm
5 5
use parent 'SL::DB::Object';
6 6
use Rose::Object::MakeMethods::Generic (
7 7
  scalar => [ qw(discount description spec price_source invalid missing) ],
8
  'scalar --get_set_init' => [ qw(priority) ],
8 9
);
9 10

  
10 11
require SL::DB::Helper::Attr;
......
38 39
  "source: @{[ $_[0]->source ]}, discount: @{[ $_[0]->discount ]}, description: @{[ $_[0]->description ]}"
39 40
}
40 41

  
42
sub init_priority {
43
  3
44
}
45

  
41 46
1;
42 47

  
43 48
__END__
......
109 114

  
110 115
A ref to the creating algorithm.
111 116

  
117
=item C<priority>
118

  
119
OPTIONAL. Discounts may supply a numerical priority. Higher will trump over lower, even when
120
supplying lower discounts. Defaults to 3 (as in middle of 1-5).
121

  
112 122
=item C<missing>
113 123

  
114 124
OPTIONAL. Both indicator and localized message that the discount with this spec
SL/PriceSource/Price.pm
5 5
use parent 'SL::DB::Object';
6 6
use Rose::Object::MakeMethods::Generic (
7 7
  scalar => [ qw(price description spec price_source invalid missing) ],
8
  'scalar --get_set_init' => [ qw(priority) ],
8 9
);
9 10

  
10 11
require SL::DB::Helper::Attr;
......
38 39
  "source: @{[ $_[0]->source ]}, price: @{[ $_[0]->price ]}, description: @{[ $_[0]->description ]}"
39 40
}
40 41

  
42
sub init_priority {
43
  3
44
}
45

  
41 46
1;
42 47

  
43 48
__END__
......
109 114

  
110 115
A ref to the creating algorithm.
111 116

  
117
=item C<priority>
118

  
119
OPTIONAL. Prices may supply a numerical priority. Higher will trump over lower, even when
120
supplying higher prices. Defaults to 3 (as in middle of 1-5).
121

  
112 122
=item C<missing>
113 123

  
114 124
OPTIONAL. Both indicator and localized message that the price with this spec
SL/PriceSource/PriceRules.pm
92 92
    price        => $self->price_for_rule($rule),
93 93
    spec         => $rule->id,
94 94
    description  => $rule->name,
95
    priority     => $rule->priority,
95 96
    price_source => $self,
96 97
    (invalid      => t8('This Price Rule is no longer valid'))x!!$rule->obsolete,
97 98
  )
......
104 105
    discount     => $rule->discount / 100,
105 106
    spec         => $rule->id,
106 107
    description  => $rule->name,
108
    priority     => $rule->priority,
107 109
    price_source => $self,
108 110
    (invalid      => t8('This Price Rule is no longer valid'))x!!$rule->obsolete,
109 111
  )

Auch abrufbar als: Unified diff