X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FPriceSource%2FDiscount.pm;h=66f9532c5ebf19661becfb51440d5d3aaefa0aa2;hb=c5057972d03f3546494fabe72224785e5a0a1714;hp=6c95f90594694424bf85fc821c9abcb8f16e629d;hpb=89b2668811eac6023ad58322e2f9970ddb6a27c9;p=kivitendo-erp.git diff --git a/SL/PriceSource/Discount.pm b/SL/PriceSource/Discount.pm index 6c95f9059..66f9532c5 100644 --- a/SL/PriceSource/Discount.pm +++ b/SL/PriceSource/Discount.pm @@ -4,7 +4,8 @@ use strict; use parent 'SL::DB::Object'; use Rose::Object::MakeMethods::Generic ( - scalar => [ qw(discount description spec price_source invalid missing) ], + scalar => [ qw(discount description spec price_source invalid missing unknown) ], + 'scalar --get_set_init' => [ qw(priority) ], ); require SL::DB::Helper::Attr; @@ -38,6 +39,10 @@ sub to_str { "source: @{[ $_[0]->source ]}, discount: @{[ $_[0]->discount ]}, description: @{[ $_[0]->description ]}" } +sub init_priority { + 3 +} + 1; __END__ @@ -46,32 +51,32 @@ __END__ =head1 NAME -SL::PriceSource::Price - contrainer to pass calculated prices around +SL::PriceSource::Discount - container to pass calculated discounts around =head1 SYNOPSIS # in PriceSource::Base implementation - $price = SL::PriceSource::Price->new( + $price = SL::PriceSource::Discount->new( discount => 10, spec => 'summersale2014', # something you can easily parse later description => t8('10% discount during summer sale 2014'), price_source => $self, ) - # special empty price in SL::PriceSource, for internal use. - SL::PriceSource::Price->new( + # special empty discount in SL::PriceSource, for internal use. + SL::PriceSource::Discount->new( description => t8('None (PriceSource)'), ); # price can't be restored - SL::PriceSource::Price->new( + SL::PriceSource::Discount->new( missing => t8('Um, sorry, cannot find that one'), price_source => $self, ); - # invalid price - SL::PriceSource::Price->new( - price => $original_price, + # invalid discount + SL::PriceSource::Discount->new( + discount => $original_discount, spec => $original_spec, description => $original_description, invalid => t8('Offer expired #1 weeks ago', $dt->delta_weeks), @@ -82,7 +87,7 @@ SL::PriceSource::Price - contrainer to pass calculated prices around See L for information about the mechanism. -This is a container for prices that are generated by L +This is a container for discounts that are generated by L implementations. =head1 CONSTRUCTOR FIELDS @@ -93,35 +98,46 @@ implementations. The discount in percent. A discount of 0 will be ignored. If passed as part of C it will be filtered out. If returned as -C or C it will trigger a warning. +C or C it will trigger a warning. =item C A unique string that can later be understood by the creating implementation. -Can be empty if the implementation only supports one price for a given +Can be empty if the implementation only supports one discount for a given record_item. =item C -A localized short description of the origins of this price. +A localized short description of the origins of this discount. =item C A ref to the creating algorithm. +=item C + +OPTIONAL. Discounts may supply a numerical priority. Higher will trump over lower, even when +supplying lower discounts. Defaults to 3 (as in middle of 1-5). + =item C -OPTIONAL. Both indicator and localized message that the price with this spec +OPTIONAL. Both indicator and localized message that the discount with this spec could not be reproduced and should be changed. -If price is missing, you do not need to supply anything except C. +If discount 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. +discount are no longer valid, and that the discount should be changed. + +If discount is missing, you do not need to supply anything except C. + +=item C -If price is missing, you do not need to supply anything except C. +OPTIONAL. Boolean indicator that this discount was not computed for performance +reasons. This is only valid for PriceSources flagged as C. This discount +must be ignored. =back