Revision a4415997
Von Bernd Bleßmann vor mehr als 9 Jahren hinzugefügt
SL/PriceSource/PriceRules.pm | ||
---|---|---|
45 | 45 |
my ($self, $source, $spec) = @_; |
46 | 46 |
|
47 | 47 |
my $rule = SL::DB::Manager::PriceRule->find_by(id => $spec); |
48 |
|
|
49 |
return SL::PriceSource::Discount->new( |
|
50 |
price_source => $self, |
|
51 |
missing => t8('The price rule for this price does not exist anymore'), |
|
52 |
) if !$rule; |
|
53 |
|
|
48 | 54 |
if ($rule->price_type != SL::DB::Manager::PriceRule::PRICE_DISCOUNT()) { |
49 | 55 |
return $self->make_price_from_rule($rule); |
56 |
} else { |
|
57 |
return SL::PriceSource::Price->new( |
|
58 |
price_source => $self, |
|
59 |
invalid => t8('The price rule is not a rule for prices'), |
|
60 |
); |
|
50 | 61 |
} |
51 |
|
|
52 |
return; |
|
53 | 62 |
} |
54 | 63 |
|
55 | 64 |
sub discount_from_source { |
56 | 65 |
my ($self, $source, $spec) = @_; |
57 | 66 |
|
58 | 67 |
my $rule = SL::DB::Manager::PriceRule->find_by(id => $spec); |
68 |
|
|
69 |
return SL::PriceSource::Discount->new( |
|
70 |
price_source => $self, |
|
71 |
missing => t8('The price rule for this discount does not exist anymore'), |
|
72 |
) if !$rule; |
|
73 |
|
|
59 | 74 |
if ($rule->price_type == SL::DB::Manager::PriceRule::PRICE_DISCOUNT()) { |
60 | 75 |
return $self->make_discount_from_rule($rule); |
76 |
} else { |
|
77 |
return SL::PriceSource::Discount->new( |
|
78 |
price_source => $self, |
|
79 |
invalid => t8('The price rule is not a rule for discounts'), |
|
80 |
); |
|
61 | 81 |
} |
62 |
|
|
63 |
return; |
|
64 | 82 |
} |
65 | 83 |
|
66 | 84 |
sub best_price { |
Auch abrufbar als: Unified diff
PriceSources: Fehlerbehandlung in PriceRules.