Lieferplan Modus Lieferwertbericht entfernt
[kivitendo-erp.git] / SL / PriceSource / Base.pm
index b095684..8233c58 100644 (file)
@@ -13,14 +13,22 @@ sub description { die 'description needs to be implemented' }
 
 sub available_prices { die 'available_prices needs to be implemented' }
 
+sub available_discounts { die 'available_discounts needs to be implemented' }
+
 sub best_price { die 'best_price needs to be implemented' }
 
+sub best_discounts { die 'best_discounts needs to be implemented' }
+
 sub price_from_source { die 'price_from_source needs to be implemented:' . "@_" }
 
 sub part {
   $_[0]->record_item->part;
 }
 
+sub customer_vendor {
+  $_[0]->record->is_sales ? $_[0]->record->customer : $_[0]->record->vendor;
+}
+
 1;
 
 __END__
@@ -98,6 +106,10 @@ anything and do not save those.
 
 Shortcut to C<< record_item->part >>
 
+=item C<customer_vendor>
+
+Shortcut to C<< record->is_sales ? record->customer : record->vendor >>
+
 =back
 
 =head1 INTERFACE METHODS
@@ -111,26 +123,40 @@ L<SL::PriceSource::ALL>.
 
 =item C<description>
 
-Must return a translated name to be used in frontend. Will be used, to
+Must return a translated name to be used in the frontend. Will be used to
 distinguish the origin of different prices.
 
 =item C<available_prices>
 
-Must return a list of all prices that you algorithm can recommend the user
+Must return a list of all prices that your algorithm can recommend to the user
 for the current situation. Each price must have a unique spec that can be used
 to recreate it later. Try to be brief, no one needs 20 different price
 suggestions.
 
+=item C<available_discounts>
+
+Must return a list of all prices that your algorithm can recommend to the user
+for the current situation. Each discount must have a unique spec that can be
+used to recreate it later. Try to be brief, no one needs 20 different discount
+suggestions.
+
 =item C<best_price>
 
 Must return what you think of as the best matching price in your
 C<available_prices>. This does not have to be the lowest price, but it will be
 compared later to other price sources, and the lowest will be set.
 
+=item C<best_discount>
+
+Must return what you think of as the best matching discount in your
+C<available_discounts>. This does not have to be the highest discount, but it
+will be compared later to other price sources, and the highest will be set.
+
 =item C<price_from_source SOURCE, SPEC>
 
-Must recreate the price from C<SPEC> and return. For reference, the complete
-C<SOURCE> entry from C<record_item.active_price_source> is included.
+Must recreate the price or discount from C<SPEC> and return. For reference, the
+complete C<SOURCE> entry from C<record_item.active_price_source> or
+C<record_item.active_discount_source> is included.
 
 Note that constraints from the rest of the C<record> do not apply anymore. If
 information needed for the retrieval can be deleted elsewhere, then you must
@@ -152,7 +178,7 @@ C<invalid> or C<missing> set.
 =item *
 
 Be aware that all 8 types of record will be passed to your algorithm. If you
-don't serve some of them, just return emptry lists on C<available_prices> and
+don't serve some of them, just return empty lists on C<available_prices> and
 C<best_price>
 
 =item *
@@ -163,7 +189,7 @@ created records there might be fields not set at all.
 =item *
 
 Records will not be calculated. If you need tax data or position totals, you
-need to invoke that for yourself.
+need to invoke that yourself.
 
 =item *
 
@@ -172,7 +198,7 @@ Accessor methods might not be present in some of the record types.
 =item *
 
 You do not need to do price factor and row discount calculation. These will be
-done automatically afterwards. You do have to include customer/vendor discount
+done automatically afterwards. You do have to include customer/vendor discounts
 if your price interacts with those.
 
 =item *
@@ -183,6 +209,8 @@ The price field in purchase records is still C<sellprice>.
 
 C<source> and C<spec> are tainted. If you store data directly in C<spec>, sanitize.
 
+=back
+
 =head1 SEE ALSO
 
 L<SL::PriceSource>,