X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/1c311d64f260430ee33bc8aeda03aeb5f437d9a9..2edde6a9ae21a8cd71fa6006579b42bed0a3c13f:/SL/PriceSource.pm diff --git a/SL/PriceSource.pm b/SL/PriceSource.pm index c8cdc6cd1..66daad285 100644 --- a/SL/PriceSource.pm +++ b/SL/PriceSource.pm @@ -31,6 +31,17 @@ sub price_from_source { : empty_price(); } +sub discount_from_source { + my ($self, $source) = @_; + my ($source_name, $spec) = split m{/}, $source, 2; + + my $class = SL::PriceSource::ALL->price_source_class_by_name($source_name); + + return $class + ? $class->new(record_item => $self->record_item, record => $self->record)->discount_from_source($source, $spec) + : empty_discount(); +} + sub available_prices { map { $_->available_prices } $_[0]->all_price_sources; } @@ -54,6 +65,12 @@ sub empty_price { ); } +sub empty_discount { + SL::PriceSource::Discount->new( + description => t8('None (PriceSource Discount)'), + ); +} + 1; __END__ @@ -136,30 +153,69 @@ not have to be registered in C. Attempts to retrieve a formerly calculated price with the same conditions +=item C + +Attempts to retrieve a formerly calculated discount with the same conditions + =item C Returns all available prices. +=item C + +Returns all available discounts. + =item C Attempts to get the best available price. returns L if no price is found. +=item C + +Attempts to get the best available discount. returns L if no discount is found. + =item C A special empty price, that does not change the previously entered price, and opens the price field to manual changes. +=item C + +A special empty discount, that does not change the previously entered discount, and +opens the discount field to manual changes. + =back =head1 SEE ALSO L, L, +L, L -=head1 BUGS +=head1 BUGS AND CAVEATS + +=over 4 -None yet. :) +=item * + +The current simple model of price sources providing a simple value in simple +cases doesn't work well in situations where prices are modified by other +properties. The same problem also causes headaches when trying to use price +sources to compute positions in assemblies. + +The solution should be to split price sources in simple ones, which do not +manage their interactions with record_items, but can be used in contexts +without record_items, and complex ones which do, but have to be fed a dummy +record_item. For the former there should be a wrapper that handles interactions +with units, price_factors etc.. + +=item * + +Currently it is only possible to provide additional prices, but not to restrict +prices. Potential scenarios include credit limit customers which do not receive +benefits from sales, or general ALLOW, DENY order calculation. + +=back =head1 AUTHOR