1 package SL::DB::DeliveryOrder;
5 use SL::DB::MetaSetup::DeliveryOrder;
6 use SL::DB::Manager::DeliveryOrder;
7 use SL::DB::Helper::LinkedRecords;
8 use SL::DB::Helper::TransNumberGenerator;
11 use List::Util qw(first);
13 __PACKAGE__->meta->add_relationship(orderitems => { type => 'one to many',
14 class => 'SL::DB::DeliveryOrderItem',
15 column_map => { id => 'delivery_order_id' },
16 manager_args => { with_objects => [ 'parts' ] }
18 shipto => { type => 'one to one',
19 class => 'SL::DB::Shipto',
20 column_map => { shipto_id => 'shipto_id' },
22 department => { type => 'one to one',
23 class => 'SL::DB::Department',
24 column_map => { department_id => 'id' },
28 __PACKAGE__->meta->initialize;
32 sub items { goto &orderitems; }
38 my $orders = SL::DB::Manager::Order->get_all(
40 ordnumber => $self->ordnumber,
41 @{ $params{query} || [] },
45 return first { $_->is_type('sales_order') } @{ $orders };
49 return shift->customer_id ? 'sales_delivery_order' : 'purchase_delivery_order';
52 sub displayable_state {
56 ($self->closed ? $::locale->text('closed') : $::locale->text('open')),
57 ($self->delivered ? $::locale->text('delivered') : $::locale->text('not delivered'));