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 unknown) ],
 
   8   'scalar --get_set_init' => [ qw(priority editable) ],
 
  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 ]}"
 
  58 SL::PriceSource::Price - container to pass calculated prices around
 
  62   # in PriceSource::Base implementation
 
  63   $price = SL::PriceSource::Price->new(
 
  65     spec         => '3', # something you can easily parse later
 
  66     description  => t8('Fix price 10.3 for customer 3'),
 
  67     price_source => $self,
 
  70   # special empty price in SL::PriceSource, for internal use.
 
  71   SL::PriceSource::Price->new(
 
  72     description => t8('None (PriceSource)'),
 
  75   # price can't be restored
 
  76   SL::PriceSource::Price->new(
 
  77     missing      => t8('Um, sorry, cannot find that one'),
 
  78     price_source => $self,
 
  82   SL::PriceSource::Price->new(
 
  83     price        => $original_price,
 
  84     spec         => $original_spec,
 
  85     description  => $original_description,
 
  86     invalid      => t8('Offer expired #1 weeks ago', $dt->delta_weeks),
 
  87     price_source => $self,
 
  92 See L<SL::PriceSource> for information about the mechanism.
 
  94 This is a container for prices that are generated by L<SL::PriceSource::Base>
 
  97 =head1 CONSTRUCTOR FIELDS
 
 103 The price. A price of 0 is special and is considered undesirable. If passed as
 
 104 part of C<available_prices> it will be filtered out. If returned as
 
 105 C<best_price> or C<price_from_source> it will trigger a warning.
 
 109 A unique string that can later be understood by the creating implementation.
 
 110 Can be empty if the implementation only supports one price for a given
 
 115 A localized short description of the origins of this price.
 
 117 =item C<price_source>
 
 119 A ref to the creating algorithm.
 
 123 OPTIONAL. Prices may supply a numerical priority. Higher will trump lower, even when
 
 124 supplying higher prices. Defaults to 3 (as in middle of 1-5).
 
 128 OPTIONAL. Prices may flag themselves as editable. An editable price will still
 
 129 be subject to checks for higher or lower prices, but will be rendered in a
 
 130 fashion that allows the user to overwrite it.
 
 132 This is potentially very distracting if the price is usually a default price
 
 133 and will be changed in a lot of instances so use with caution.
 
 135 On the other hand it can provide the capability that users unfamiliar with the
 
 136 system will intuitively expect so it can be a good way to introduce the system.
 
 140 OPTIONAL. Both indicator and localized message that the price with this spec
 
 141 could not be reproduced and should be changed.
 
 143 If price is missing, you do not need to supply anything except C<source>.
 
 147 OPTIONAL. Both indicator and localized message that the conditions for this
 
 148 price are no longer valid, and that the price should be changed.
 
 150 If price is missing, you do not need to supply anything except C<source>.
 
 154 OPTIONAL. Boolean indicator that this price was not computed for performance
 
 155 reasons. This is only valid for PriceSources flagged as C<fast>. This price
 
 163 L<SL::PriceSource::Base>,
 
 164 L<SL::PriceSource::ALL>
 
 172 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>