1 package SL::PriceSource::Price;
5 use parent 'SL::DB::Object';
6 use Rose::Object::MakeMethods::Generic (
7 scalar => [ qw(price description spec price_source invalid missing) ],
8 'scalar --get_set_init' => [ qw(priority) ],
11 require SL::DB::Helper::Attr;
12 SL::DB::Helper::Attr::make(__PACKAGE__,
13 price => 'numeric(15,5)',
18 ? $_[0]->price_source->name . '/' . $_[0]->spec
22 sub full_description {
26 ? $self->price_source->description . ': ' . $self->description
30 sub source_description {
34 ? $self->price_source->description
39 "source: @{[ $_[0]->source ]}, price: @{[ $_[0]->price ]}, description: @{[ $_[0]->description ]}"
54 SL::PriceSource::Price - container to pass calculated prices around
58 # in PriceSource::Base implementation
59 $price = SL::PriceSource::Price->new(
61 spec => '3', # something you can easily parse later
62 description => t8('Fix price 10.3 for customer 3'),
63 price_source => $self,
66 # special empty price in SL::PriceSource, for internal use.
67 SL::PriceSource::Price->new(
68 description => t8('None (PriceSource)'),
71 # price can't be restored
72 SL::PriceSource::Price->new(
73 missing => t8('Um, sorry, cannot find that one'),
74 price_source => $self,
78 SL::PriceSource::Price->new(
79 price => $original_price,
80 spec => $original_spec,
81 description => $original_description,
82 invalid => t8('Offer expired #1 weeks ago', $dt->delta_weeks),
83 price_source => $self,
88 See L<SL::PriceSource> for information about the mechanism.
90 This is a container for prices that are generated by L<SL::PriceSource::Base>
93 =head1 CONSTRUCTOR FIELDS
99 The price. A price of 0 is special and is considered undesirable. If passed as
100 part of C<available_prices> it will be filtered out. If returned as
101 C<best_price> or C<price_from_source> it will trigger a warning.
105 A unique string that can later be understood by the creating implementation.
106 Can be empty if the implementation only supports one price for a given
111 A localized short description of the origins of this price.
113 =item C<price_source>
115 A ref to the creating algorithm.
119 OPTIONAL. Prices may supply a numerical priority. Higher will trump lower, even when
120 supplying higher prices. Defaults to 3 (as in middle of 1-5).
124 OPTIONAL. Both indicator and localized message that the price with this spec
125 could not be reproduced and should be changed.
127 If price is missing, you do not need to supply anything except C<source>.
131 OPTIONAL. Both indicator and localized message that the conditions for this
132 price are no longer valid, and that the price should be changed.
134 If price is missing, you do not need to supply anything except C<source>.
141 L<SL::PriceSource::Base>,
142 L<SL::PriceSource::ALL>
150 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>