commit 27e3ec0d506e2e274f804db1725e8ffce88c7aa9
Author: Tamino Steinert <tamino.steinert@tamino.st>
Date:   Thu Jul 20 11:11:52 2023 +0200

    FIX: Reklamationsbericht: Sortierung nach angezeigten Werten

diff --git a/SL/Controller/Reclamation.pm b/SL/Controller/Reclamation.pm
index 92657f40b..10de31114 100644
--- a/SL/Controller/Reclamation.pm
+++ b/SL/Controller/Reclamation.pm
@@ -1285,14 +1285,14 @@ sub init_models {
       },
       id                      => t8('ID'),
       record_number           => t8('Reclamation Number'),
-      employee_id             => t8('Employee'),
-      salesman_id             => t8('Salesman'),
-      customer_id             => t8('Customer'),
-      vendor_id               => t8('Vendor'),
-      contact_id              => t8('Contact'),
-      language_id             => t8('Language'),
-      department_id           => t8('Department'),
-      globalproject_id        => t8('Project Number'),
+      employee                => t8('Employee'),
+      salesman                => t8('Salesman'),
+      customer                => t8('Customer'),
+      vendor                  => t8('Vendor'),
+      contact                 => t8('Contact'),
+      language                => t8('Language'),
+      department              => t8('Department'),
+      globalproject           => t8('Project Number'),
       cv_record_number        => ($self->type eq 'sales_reclamation' ? t8('Customer Record Number') : t8('Vendor Record Number')),
       transaction_description => t8('Description'),
       notes                   => t8('Notes'),
