X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FDB%2FManager%2FInvoice.pm;h=5dc943f85dd39355d610718ae79f9a62de4838d8;hb=b74d1c197c8365b14587838d999244274de12884;hp=c3a9a7bb4eeba79ce143f7d98cb5eef3a8c794fb;hpb=624c53dc0cb5056d2c259aec6f815e69b8313ae0;p=kivitendo-erp.git diff --git a/SL/DB/Manager/Invoice.pm b/SL/DB/Manager/Invoice.pm index c3a9a7bb4..5dc943f85 100644 --- a/SL/DB/Manager/Invoice.pm +++ b/SL/DB/Manager/Invoice.pm @@ -2,7 +2,10 @@ package SL::DB::Manager::Invoice; use strict; -use base qw(SL::DB::Helper::Manager); +use parent qw(SL::DB::Helper::Manager); + +use SL::DB::Helper::Paginated; +use SL::DB::Helper::Sorted; sub object_class { 'SL::DB::Invoice' } @@ -13,12 +16,38 @@ sub type_filter { 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 => { ge => 0 }, or => [ storno => 0, storno => undef ] ]) if $type =~ m/^(?:sales_)?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'; + return (amount => {gt => 'paid'}) if $type eq 'open'; die "Unknown type $type"; } +sub _sort_spec { + return ( + default => [ 'transdate', 1 ], + nulls => { + transaction_description => 'FIRST', + customer_name => 'FIRST', + default => 'LAST', + }, + columns => { + SIMPLE => 'ALL', + customer => 'lower(customer.name)', + globalprojectnumber => 'lower(globalproject.projectnumber)', + + # Bug in Rose::DB::Object: the next should be + # "globalproject.project_type.description". This workaround will + # only work if no other table with "project_type" is visible in + # the current query + globalproject_type => 'lower(project_type.description)', + + map { ( $_ => "lower(ar.$_)" ) } qw(invnumber ordnumber quonumber cusordnumber shippingpoint shipvia notes intnotes transaction_description), + }); +} + +sub default_objects_per_page { 40 } + 1;