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   array => [ qw(depends_on) ]
 
  11 use 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
 
  31   "source: @{[ $_[0]->source ]}, price: @{[ $_[0]->price]}, description: @{[ $_[0]->description ]}"
 
  42 SL::PriceSource::Price - contrainer to pass calculated prices around
 
  46   # in PriceSource::Base implementation
 
  47   $price = SL::PriceSource::Price->new(
 
  49     spec         => '10.3', # something you can easily parse later
 
  50     description  => t8('Fix price 10.3'),
 
  51     price_source => $self,
 
  54   # special empty price in SL::PriceSource
 
  55   SL::PriceSource::Price->new(
 
  56     description => t8('None (PriceSource)'),
 
  60   SL::PriceSource::Price->new(
 
  61     price        => $original_price,
 
  62     spec         => $original_spec,
 
  63     description  => $original_description,
 
  64     invalid      => t8('Offer expired #1 weeks ago', $dt->delta_weeks),
 
  65     price_source => $self,
 
  69   SL::PriceSource::Price->new(
 
  70     price        => $original_price,              # will keep last entered price
 
  71     spec         => $original_spec,
 
  73     missing      => t8('Um, sorry, cannot find that one'),
 
  74     price_source => $self,
 
  80 See L<SL::PriceSource> for information about the mechanism.
 
  82 This is a container for prices that are generated by L<SL::PriceSource::Base>
 
  85 =head1 CONSTRUCTOR FIELDS
 
  91 The price. A price of 0 is special and is considered undesirable. If passed as
 
  92 part of C<available_prices> it will be filtered out. If returned as
 
  93 C<best_price> or C<price_from_source> it will be warned about.
 
  97 A unique string that can later be understood by the creating implementation.
 
  98 Can be empty if the implementation only supports one price for a given
 
 103 A localized short description of the origins of this price.
 
 105 =item C<price_source>
 
 107 A ref to the creating algorithm.
 
 111 OPTIONAL. Both indicator and localized message that the price with this spec
 
 112 could not be reproduced and should be changed.
 
 116 OPTIONAL. Both indicator and localized message that the conditions for this
 
 117 price are no longer valid, and that the price should be changed.
 
 124 L<SL::PriceSource::Base>,
 
 125 L<SL::PriceSource::ALL>
 
 133 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>