1 package SL::PriceSource::Discount;
5 use parent 'SL::DB::Object';
6 use Rose::Object::MakeMethods::Generic (
7 scalar => [ qw(discount description spec price_source invalid missing) ],
10 require SL::DB::Helper::Attr;
11 SL::DB::Helper::Attr::make(__PACKAGE__,
12 discount => 'numeric(15,5)',
17 ? $_[0]->price_source->name . '/' . $_[0]->spec
21 sub full_description {
25 ? $self->price_source->description . ': ' . $self->description
29 sub source_description {
33 ? $self->price_source->description
38 "source: @{[ $_[0]->source ]}, discount: @{[ $_[0]->discount ]}, description: @{[ $_[0]->description ]}"
49 SL::PriceSource::Discount - contrainer to pass calculated discounts around
53 # in PriceSource::Base implementation
54 $price = SL::PriceSource::Discount->new(
56 spec => 'summersale2014', # something you can easily parse later
57 description => t8('10% discount during summer sale 2014'),
58 price_source => $self,
61 # special empty discount in SL::PriceSource, for internal use.
62 SL::PriceSource::Discount->new(
63 description => t8('None (PriceSource)'),
66 # price can't be restored
67 SL::PriceSource::Discount->new(
68 missing => t8('Um, sorry, cannot find that one'),
69 price_source => $self,
73 SL::PriceSource::Dicount->new(
74 discount => $original_discount,
75 spec => $original_spec,
76 description => $original_description,
77 invalid => t8('Offer expired #1 weeks ago', $dt->delta_weeks),
78 price_source => $self,
83 See L<SL::PriceSource> for information about the mechanism.
85 This is a container for discounts that are generated by L<SL::PriceSource::Base>
88 =head1 CONSTRUCTOR FIELDS
94 The discount in percent. A discount of 0 will be ignored. If passed as
95 part of C<available_prices> it will be filtered out. If returned as
96 C<best_discount> or C<discount_from_source> it will trigger a warning.
100 A unique string that can later be understood by the creating implementation.
101 Can be empty if the implementation only supports one discount for a given
106 A localized short description of the origins of this discount.
108 =item C<price_source>
110 A ref to the creating algorithm.
114 OPTIONAL. Both indicator and localized message that the discount with this spec
115 could not be reproduced and should be changed.
117 If discount is missing, you do not need to supply anything except C<source>.
121 OPTIONAL. Both indicator and localized message that the conditions for this
122 discount are no longer valid, and that the discount should be changed.
124 If discount is missing, you do not need to supply anything except C<source>.
131 L<SL::PriceSource::Base>,
132 L<SL::PriceSource::ALL>
140 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>