X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FPriceSource%2FPrice.pm;h=52558470c9deaed41c0b3f8343fc21347ff3bf55;hb=d58f0807a72e7a791cded47b057e5f20116ca13f;hp=1e8f0a299c2afa141a28a5d31faec96cf46035b7;hpb=cf63992efd6843a38de948fc509cdcc3bf51f1b6;p=kivitendo-erp.git diff --git a/SL/PriceSource/Price.pm b/SL/PriceSource/Price.pm index 1e8f0a299..52558470c 100644 --- a/SL/PriceSource/Price.pm +++ b/SL/PriceSource/Price.pm @@ -4,17 +4,18 @@ use strict; use parent 'SL::DB::Object'; use Rose::Object::MakeMethods::Generic ( - scalar => [ qw(price description spec price_source invalid missing) ], + scalar => [ qw(price description spec price_source invalid missing unknown) ], + 'scalar --get_set_init' => [ qw(priority editable) ], ); -use SL::DB::Helper::Attr; +require SL::DB::Helper::Attr; SL::DB::Helper::Attr::make(__PACKAGE__, price => 'numeric(15,5)', ); sub source { $_[0]->price_source - ? $_[0]->price_source->name . '/' . $_[0]->spec + ? $_[0]->price_source->name . '/' . $_[0]->spec : ''; } @@ -31,11 +32,19 @@ sub source_description { $self->price_source ? $self->price_source->description - : $self->description + : $self->description } sub to_str { - "source: @{[ $_[0]->source ]}, price: @{[ $_[0]->price]}, description: @{[ $_[0]->description ]}" + "source: @{[ $_[0]->source ]}, price: @{[ $_[0]->price ]}, description: @{[ $_[0]->description ]}" +} + +sub init_priority { + 3 +} + +sub init_editable { + 0 } 1; @@ -46,42 +55,38 @@ __END__ =head1 NAME -SL::PriceSource::Price - contrainer to pass calculated prices around +SL::PriceSource::Price - container to pass calculated prices around =head1 SYNOPSIS # in PriceSource::Base implementation $price = SL::PriceSource::Price->new( price => 10.3, - spec => '10.3', # something you can easily parse later - description => t8('Fix price 10.3'), + spec => '3', # something you can easily parse later + description => t8('Fix price 10.3 for customer 3'), price_source => $self, ) - # special empty price in SL::PriceSource + # special empty price in SL::PriceSource, for internal use. SL::PriceSource::Price->new( description => t8('None (PriceSource)'), ); - # invalid price + # price can't be restored SL::PriceSource::Price->new( - price => $original_price, - spec => $original_spec, - description => $original_description, - invalid => t8('Offer expired #1 weeks ago', $dt->delta_weeks), + missing => t8('Um, sorry, cannot find that one'), price_source => $self, ); - # missing price + # invalid price SL::PriceSource::Price->new( - price => $original_price, # will keep last entered price + price => $original_price, spec => $original_spec, - description => '', - missing => t8('Um, sorry, cannot find that one'), + description => $original_description, + invalid => t8('Offer expired #1 weeks ago', $dt->delta_weeks), price_source => $self, ); - =head1 DESCRIPTION See L for information about the mechanism. @@ -97,7 +102,7 @@ implementations. The price. A price of 0 is special and is considered undesirable. If passed as part of C it will be filtered out. If returned as -C or C it will be warned about. +C or C it will trigger a warning. =item C @@ -113,16 +118,43 @@ A localized short description of the origins of this price. A ref to the creating algorithm. +=item C + +OPTIONAL. Prices may supply a numerical priority. Higher will trump lower, even when +supplying higher prices. Defaults to 3 (as in middle of 1-5). + +=item C + +OPTIONAL. Prices may flag themselves as editable. An editable price will still +be subject to checks for higher or lower prices, but will be rendered in a +fashion that allows the user to overwrite it. + +This is potentially very distracting if the price is usually a default price +and will be changed in a lot of instances so use with caution. + +On the other hand it can provide the capability that users unfamiliar with the +system will intuitively expect so it can be a good way to introduce the system. + =item C OPTIONAL. Both indicator and localized message that the price with this spec could not be reproduced and should be changed. +If price is missing, you do not need to supply anything except C. + =item C OPTIONAL. Both indicator and localized message that the conditions for this price are no longer valid, and that the price should be changed. +If price is missing, you do not need to supply anything except C. + +=item C + +OPTIONAL. Boolean indicator that this price was not computed for performance +reasons. This is only valid for PriceSources flagged as C. This price +must be ignored. + =back =head1 SEE ALSO