Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7317b8d9

Von Jan Büren vor mehr als 9 Jahren hinzugefügt

  • ID 7317b8d9828cad7fd033d73589d7e9665fb397c7
  • Vorgänger e6e4f310
  • Nachfolger 31347b09

OrderItem tote Funktionen entfernt

Unterschiede anzeigen:

SL/DB/OrderItem.pm
40 40
  return sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi);
41 41
}
42 42

  
43
sub delivered_qty {
44
  my ($self) = @_;
45

  
46
  return $self->_delivered_qty;
47
}
48

  
49
sub _delivered_qty {
50
  my ($self) = @_;
51

  
52
  return $self->{delivered_qty} if $self->{delivered_qty};
53

  
54
  my $d_orders = $self->order->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrder');
55

  
56
  my @d_orders_delivered = grep { $_->delivered } @$d_orders;
57

  
58
  my @doi_delivered      = grep { $_->parts_id == $self->parts_id } map { $_->orderitems } @d_orders_delivered;
59

  
60
  require SL::AM;
61
  $self->{delivered_qty} =  sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi_delivered);
62

  
63
  return $self->{delivered_qty};
64
}
65

  
66
sub value_of_goods {
67
  my ($self) = @_;
68

  
69
  my $price_factor = $self->price_factor || 1;
70

  
71
  $self->_delivered_qty;
72
  return ($self->_delivered_qty * $self->sellprice * (1 - $self->discount ) / $price_factor);
73
}
74

  
75
sub stocked_qty {
76
  my ($self) = @_;
77

  
78
  my $d_orders   = $self->order->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrder');
79
  my @doi        = grep { $_->parts_id == $self->parts_id } map { $_->orderitems } @$d_orders;
80

  
81
  return 0 if !@doi;
82

  
83
  my $doi_stocks = SL::DB::Manager::DeliveryOrderItemsStock->get_all(query => [delivery_order_item_id => [ map {$_->id} @doi ]]);
84

  
85
  require SL::AM;
86
  return sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @{ $doi_stocks });
87
}
88

  
89
sub taxincluded {
90
  my ($self) = @_;
91

  
92
  return SL::DB::Manager::Order->find_by(id => $self->trans_id)->taxincluded ?  $::locale->text('WARN: Tax included value!') : '';
93
}
94

  
95 43
sub record { goto &order }
96 44

  
97 45
1;
46

  

Auch abrufbar als: Unified diff