]> wagnertech.de Git - mfinanz.git/blob - SL/DB/Manager/Reclamation.pm
restart apache2 in postinst
[mfinanz.git] / SL / DB / Manager / Reclamation.pm
1 package SL::DB::Manager::Reclamation;
2
3 use strict;
4
5 use parent qw(SL::DB::Helper::Manager);
6
7 use SL::DB::Helper::Paginated;
8 use SL::DB::Helper::Sorted;
9 use SL::DB::Helper::Filtered;
10
11 sub object_class { 'SL::DB::Reclamation' }
12
13 __PACKAGE__->make_manager_methods;
14
15 __PACKAGE__->add_filter_specs(
16   type => sub {
17     my ($key, $value, $prefix) = @_;
18     return __PACKAGE__->type_filter($value, $prefix);
19   },
20   # todo when is this used?
21   #all => sub {
22   #  my ($key, $value, $prefix) = @_;
23   #  return or => [ map { $prefix . $_ => $value } qw(record_number customer.name vendor.name transaction_description) ]
24   #}
25 );
26
27 sub type_filter {
28   my $class  = shift;
29   my $type   = lc(shift || '');
30   my $prefix = shift || '';
31
32   return (and => [ "!customer_id" => undef ]) if $type eq 'sales_reclamation';
33   return (and => [ "!vendor_id"   => undef ]) if $type eq 'purchase_reclamation';
34
35   die "Unknown type $type";
36 }
37
38 sub _sort_spec {
39   return (
40     default                   => [ 'transdate', 1 ],
41     nulls                     => {
42       transaction_description => 'FIRST',
43       default                 => 'LAST',
44     },
45     columns                   => {
46       SIMPLE                  => 'ALL',
47       customer                => 'lower(customer.name)',
48       vendor                  => 'lower(vendor.name)',
49       employee                => 'lower(employee.name)',
50       salesman                => 'lower(salesman.name)',
51       contact                 => 'lower(contact.cp_name)',
52       language                => 'lower(language.article_code)',
53       department              => 'lower(department.description)',
54       globalprojectnumber     => 'lower(globalproject.projectnumber)',
55       delivery_term           => 'lower(delivery_term.description)',
56       payment                 => 'lower(payment.description)',
57       currency                => 'lower(currency.name)',
58       taxzone                 => 'lower(taxzone.description)',
59
60       # Bug in Rose::DB::Object: the next should be
61       # "globalproject.project_type.description". This workaround will
62       # only work if no other table with "project_type" is visible in
63       # the current query
64       globalproject_type      => 'lower(project_type.description)',
65
66       map { ( $_ => "lower(reclamations.$_)" ) }
67         qw(record_number cv_record_number shippingpoint shipvia notes intnotes
68            transaction_description
69         ),
70     });
71 }
72
73 1;