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;
13 use List::Util qw(first);
15 __PACKAGE__->meta->add_relationship(orderitems => { type => 'one to many',
16 class => 'SL::DB::DeliveryOrderItem',
17 column_map => { id => 'delivery_order_id' },
18 manager_args => { with_objects => [ 'part' ] }
22 __PACKAGE__->meta->initialize;
26 sub items { goto &orderitems; }
32 my $orders = SL::DB::Manager::Order->get_all(
34 ordnumber => $self->ordnumber,
35 @{ $params{query} || [] },
39 return first { $_->is_type('sales_order') } @{ $orders };
43 return shift->customer_id ? 'sales_delivery_order' : 'purchase_delivery_order';
46 sub displayable_state {
50 ($self->closed ? $::locale->text('closed') : $::locale->text('open')),
51 ($self->delivered ? $::locale->text('delivered') : $::locale->text('not delivered'));