From: Sven Schöling Date: Fri, 12 Sep 2014 15:59:32 +0000 (+0200) Subject: PriceRule: Nicht Fehler werfen wenn _garkeine_ Regel zutrifft X-Git-Tag: release-3.2.0beta~142 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3a45c5ca624f39ebbab4fffcbc7ccb1c96e0f3e0;p=kivitendo-erp.git PriceRule: Nicht Fehler werfen wenn _garkeine_ Regel zutrifft --- 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 {