]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/Manager/Invoice.pm
RDBO Support.
[mfinanz.git] / SL / DB / Manager / Invoice.pm
diff --git a/SL/DB/Manager/Invoice.pm b/SL/DB/Manager/Invoice.pm
new file mode 100644 (file)
index 0000000..025f7f2
--- /dev/null
@@ -0,0 +1,24 @@
+package SL::DB::Manager::Invoice;
+
+use strict;
+
+use base qw(SL::DB::Helpers::Manager);
+
+sub object_class { 'SL::DB::Invoice' }
+
+__PACKAGE__->make_manager_methods;
+
+sub type_filter {
+  my $class = shift;
+  my $type  = lc(shift || '');
+
+  return (or  => [ invoice => 0, invoice => undef                                               ]) if $type eq 'ar_transaction';
+  return (and => [ invoice => 1, amount  => { ge => 0 }, or => [ storno => 0, storno => undef ] ]) if $type eq 'invoice';
+  return (and => [ invoice => 1, amount  => { lt => 0 }, or => [ storno => 0, storno => undef ] ]) if $type eq 'credit_note';
+  return (and => [ invoice => 1, amount  => { lt => 0 },         storno => 1                    ]) if $type =~ m/(?:invoice_)?storno/;
+  return (and => [ invoice => 1, amount  => { ge => 0 },         storno => 1                    ]) if $type eq 'credit_note_storno';
+
+  die "Unknown type $type";
+}
+
+1;