From: Moritz Bunkus Date: Mon, 3 Sep 2012 07:29:22 +0000 (+0200) Subject: Refactoring: Code für OrderItem-Manager von DB-Datei in eigene Manager-Datei ausgelagert X-Git-Tag: release-3.0.0beta1~251^2~8 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=ef2b5e949ac07d4f3258821f781da90761bead1a;p=kivitendo-erp.git Refactoring: Code für OrderItem-Manager von DB-Datei in eigene Manager-Datei ausgelagert --- diff --git a/SL/DB/Manager/OrderItem.pm b/SL/DB/Manager/OrderItem.pm new file mode 100644 index 000000000..000369e76 --- /dev/null +++ b/SL/DB/Manager/OrderItem.pm @@ -0,0 +1,36 @@ +package SL::DB::Manager::OrderItem; + +use strict; + +use SL::DB::Helper::Manager; +use base qw(SL::DB::Helper::Manager); + +use SL::DB::Helper::Paginated; +use SL::DB::Helper::Sorted; + +sub object_class { 'SL::DB::OrderItem' } + +__PACKAGE__->make_manager_methods; + +sub _sort_spec { + return ( columns => { delivery_date => [ 'deliverydate', ], + description => [ 'lower(orderitems.description)', ], + partnumber => [ 'part.partnumber', ], + qty => [ 'qty' ], + ordnumber => [ 'order.ordnumber' ], + customer => [ 'lower(customer.name)', ], + position => [ 'trans_id', 'runningnumber' ], + reqdate => [ 'COALESCE(orderitems.reqdate, order.reqdate)' ], + orddate => [ 'order.orddate' ], + sellprice => [ 'sellprice' ], + discount => [ 'discount' ], + transdate => [ 'transdate::date', 'order.reqdate' ], + }, + default => [ 'position', 1 ], + nulls => { } + ); +} + +sub default_objects_per_page { 40 } + +1; diff --git a/SL/DB/OrderItem.pm b/SL/DB/OrderItem.pm index f24abcaf1..3b868d350 100644 --- a/SL/DB/OrderItem.pm +++ b/SL/DB/OrderItem.pm @@ -6,6 +6,7 @@ use List::Util qw(sum); use SL::AM; use SL::DB::MetaSetup::OrderItem; +use SL::DB::Manager::OrderItem; use SL::DB::Helper::CustomVariables ( sub_module => 'orderitems', cvars_alias => 1, @@ -37,9 +38,6 @@ __PACKAGE__->meta->add_relationship( }, ); -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. -__PACKAGE__->meta->make_manager_class; - __PACKAGE__->meta->initialize; sub is_price_update_available { @@ -56,30 +54,4 @@ sub shipped_qty { return sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi); } -package SL::DB::Manager::OrderItem; - -use SL::DB::Helper::Paginated; -use SL::DB::Helper::Sorted; - -sub _sort_spec { - return ( columns => { delivery_date => [ 'deliverydate', ], - description => [ 'lower(orderitems.description)', ], - partnumber => [ 'part.partnumber', ], - qty => [ 'qty' ], - ordnumber => [ 'order.ordnumber' ], - customer => [ 'lower(customer.name)', ], - position => [ 'trans_id', 'runningnumber' ], - reqdate => [ 'COALESCE(orderitems.reqdate, order.reqdate)' ], - orddate => [ 'order.orddate' ], - sellprice => [ 'sellprice' ], - discount => [ 'discount' ], - transdate => [ 'transdate::date', 'order.reqdate' ], - }, - default => [ 'position', 1 ], - nulls => { } - ); -} - -sub default_objects_per_page { 40 } - 1;