1 package SL::DB::OrderItem;
 
   5 use SL::DB::MetaSetup::OrderItem;
 
   6 use SL::DB::Manager::OrderItem;
 
   7 use SL::DB::Helper::ActsAsList;
 
   8 use SL::DB::Helper::LinkedRecords;
 
   9 use SL::DB::Helper::RecordItem;
 
  10 use SL::DB::Helper::CustomVariables (
 
  11   sub_module  => 'orderitems',
 
  15       class => 'SL::DB::Part',
 
  20 use SL::Helper::ShippedQty;
 
  22 __PACKAGE__->meta->initialize;
 
  24 __PACKAGE__->configure_acts_as_list(group_by => [qw(trans_id)]);
 
  26 sub is_price_update_available {
 
  28   return $self->origprice > $self->part->sellprice;
 
  32   my ($self, %params) = @_;
 
  34   my $force = delete $params{force};
 
  36   SL::Helper::ShippedQty->new(%params)->calculate($self)->write_to_objects if $force || !defined $self->{shipped_qty};
 
  41 sub linked_delivery_order_items {
 
  44   return $self->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrderItem');
 
  47 sub delivered_qty { goto &shipped_qty }
 
  49 sub record { goto &order }
 
  59 SL::DB::OrderItems: Rose model for orderitems
 
  65 =item C<shipped_qty PARAMS>
 
  67 Calculates the shipped qty for this orderitem (measured in the current unit)
 
  70 Note that the shipped qty is expected not to change within the request and is
 
  71 cached in C<shipped_qty> once calculated. If C<< force => 1 >> is passed, the
 
  72 existibng cache is ignored.
 
  74 Given parameters will be passed to L<SL::Helper::ShippedQty>, so you can force
 
  75 the shipped/delivered distinction like this:
 
  77   $_->shipped_qty(require_stock_out => 0);
 
  79 Note however that calculating shipped_qty on individual Orderitems is generally
 
  80 a bad idea. See L<SL::Helper::ShippedQty> for way to compute these all at once.
 
  82 =item C<delivered_qty>
 
  84 Alias for L</shipped_qty>.
 
  90 G. Richardson E<lt>grichardson@kivitendo-premium.deE<gt>