c3a9a7bb4eeba79ce143f7d98cb5eef3a8c794fb
[kivitendo-erp.git] / SL / DB / Manager / Invoice.pm
1 package SL::DB::Manager::Invoice;
2
3 use strict;
4
5 use base qw(SL::DB::Helper::Manager);
6
7 sub object_class { 'SL::DB::Invoice' }
8
9 __PACKAGE__->make_manager_methods;
10
11 sub type_filter {
12   my $class = shift;
13   my $type  = lc(shift || '');
14
15   return (or  => [ invoice => 0, invoice => undef                                               ]) if $type eq 'ar_transaction';
16   return (and => [ invoice => 1, amount  => { ge => 0 }, or => [ storno => 0, storno => undef ] ]) if $type eq 'invoice';
17   return (and => [ invoice => 1, amount  => { lt => 0 }, or => [ storno => 0, storno => undef ] ]) if $type eq 'credit_note';
18   return (and => [ invoice => 1, amount  => { lt => 0 },         storno => 1                    ]) if $type =~ m/(?:invoice_)?storno/;
19   return (and => [ invoice => 1, amount  => { ge => 0 },         storno => 1                    ]) if $type eq 'credit_note_storno';
20
21   die "Unknown type $type";
22 }
23
24 1;