SL:Webdav:File.pm->store: ungeänderte Dokumente nicht doppelt speichern.
[kivitendo-erp.git] / SL / PriceSource / MasterData.pm
index 3f7c11d..bf22c99 100644 (file)
@@ -20,6 +20,8 @@ sub available_prices {
     : ($self->make_lastcost,  $self->make_listprice);
 }
 
+sub available_discounts { }
+
 sub price_from_source {
   my ($self, $source, $spec) = @_;
 
@@ -29,17 +31,25 @@ sub price_from_source {
   : do { die "unknown spec '$spec'" };
 }
 
+sub discount_from_source { }
+
 sub best_price {
   $_[0]->record->is_sales
   ? $_[0]->make_sellprice
   : $_[0]->make_lastcost
 }
 
+sub best_discount { }
+
+sub unit_mul {
+  $_[0]->record_item ? $_[0]->record_item->unit_multiplier : 1
+}
+
 sub make_sellprice {
   my ($self) = @_;
 
   return SL::PriceSource::Price->new(
-    price        => $self->part->sellprice,
+    price        => $self->part->sellprice * $self->unit_mul,
     spec         => 'sellprice',
     description  => t8('Sellprice'),
     price_source => $self,
@@ -50,7 +60,7 @@ sub make_listprice {
   my ($self) = @_;
 
   return SL::PriceSource::Price->new(
-    price        => $self->part->listprice,
+    price        => $self->part->listprice * $self->unit_mul,
     spec         => 'listprice',
     description  => t8('List Price'),
     price_source => $self,
@@ -61,10 +71,11 @@ sub make_lastcost {
   my ($self) = @_;
 
   return SL::PriceSource::Price->new(
-    price        => $self->part->lastcost,
+    price        => $self->part->lastcost * $self->unit_mul,
     spec         => 'lastcost',
     description  => t8('Lastcost'),
     price_source => $self,
+    priority     => 2,
   );
 }