From: Moritz Bunkus Date: Fri, 14 Jun 2013 08:09:44 +0000 (+0200) Subject: Manager für Warehouse- und Currency-Models X-Git-Tag: release-3.1.0beta1~331^2~10 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=91b948e473f5b731a6886e4b2cd4c526a42ace4e;p=kivitendo-erp.git Manager für Warehouse- und Currency-Models --- diff --git a/SL/DB/Bin.pm b/SL/DB/Bin.pm index d9d29b4ff..e5397ef73 100644 --- a/SL/DB/Bin.pm +++ b/SL/DB/Bin.pm @@ -1,13 +1,9 @@ -# This file has been auto-generated only because it didn't exist. -# Feel free to modify it at will; it will not be overwritten automatically. - package SL::DB::Bin; use strict; use SL::DB::MetaSetup::Bin; -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. __PACKAGE__->meta->make_manager_class; 1; diff --git a/SL/DB/Currency.pm b/SL/DB/Currency.pm index 14ba066e9..9b24f4105 100644 --- a/SL/DB/Currency.pm +++ b/SL/DB/Currency.pm @@ -1,13 +1,8 @@ -# This file has been auto-generated only because it didn't exist. -# Feel free to modify it at will; it will not be overwritten automatically. - package SL::DB::Currency; use strict; use SL::DB::MetaSetup::Currency; - -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. -__PACKAGE__->meta->make_manager_class; +use SL::DB::Manager::Currency; 1; diff --git a/SL/DB/Manager/Currency.pm b/SL/DB/Manager/Currency.pm new file mode 100644 index 000000000..b18cd4cce --- /dev/null +++ b/SL/DB/Manager/Currency.pm @@ -0,0 +1,21 @@ +package SL::DB::Manager::Currency; + +use strict; + +use SL::DB::Helper::Manager; +use base qw(SL::DB::Helper::Manager); + +use SL::DB::Helper::Sorted; + +sub object_class { 'SL::DB::Currency' } + +__PACKAGE__->make_manager_methods; + +sub _sort_spec { + return ( default => [ 'id', 1 ], + columns => { SIMPLE => 'ALL', + map { ( $_ => "lower(currencies.$_)" ) } qw(name) + }); +} + +1; diff --git a/SL/DB/Manager/Warehouse.pm b/SL/DB/Manager/Warehouse.pm new file mode 100644 index 000000000..6642f876b --- /dev/null +++ b/SL/DB/Manager/Warehouse.pm @@ -0,0 +1,21 @@ +package SL::DB::Manager::Warehouse; + +use strict; + +use SL::DB::Helper::Manager; +use base qw(SL::DB::Helper::Manager); + +use SL::DB::Helper::Sorted; + +sub object_class { 'SL::DB::Warehouse' } + +__PACKAGE__->make_manager_methods; + +sub _sort_spec { + return ( default => [ 'sortkey', 1 ], + columns => { SIMPLE => 'ALL', + map { ( $_ => "lower(warehouse.$_)" ) } qw(description) + }); +} + +1; diff --git a/SL/DB/Warehouse.pm b/SL/DB/Warehouse.pm index 0557976f3..8345709da 100644 --- a/SL/DB/Warehouse.pm +++ b/SL/DB/Warehouse.pm @@ -1,15 +1,11 @@ -# This file has been auto-generated only because it didn't exist. -# Feel free to modify it at will; it will not be overwritten automatically. - package SL::DB::Warehouse; use strict; use SL::DB::MetaSetup::Warehouse; +use SL::DB::Manager::Warehouse; use SL::DB::Helper::ActsAsList; -__PACKAGE__->meta->make_manager_class; - __PACKAGE__->meta->add_relationship( bins => { type => 'one to many', @@ -18,13 +14,14 @@ __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 bins_sorted { + return [ sort { $a->id <=> $b->id } @{ shift()->bins || [] } ]; +} + sub first_bin { - return shift()->bins->[0]; + return shift()->bins_sorted->[0]; } 1;