Revision f7c37ff9
Von Jan Büren vor etwa 10 Jahren hinzugefügt
SL/DB/OrderItem.pm | ||
---|---|---|
37 | 37 |
sub delivered_qty { |
38 | 38 |
my ($self) = @_; |
39 | 39 |
|
40 |
$self->_delivered_qty unless $self->{delivered_qty}; |
|
41 |
return $self->{delivered_qty}; |
|
42 |
} |
|
43 |
|
|
44 |
sub _delivered_qty { |
|
45 |
my ($self) = @_; |
|
46 |
|
|
40 | 47 |
my $d_orders = $self->order->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrder'); |
41 | 48 |
|
42 | 49 |
my @d_orders_delivered = grep { $_->delivered } @$d_orders; |
... | ... | |
45 | 52 |
|
46 | 53 |
require SL::AM; |
47 | 54 |
$self->{delivered_qty} = sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi_delivered); |
48 |
return $self->{delivered_qty}; |
|
49 | 55 |
} |
50 | 56 |
|
51 | 57 |
sub value_of_goods { |
... | ... | |
53 | 59 |
|
54 | 60 |
my $price_factor = $self->price_factor || 1; |
55 | 61 |
|
62 |
$self->_delivered_qty unless $self->{delivered_qty}; |
|
56 | 63 |
return ($self->{delivered_qty} * $self->sellprice * (1 - $self->discount ) / $price_factor); |
57 | 64 |
} |
58 | 65 |
|
Auch abrufbar als: Unified diff
OrderItems-> delivered_qty in helper-funktion ausgelagert
Ergänzung zum Commit von gerade: Da man nicht sicher sein kann,
ob dieser Wert als Objekt-Variable zu dem Zeitpunkt (t2) schon berechnet
wurde, entsprechend in eine nach perl-konvention private (_delivered_qty)
funktion ausgelagert.