HelperFunktion OderItem: _delivered_qty optimiert
authorJan Büren <jan@kivitendo-premium.de>
Mon, 10 Nov 2014 15:29:51 +0000 (16:29 +0100)
committerJan Büren <jan@kivitendo-premium.de>
Mon, 10 Nov 2014 15:29:51 +0000 (16:29 +0100)
SL/DB/OrderItem.pm

index 1925c80..0c28a52 100644 (file)
@@ -37,13 +37,15 @@ sub shipped_qty {
 sub delivered_qty {
   my ($self) = @_;
 
-  $self->_delivered_qty unless $self->{delivered_qty};
+  $self->_delivered_qty;
   return $self->{delivered_qty};
 }
 
 sub _delivered_qty {
   my ($self) = @_;
 
+  return if $self->{delivered_qty};
+
   my $d_orders = $self->order->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrder');
 
   my @d_orders_delivered = grep { $_->delivered } @$d_orders;
@@ -59,7 +61,7 @@ sub value_of_goods {
 
   my $price_factor = $self->price_factor || 1;
 
-  $self->_delivered_qty unless $self->{delivered_qty};
+  $self->_delivered_qty;
   return ($self->{delivered_qty} * $self->sellprice * (1 - $self->discount ) / $price_factor);
 }