X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FManager%2FPart.pm;h=6c781a9fee2c4a4c626a244dd4785d6f28f90366;hb=e36b34d301ba80bbb8f9ba2fe33608e153f8f71c;hp=e6aca1f712d061be27634f866a30a7476322f1dd;hpb=762f8a97338181a9ecb01c20eed52215b470212d;p=kivitendo-erp.git diff --git a/SL/DB/Manager/Part.pm b/SL/DB/Manager/Part.pm index e6aca1f71..6c781a9fe 100644 --- a/SL/DB/Manager/Part.pm +++ b/SL/DB/Manager/Part.pm @@ -7,32 +7,36 @@ use base qw(SL::DB::Helper::Manager); use Carp; use SL::DBUtils; +use SL::MoreCommon qw(listify); sub object_class { 'SL::DB::Part' } __PACKAGE__->make_manager_methods; sub type_filter { - my $class = shift; - my $type = lc(shift || ''); - - if ($type =~ m/^part/) { - return (and => [ or => [ assembly => 0, assembly => undef ], - '!inventory_accno_id' => 0, - '!inventory_accno_id' => undef, - ]); - - } elsif ($type =~ m/^service/) { - return (and => [ or => [ assembly => 0, assembly => undef ], - or => [ inventory_accno_id => 0, inventory_accno_id => undef ], - ]); - - } elsif ($type =~ m/^assembl/) { - return (assembly => 1); - + my ($class, $type) = @_; + + return () unless $type; + + my @types = listify($type); + my @filter; + + for my $type (@types) { + if ($type =~ m/^part/) { + push @filter, (and => [ or => [ assembly => 0, assembly => undef ], + '!inventory_accno_id' => 0, + '!inventory_accno_id' => undef, + ]); + } elsif ($type =~ m/^service/) { + push @filter, (and => [ or => [ assembly => 0, assembly => undef ], + or => [ inventory_accno_id => 0, inventory_accno_id => undef ], + ]); + } elsif ($type =~ m/^assembl/) { + push @filter, (assembly => 1); + } } - return (); + return @filter ? (or => \@filter) : (); } sub get_ordered_qty { @@ -61,3 +65,47 @@ SQL } 1; +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::DB::Manager::Part - RDBO manager for the C table + +=head1 FUNCTIONS + +=over 4 + +=item C + +For each of the given part IDs the ordered quantity is +calculated. This is done by summing over all open purchase orders. + +Returns a hash with the part IDs being the keys and the ordered +quantities being the values. + +=item C + +Constructs a partial filter for matching any of the article types +given with C<@types>. The returned partial filter is suitable for a +Rose manager query. + +Each type can be either 'C', 'C' or 'C' +(their plurals are recognized as well). If multiple types are given +then they're combined with C. + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Sven Schöling Es.schoeling@linet-services.deE, +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut