From 3a45c5ca624f39ebbab4fffcbc7ccb1c96e0f3e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 12 Sep 2014 17:59:32 +0200 Subject: [PATCH] PriceRule: Nicht Fehler werfen wenn _garkeine_ Regel zutrifft --- SL/PriceSource/PriceRules.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/SL/PriceSource/PriceRules.pm b/SL/PriceSource/PriceRules.pm index 1fee03200..514cadb4e 100644 --- a/SL/PriceSource/PriceRules.pm +++ b/SL/PriceSource/PriceRules.pm @@ -36,7 +36,14 @@ sub price_from_source { sub best_price { my ($self) = @_; - $self->make_price_from_rule( min_by { $self->price_for_rule($_) } max_by { $_->priority } @{ $self->available_rules }); + my $rules = $self->available_rules; + + return unless @$rules; + + my @max_prio = max_by { $_->priority } @$rules; + my $min_price = min_by { $self->price_for_rule($_) } @max_prio; + + $self->make_price_from_rule($min_price); } sub price_for_rule { -- 2.20.1