1 package SL::DB::OrderItem;
5 use List::Util qw(sum);
7 use SL::DB::MetaSetup::OrderItem;
8 use SL::DB::Manager::OrderItem;
9 use SL::DB::DeliveryOrderItemsStock;
10 use SL::DB::Helper::ActsAsList;
11 use SL::DB::Helper::LinkedRecords;
12 use SL::DB::Helper::RecordItem;
13 use SL::DB::Helper::CustomVariables (
14 sub_module => 'orderitems',
18 class => 'SL::DB::Part',
23 use SL::Helper::ShippedQty;
25 __PACKAGE__->meta->initialize;
27 __PACKAGE__->configure_acts_as_list(group_by => [qw(trans_id)]);
29 sub is_price_update_available {
31 return $self->origprice > $self->part->sellprice;
35 my ($self, %params) = @_;
37 my $force = delete $params{force};
39 SL::Helper::ShippedQty->new(%params)->calculate($self)->write_to_objects if $force || !defined $self->{shipped_qty};
44 sub linked_delivery_order_items {
47 return $self->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrderItem');
50 sub delivered_qty { goto &shipped_qty }
52 sub record { goto &order }
62 SL::DB::OrderItems: Rose model for orderitems
68 =item C<shipped_qty PARAMS>
70 Calculates the shipped qty for this orderitem (measured in the current unit)
73 Note that the shipped qty is expected not to change within the request and is
74 cached in C<shipped_qty> once calculated. If C<< force => 1 >> is passed, the
75 existibng cache is ignored.
77 Given parameters will be passed to L<SL::Helper::ShippedQty>, so you can force
78 the shipped/delivered distinction like this:
80 $_->shipped_qty(require_stock_out => 0);
82 Note however that calculating shipped_qty on individual Orderitems is generally
83 a bad idea. See L<SL::Helper::ShippedQty> for way to compute these all at once.
85 =item C<delivered_qty>
87 Alias for L</shipped_qty>.
93 G. Richardson E<lt>grichardson@kivitendo-premium.deE<gt>