]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/Manager/Order.pm
kivitendo 3.9.2-0.2
[mfinanz.git] / SL / DB / Manager / Order.pm
index ff5169bfa80bb28b46ac4e7cf9ad1790508133ef..378b96b8d756dd3e8b809fb09d2b31048ae2a29a 100644 (file)
@@ -4,10 +4,13 @@ use strict;
 
 use parent qw(SL::DB::Helper::Manager);
 
+use SL::DB::Order::TypeData qw(:types);
 use SL::DB::Helper::Paginated;
 use SL::DB::Helper::Sorted;
 use SL::DB::Helper::Filtered;
 
+use List::MoreUtils qw(any);
+
 sub object_class { 'SL::DB::Order' }
 
 __PACKAGE__->make_manager_methods;
@@ -28,10 +31,15 @@ sub type_filter {
   my $type   = lc(shift || '');
   my $prefix = shift || '';
 
-  return (and => [ "!${prefix}customer_id" => undef,         "${prefix}quotation" => 1                       ]) if $type eq 'sales_quotation';
-  return (and => [ "!${prefix}vendor_id"   => undef,         "${prefix}quotation" => 1                       ]) if $type eq 'request_quotation';
-  return (and => [ "!${prefix}customer_id" => undef, or => [ "${prefix}quotation" => 0, "${prefix}quotation" => undef ] ]) if $type eq 'sales_order';
-  return (and => [ "!${prefix}vendor_id"   => undef, or => [ "${prefix}quotation" => 0, "${prefix}quotation" => undef ] ]) if $type eq 'purchase_order';
+  return ("${prefix}record_type" => $type) if( any {$type eq $_} (
+      SALES_ORDER_INTAKE_TYPE(),
+      SALES_ORDER_TYPE(),
+      SALES_QUOTATION_TYPE(),
+      PURCHASE_ORDER_TYPE(),
+      PURCHASE_ORDER_CONFIRMATION_TYPE(),
+      REQUEST_QUOTATION_TYPE(),
+      PURCHASE_QUOTATION_INTAKE_TYPE(),
+    ));
 
   die "Unknown type $type";
 }