@@ -1302,12 +1302,12 @@ sub init_models {
       shipto_id               => t8('Shipping Address'),
       amount                  => t8('Total'),
       netamount               => t8('Subtotal'),
-      delivery_term_id        => t8('Delivery Terms'),
-      payment_id              => t8('Payment Terms'),
-      currency_id             => t8('Currency'),
+      delivery_term           => t8('Delivery Terms'),
+      payment                 => t8('Payment Terms'),
+      currency                => t8('Currency'),
       exchangerate            => t8('Exchangerate'),
       taxincluded             => t8('Tax Included'),
-      taxzone_id              => t8('Tax zone'),
+      taxzone                 => t8('Tax zone'),
       tax_point               => t8('Tax point'),
       reqdate                 => t8('Deadline'),
       transdate               => t8('Booking Date'),
@@ -1322,7 +1322,13 @@ sub init_models {
       (employee_id => SL::DB::Manager::Employee->current->id) x ($self->reclamation->is_sales  && !$::auth->assert('sales_all_edit', 1)),
       (employee_id => SL::DB::Manager::Employee->current->id) x (!$self->reclamation->is_sales && !$::auth->assert('purchase_all_edit', 1)),
     ],
-  );
+
+    with_objects => [
+        'customer',      'vendor',   'employee',   'salesman',
+        'contact',       'language', 'department', 'globalproject',
+        'delivery_term', 'payment',  'currency',   'taxzone',
+      ],
+    );
 }
 
 sub init_p {
@@ -1941,14 +1947,14 @@ sub prepare_report {
   my @columns_order = qw(
     id
     record_number
-    employee_id
-    salesman_id
-    customer_id
-    vendor_id
-    contact_id
-    language_id
-    department_id
-    globalproject_id
+    employee
+    salesman
+    customer
+    vendor
+    contact
+    language
+    department
+    globalproject
     cv_record_number
     transaction_description
     notes
@@ -1957,12 +1963,12 @@ sub prepare_report {
     shipvia
     amount
     netamount
-    delivery_term_id
-    payment_id
-    currency_id
+    delivery_term
+    payment
+    currency
     exchangerate
     taxincluded
-    taxzone_id
+    taxzone
     tax_point
     reqdate
     transdate
@@ -1974,9 +1980,9 @@ sub prepare_report {
 
   my @default_columns = qw(
     record_number
-    employee_id
-    department_id
-    globalproject_id
+    employee
+    department
+    globalproject
     cv_record_number
     transaction_description
     amount
@@ -1997,19 +2003,19 @@ sub prepare_report {
       obj_link => sub {$self->url_for(action => 'edit', id => $_[0]->id, type => $self->type, callback => $callback)},
       sub      => sub { $_[0]->record_number },
     },
-    employee_id => {
+    employee => {
       sub      => sub { $_[0]->employee ? $_[0]->employee->name : '' },
     },
-    salesman_id => {
+    salesman => {
       sub      => sub { $_[0]->salesman ? $_[0]->salesman->name : '' },
     },
-    language_id => {
+    language => {
       sub      => sub { $_[0]->language ? $_[0]->language->article_code : '' },
     },
-    department_id => {
+    department => {
       sub      => sub { $_[0]->department ? $_[0]->department->description : '' },
     },
-    globalproject_id => {
+    globalproject => {
       obj_link => sub { $_[0]->globalproject_id ?
        $self->url_for(
           controller => "controller.pl",
@@ -2047,7 +2053,7 @@ sub prepare_report {
     netamount  => {
       sub      => sub { $_[0]->netamount_as_number },
     },
-    delivery_term_id => {
+    delivery_term => {
       obj_link => sub { $_[0]->delivery_term_id ?
        $self->url_for(
           controller => "controller.pl",
@@ -2057,7 +2063,7 @@ sub prepare_report {
         ) : '' },
       sub      => sub { $_[0]->delivery_term ? $_[0]->delivery_term->description : '' },
     },
-    payment_id => {
+    payment => {
       obj_link => sub { $_[0]->payment_id ?
        $self->url_for(
           controller => "controller.pl",
@@ -2067,7 +2073,7 @@ sub prepare_report {
         ) : '' },
       sub      => sub { $_[0]->payment ? $_[0]->payment->description : '' },
     },
-    currency_id => {
+    currency => {
       sub      => sub { $_[0]->currency ? $_[0]->currency->name : '' },
     },
     exchangerate  => {
@@ -2076,7 +2082,7 @@ sub prepare_report {
     taxincluded => {
       sub      => sub { $_[0]->taxincluded ? t8('Yes') : t8('No') },
     },
-    taxzone_id => {
+    taxzone => {
       obj_link => sub { $_[0]->taxzone_id ?
        $self->url_for(
           controller => "controller.pl",
@@ -2109,11 +2115,11 @@ sub prepare_report {
     },
   );
   if ($self->type eq sales_reclamation_type()) {
-    $column_defs{customer_id} = ({
+    $column_defs{customer} = ({
       raw_data => sub { $_[0]->customervendor->presenter->customer(display => 'table-cell', callback => $callback) },
       sub      => sub { $_[0]->customervendor->name },
     });
-    $column_defs{contact_id} = ({
+    $column_defs{contact} = ({
       obj_link => sub { $self->url_for(
           controller => "controller.pl",
           action => 'CustomerVendor/edit',
@@ -2124,11 +2130,11 @@ sub prepare_report {
       sub      => sub { $_[0]->contact ? $_[0]->contact->cp_name : '' },
     });
   } elsif ($self->type eq purchase_reclamation_type()) {
-    $column_defs{vendor_id} = ({
+    $column_defs{vendor} = ({
       raw_data => sub { $_[0]->customervendor->presenter->vendor(display => 'table-cell', callback => $callback) },
       sub      => sub { $_[0]->customervendor->name },
     });
-    $column_defs{contact_id} = ({
+    $column_defs{contact} = ({
       obj_link => sub { $self->url_for(
           controller => "controller.pl",
           action => 'CustomerVendor/edit',
diff --git a/SL/DB/Manager/Reclamation.pm b/SL/DB/Manager/Reclamation.pm
index 176d77dbc..c382bd4d2 100644
--- a/SL/DB/Manager/Reclamation.pm
+++ b/SL/DB/Manager/Reclamation.pm
@@ -47,7 +47,15 @@ sub _sort_spec {
       customer                => 'lower(customer.name)',
       vendor                  => 'lower(vendor.name)',
       employee                => 'lower(employee.name)',
+      salesman                => 'lower(salesman.name)',
+      contact                 => 'lower(contact.cp_name)',
+      language                => 'lower(language.article_code)',
+      department              => 'lower(department.description)',
       globalprojectnumber     => 'lower(globalproject.projectnumber)',
+      delivery_term           => 'lower(delivery_term.description)',
+      payment                 => 'lower(payment.description)',
+      currency                => 'lower(currency.name)',
+      taxzone                 => 'lower(taxzone.description)',
 
       # Bug in Rose::DB::Object: the next should be
       # "globalproject.project_type.description". This workaround will
diff --git a/SL/Presenter/ReclamationFilter.pm b/SL/Presenter/ReclamationFilter.pm
index 95d437ac2..a7f0dc354 100644
--- a/SL/Presenter/ReclamationFilter.pm
+++ b/SL/Presenter/ReclamationFilter.pm
@@ -33,7 +33,7 @@ sub filter {
       'input_name' => 'filter.id:number',
       'input_default' =>$filter->{'id:number'},
       'report_id' => 'id',
-      'active' => 1,
+      'active' => 0,
     },
     'record_number' => {
       'position' => 3,
@@ -44,41 +44,41 @@ sub filter {
       'report_id' => 'record_number',
       'active' => 1,
     },
-    'employee_name' => {
+    'employee' => {
       'position' => 4,
       'text' => t8("Employee Name"),
       'input_type' => 'input_tag',
       'input_name' => 'filter.employee.name:substr::ilike',
       'input_default' =>$filter->{employee}->{'name:substr::ilike'},
-      'report_id' => 'employee_id',
+      'report_id' => 'employee',
       'active' => 1,
     },
-    'salesman_name' => {
+    'salesman' => {
       'position' => 5,
       'text' => t8("Salesman Name"),
       'input_type' => 'input_tag',
       'input_name' => 'filter.salesman.name:substr::ilike',
       'input_default' =>$filter->{salesman}->{'name:substr::ilike'},
-      'report_id' => 'salesman_id',
+      'report_id' => 'salesman',
       'active' => 1,
     },
     # 6,7 for Customer/Vendor
-    'customer_name' => {
+    'customer' => {
       'position' => 6,
       'text' => t8("Customer Name"),
       'input_type' => 'input_tag',
       'input_name' => 'filter.customer.name:substr::ilike',
       'input_default' => $filter->{customer}->{'name:substr::ilike'},
-      'report_id' => 'customer_id',
+      'report_id' => 'customer',
       'active' => ($reclamation_type eq 'sales_reclamation' ? 1 : 0),
     },
-    'vendor_name' => {
+    'vendor' => {
       'position' => 6,
-      'text' => t8("Vendor"),
+      'text' => t8("Vendor Name"),
       'input_type' => 'input_tag',
       'input_name' => 'filter.vendor.name:substr::ilike',
       'input_default' => $filter->{vendor}->{'name:substr::ilike'},
-      'report_id' => 'vendor_id',
+      'report_id' => 'vendor',
       'active' => ($reclamation_type eq 'purchase_reclamation' ? 1 : 0),
     },
     'customer_number' => {
@@ -103,7 +103,7 @@ sub filter {
       'input_type' => 'input_tag',
       'input_name' => 'filter.contact.cp_name:substr::ilike',
       'input_default' =>$filter->{contact}->{'cp_name:substr::ilike'},
-      'report_id' => 'contact_id',
+      'report_id' => 'contact',
       'active' => 1,
     },
     'language_code' => {
@@ -112,7 +112,7 @@ sub filter {
       'input_type' => 'input_tag',
       'input_name' => 'filter.language.article_code:substr::ilike',
       'input_default' =>$filter->{language}->{'article_code:substr::ilike'},
-      'report_id' => 'language_id',
+      'report_id' => 'language',
       'active' => 1,
     },
     'department_description' => {
@@ -121,7 +121,7 @@ sub filter {
       'input_type' => 'input_tag',
       'input_name' => 'filter.department.description:substr::ilike',
       'input_default' =>$filter->{department}->{'description:substr::ilike'},
-      'report_id' => 'department_id',
+      'report_id' => 'department',
       'active' => 1,
     },
     'globalproject_projectnumber' => {
@@ -130,7 +130,7 @@ sub filter {
       'input_type' => 'input_tag',
       'input_name' => 'filter.globalproject.projectnumber:substr::ilike',
       'input_default' =>$filter->{globalproject}->{'projectnumber:substr::ilike'},
-      'report_id' => 'globalproject_id',
+      'report_id' => 'globalproject',
       'active' => 1,
     },
     'globalproject_description' => {
@@ -222,7 +222,7 @@ sub filter {
       'input_type' => 'input_tag',
       'input_name' => 'filter.delivery_term.description:substr::ilike',
       'input_default' =>$filter->{delivery_term}->{'description:substr::ilike'},
-      'report_id' => 'delivery_term_id',
+      'report_id' => 'delivery_term',
       'active' => 1,
     },
     'payment_description' => {
@@ -231,7 +231,7 @@ sub filter {
       'input_type' => 'input_tag',
       'input_name' => 'filter.payment.description:substr::ilike',
       'input_default' =>$filter->{payment}->{'description:substr::ilike'},
-      'report_id' => 'payment_id',
+      'report_id' => 'payment',
       'active' => 1,
     },
     'currency_name' => {
@@ -240,7 +240,7 @@ sub filter {
       'input_type' => 'input_tag',
       'input_name' => 'filter.currency.name:substr::ilike',
       'input_default' =>$filter->{currency}->{'name:substr::ilike'},
-      'report_id' => 'currency_id',
+      'report_id' => 'currency',
       'active' => 1,
     },
     'exchangerate' => {
@@ -267,7 +267,7 @@ sub filter {
       'input_type' => 'input_tag',
       'input_name' => 'filter.taxzone.description:substr::ilike',
       'input_default' =>$filter->{taxzone}->{'description:substr::ilike'},
-      'report_id' => 'taxzone_id',
+      'report_id' => 'taxzone',
       'active' => 1,
     },
     'tax_point' => {
