From 2b82180a2117342c28fdf913fa135ca0a1828aea Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 12 May 2014 09:17:31 +0200 Subject: [PATCH] =?utf8?q?RDBO:=20Manager-Klasse=20f=C3=BCr=20Vendor?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/Manager/Vendor.pm | 31 +++++++++++++++++++++++++++++++ SL/DB/Vendor.pm | 8 +++++++- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 SL/DB/Manager/Vendor.pm 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 }; -- 2.20.1