1 package SL::DB::OrderItem;
5 use SL::DB::MetaSetup::OrderItem;
6 use SL::DB::Helper::CustomVariables (
7 sub_module => 'orderitems',
10 parts_id => 'SL::DB::Part',
14 __PACKAGE__->meta->add_relationship(
17 class => 'SL::DB::Part',
18 column_map => { parts_id => 'id' },
22 class => 'SL::DB::PriceFactor',
23 column_map => { price_factor_id => 'id' },
27 class => 'SL::DB::Unit',
28 column_map => { unit => 'name' },
32 class => 'SL::DB::Order',
33 column_map => { trans_id => 'id' },
37 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
38 __PACKAGE__->meta->make_manager_class;
40 __PACKAGE__->meta->initialize;
42 sub is_price_update_available {
44 return $self->origprice > $self->part->sellprice;
47 package SL::DB::Manager::OrderItem;
49 use SL::DB::Helper::Paginated;
50 use SL::DB::Helper::Sorted;
53 return ( columns => { delivery_date => [ 'deliverydate', ],
54 description => [ 'lower(orderitems.description)', ],
55 partnumber => [ 'part.partnumber', ],
57 ordnumber => [ 'order.ordnumber' ],
58 customer => [ 'lower(customer.name)', ],
59 position => [ 'trans_id', 'runningnumber' ],
60 transdate => [ 'transdate', 'lower(order.reqdate::text)' ],
62 default => [ 'position', 1 ],
67 sub default_objects_per_page { 40 }