Revision ef2b5e94
Von Moritz Bunkus vor mehr als 12 Jahren hinzugefügt
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::Paginated; |
|
9 |
use SL::DB::Helper::Sorted; |
|
10 |
|
|
11 |
sub object_class { 'SL::DB::OrderItem' } |
|
12 |
|
|
13 |
__PACKAGE__->make_manager_methods; |
|
14 |
|
|
15 |
sub _sort_spec { |
|
16 |
return ( columns => { delivery_date => [ 'deliverydate', ], |
|
17 |
description => [ 'lower(orderitems.description)', ], |
|
18 |
partnumber => [ 'part.partnumber', ], |
|
19 |
qty => [ 'qty' ], |
|
20 |
ordnumber => [ 'order.ordnumber' ], |
|
21 |
customer => [ 'lower(customer.name)', ], |
|
22 |
position => [ 'trans_id', 'runningnumber' ], |
|
23 |
reqdate => [ 'COALESCE(orderitems.reqdate, order.reqdate)' ], |
|
24 |
orddate => [ 'order.orddate' ], |
|
25 |
sellprice => [ 'sellprice' ], |
|
26 |
discount => [ 'discount' ], |
|
27 |
transdate => [ 'transdate::date', 'order.reqdate' ], |
|
28 |
}, |
|
29 |
default => [ 'position', 1 ], |
|
30 |
nulls => { } |
|
31 |
); |
|
32 |
} |
|
33 |
|
|
34 |
sub default_objects_per_page { 40 } |
|
35 |
|
|
36 |
1; |
SL/DB/OrderItem.pm | ||
---|---|---|
6 | 6 |
use SL::AM; |
7 | 7 |
|
8 | 8 |
use SL::DB::MetaSetup::OrderItem; |
9 |
use SL::DB::Manager::OrderItem; |
|
9 | 10 |
use SL::DB::Helper::CustomVariables ( |
10 | 11 |
sub_module => 'orderitems', |
11 | 12 |
cvars_alias => 1, |
... | ... | |
37 | 38 |
}, |
38 | 39 |
); |
39 | 40 |
|
40 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
|
41 |
__PACKAGE__->meta->make_manager_class; |
|
42 |
|
|
43 | 41 |
__PACKAGE__->meta->initialize; |
44 | 42 |
|
45 | 43 |
sub is_price_update_available { |
... | ... | |
56 | 54 |
return sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi); |
57 | 55 |
} |
58 | 56 |
|
59 |
package SL::DB::Manager::OrderItem; |
|
60 |
|
|
61 |
use SL::DB::Helper::Paginated; |
|
62 |
use SL::DB::Helper::Sorted; |
|
63 |
|
|
64 |
sub _sort_spec { |
|
65 |
return ( columns => { delivery_date => [ 'deliverydate', ], |
|
66 |
description => [ 'lower(orderitems.description)', ], |
|
67 |
partnumber => [ 'part.partnumber', ], |
|
68 |
qty => [ 'qty' ], |
|
69 |
ordnumber => [ 'order.ordnumber' ], |
|
70 |
customer => [ 'lower(customer.name)', ], |
|
71 |
position => [ 'trans_id', 'runningnumber' ], |
|
72 |
reqdate => [ 'COALESCE(orderitems.reqdate, order.reqdate)' ], |
|
73 |
orddate => [ 'order.orddate' ], |
|
74 |
sellprice => [ 'sellprice' ], |
|
75 |
discount => [ 'discount' ], |
|
76 |
transdate => [ 'transdate::date', 'order.reqdate' ], |
|
77 |
}, |
|
78 |
default => [ 'position', 1 ], |
|
79 |
nulls => { } |
|
80 |
); |
|
81 |
} |
|
82 |
|
|
83 |
sub default_objects_per_page { 40 } |
|
84 |
|
|
85 | 57 |
1; |
Auch abrufbar als: Unified diff
Refactoring: Code für OrderItem-Manager von DB-Datei in eigene Manager-Datei ausgelagert