Order: new_from: auch gleiche Quell- und Ziel-Typen berücksichtigen
[kivitendo-erp.git] / SL / DB / Manager / OrderItem.pm
1 package SL::DB::Manager::OrderItem;
2
3 use strict;
4
5 use SL::DB::Helper::Manager;
6 use base qw(SL::DB::Helper::Manager);
7
8 use SL::DB::Helper::Filtered;
9 use SL::DB::Helper::Paginated;
10 use SL::DB::Helper::Sorted;
11
12 sub object_class { 'SL::DB::OrderItem' }
13
14 __PACKAGE__->make_manager_methods;
15 __PACKAGE__->add_filter_specs(
16   reqdate => sub {
17     my ($key, $value, $prefix) = @_;
18
19     return or => [
20       $prefix . reqdate => $value,
21       and => [
22         $prefix . reqdate => undef,
23         $prefix . 'order.reqdate' => $value,
24       ]
25     ], $prefix . 'order';
26   },
27 );
28
29
30 sub _sort_spec {
31   return ( columns => { delivery_date => [ 'deliverydate',        ],
32                         description   => [ 'lower(orderitems.description)',  ],
33                         partnumber    => [ 'part.partnumber',     ],
34                         qty           => [ 'qty'                  ],
35                         ordnumber     => [ 'order.ordnumber'      ],
36                         customer      => [ 'lower(customer.name)', ],
37                         position      => [ 'trans_id', 'runningnumber' ],
38                         reqdate       => [ 'COALESCE(orderitems.reqdate, order.reqdate)' ],
39                         orddate       => [ 'order.orddate' ],
40                         sellprice     => [ 'sellprice' ],
41                         discount      => [ 'discount' ],
42                         transdate     => [ 'orderitems.transdate::date', 'order.reqdate' ],
43                       },
44            default => [ 'position', 1 ],
45            nulls   => { }
46          );
47 }
48
49 sub default_objects_per_page { 15 }
50
51 1;