Revision 0409db7c
Von Sven Schöling vor etwa 10 Jahren hinzugefügt
SL/PriceSource/Pricegroup.pm | ||
---|---|---|
5 | 5 |
|
6 | 6 |
use SL::PriceSource::Price; |
7 | 7 |
use SL::Locale::String; |
8 |
use List::UtilsBy qw(min_by); |
|
9 |
use List::Util qw(first); |
|
8 | 10 |
|
9 | 11 |
sub name { 'pricegroup' } |
10 | 12 |
|
... | ... | |
36 | 38 |
return $self->make_price($price); |
37 | 39 |
} |
38 | 40 |
|
41 |
sub best_price { |
|
42 |
my ($self, %params) = @_; |
|
43 |
|
|
44 |
my @prices = $self->availabe_prices; |
|
45 |
my $customer = $self->record->customer; |
|
46 |
my $min_price = min_by { $_->price } @prices; |
|
47 |
|
|
48 |
return $min_price if !$customer || !$customer->cv_klass; |
|
49 |
|
|
50 |
my $best_price = first { $_->spec == $customer->cv_class } @prices; |
|
51 |
|
|
52 |
return $best_price || $min_price; |
|
53 |
} |
|
54 |
|
|
39 | 55 |
sub make_price { |
40 | 56 |
my ($self, $price_obj) = @_; |
41 | 57 |
|
42 | 58 |
SL::PriceSource::Price->new( |
43 | 59 |
price => $price_obj->price, |
44 |
source => 'pricegroup/' . $price_obj->id,
|
|
60 |
spec => $price_obj->id,
|
|
45 | 61 |
description => $price_obj->pricegroup->pricegroup, |
46 | 62 |
price_source => $self, |
47 | 63 |
) |
Auch abrufbar als: Unified diff
PriceSource: Mehr Informationen an Preise übergeben
record + record_item verfügbar gemacht
best_price für pricegroups
Price: spec/source entzerrt