RDBO Support.
[kivitendo-erp.git] / SL / DB / Manager / Order.pm
diff --git a/SL/DB/Manager/Order.pm b/SL/DB/Manager/Order.pm
new file mode 100644 (file)
index 0000000..451a43a
--- /dev/null
@@ -0,0 +1,24 @@
+package SL::DB::Manager::Order;
+
+use strict;
+
+use SL::DB::Helpers::Manager;
+use base qw(SL::DB::Helpers::Manager);
+
+sub object_class { 'SL::DB::Order' }
+
+__PACKAGE__->make_manager_methods;
+
+sub type_filter {
+  my $class = shift;
+  my $type  = lc(shift || '');
+
+  return (and => [ '!customer_id' => undef,         quotation => 1                       ]) if $type eq 'sales_quotation';
+  return (and => [ '!vendor_id'   => undef,         quotation => 1                       ]) if $type eq 'request_quotation';
+  return (and => [ '!customer_id' => undef, or => [ quotation => 0, quotation => undef ] ]) if $type eq 'sales_order';
+  return (and => [ '!vendor_id'   => undef, or => [ quotation => 0, quotation => undef ] ]) if $type eq 'purchase_order';
+
+  die "Unknown type $type";
+}
+
+1;