From: Moritz Bunkus Date: Mon, 12 May 2014 07:17:31 +0000 (+0200) Subject: RDBO: Manager-Klasse für Vendor X-Git-Tag: release-3.2.0beta~457 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=2b82180a2117342c28fdf913fa135ca0a1828aea;p=kivitendo-erp.git RDBO: Manager-Klasse für Vendor --- diff --git a/SL/DB/Manager/Vendor.pm b/SL/DB/Manager/Vendor.pm new file mode 100644 index 000000000..838d12b97 --- /dev/null +++ b/SL/DB/Manager/Vendor.pm @@ -0,0 +1,31 @@ +package SL::DB::Manager::Vendor; + +use strict; + +use SL::DB::Helper::Manager; +use base qw(SL::DB::Helper::Manager); + +use SL::DB::Helper::Filtered; +use SL::DB::Helper::Sorted; + +sub object_class { 'SL::DB::Vendor' } + +__PACKAGE__->make_manager_methods; + +__PACKAGE__->add_filter_specs( + all => sub { + my ($key, $value, $prefix) = @_; + return or => [ map { $prefix . $_ => $value } qw(vendornumber name) ] + } +); + +sub _sort_spec { + return ( + default => [ 'name', 1 ], + columns => { + SIMPLE => 'ALL', + map { ( $_ => "lower(vendor.$_)" ) } qw(account_number bank bank_code bcc bic cc city contact country department_1 department_2 depositor email fax greeting homepage iban language + name notes phone street taxnumber user_password username ustid v_customer_id vendornumber zipcode) + }); +} +1; diff --git a/SL/DB/Vendor.pm b/SL/DB/Vendor.pm index 23886eaef..8a1ea464f 100644 --- a/SL/DB/Vendor.pm +++ b/SL/DB/Vendor.pm @@ -3,6 +3,7 @@ package SL::DB::Vendor; use strict; use SL::DB::MetaSetup::Vendor; +use SL::DB::Manager::Vendor; use SL::DB::Helper::TransNumberGenerator; use SL::DB::Helper::CustomVariables ( module => 'CT', @@ -27,7 +28,6 @@ __PACKAGE__->meta->add_relationship( }, ); -__PACKAGE__->meta->make_manager_class; __PACKAGE__->meta->initialize; __PACKAGE__->before_save('_before_save_set_vendornumber'); @@ -39,6 +39,12 @@ sub _before_save_set_vendornumber { return 1; } +sub displayable_name { + my $self = shift; + + return join ' ', grep $_, $self->vendornumber, $self->name; +} + sub is_customer { 0 }; sub is_vendor { 1 };