1 package SL::DB::DeliveryOrder;
7 use SL::DB::MetaSetup::DeliveryOrder;
8 use SL::DB::Manager::DeliveryOrder;
9 use SL::DB::Helper::LinkedRecords;
10 use SL::DB::Helper::TransNumberGenerator;
12 use List::Util qw(first);
14 __PACKAGE__->meta->add_relationship(orderitems => { type => 'one to many',
15 class => 'SL::DB::DeliveryOrderItem',
16 column_map => { id => 'delivery_order_id' },
17 manager_args => { with_objects => [ 'part' ] }
21 __PACKAGE__->meta->initialize;
25 sub items { goto &orderitems; }
30 return [ sort {$a->id <=> $b->id } @{ $self->items } ];
38 require SL::DB::Order;
39 my $orders = SL::DB::Manager::Order->get_all(
41 ordnumber => $self->ordnumber,
42 @{ $params{query} || [] },
46 return first { $_->is_type('sales_order') } @{ $orders };
50 return shift->customer_id ? 'sales_delivery_order' : 'purchase_delivery_order';
53 sub displayable_state {
57 ($self->closed ? $::locale->text('closed') : $::locale->text('open')),
58 ($self->delivered ? $::locale->text('delivered') : $::locale->text('not delivered'));