From ef2b5e949ac07d4f3258821f781da90761bead1a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 3 Sep 2012 09:29:22 +0200 Subject: [PATCH] =?utf8?q?Refactoring:=20Code=20f=C3=BCr=20OrderItem-Manag?= =?utf8?q?er=20von=20DB-Datei=20in=20eigene=20Manager-Datei=20ausgelagert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/Manager/OrderItem.pm | 36 ++++++++++++++++++++++++++++++++++++ SL/DB/OrderItem.pm | 30 +----------------------------- 2 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 SL/DB/Manager/OrderItem.pm 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; -- 2.20.1