1 package SL::PriceSource::Base;
5 use parent qw(SL::DB::Object);
6 use Rose::Object::MakeMethods::Generic (
7 scalar => [ qw(record_item record) ],
10 sub name { die 'name needs to be implemented' }
12 sub description { die 'description needs to be implemented' }
14 sub available_prices { die 'available_prices needs to be implemented' }
16 sub best_price { die 'best_price needs to be implemented' }
18 sub price_from_source { die 'price_from_source needs to be implemented:' . "@_" }
21 $_[0]->record_item->part;
32 SL::PriceSource::Base - <oneliner description>
37 # TODO: thats bullshit, theres no need to have this pollute the namespace
38 # make a manager that handles this
40 my @list_of_price_sources = $record_item->price_sources;
41 for (@list_of_price_sources) {
42 my $internal_name = $_->name;
43 my $translated_name = $_->description;
44 my $price = $_->price;
47 $record_item->set_active_price_source($price_source) # equivalent to:
48 $record_item->active_price_source($price_source->name);
49 $record_item->sellprice($price_source->price);
52 $price_source->needed_params
53 $price_source->supported_params
57 PriceSource is an interface that allows generic algorithms to be used, to
58 calculate a price for a position in a record.
60 If any such price_source algorithm is known to the system, a user can chose
61 which of them should be used to claculate the price displayed in the record.
63 The algorithm is saved togetherwith the target price, so that changes in the
64 record can recalculate the price accordingly, and otherwise manual changes to
65 the price can reset the price_source used to custom (aka no price_source).
67 =head1 INTERFACE METHODS
73 Should return a unique internal name. Should be entered in
74 L<SL::PriceSource::ALL> so that a name_to_class lookup works.
78 Should return a translated name.
80 =item C<needed_params>
82 Should return a list of elements that a record_item NEEDS to be used with this calulation.
84 Both C<needed_params> nad C<supported_params> are purely informational at this point.
86 =item C<supported_params>
88 Should return a list of elements that a record_item MAY HAVE to be used with this calulation.
90 Both C<needed_params> nad C<supported_params> are purely informational at this point.
94 Calculate a price and return. Do not mutate the record_item. Should will return
95 undef if price is not applicable to the current record_item.
105 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>