1 package SL::DB::Manager::Order;
5 use parent qw(SL::DB::Helper::Manager);
7 use SL::DB::Helper::Paginated;
8 use SL::DB::Helper::Sorted;
9 use SL::DB::Helper::Filtered;
11 sub object_class { 'SL::DB::Order' }
13 __PACKAGE__->make_manager_methods;
15 __PACKAGE__->add_filter_specs(
17 my ($key, $value, $prefix) = @_;
18 return __PACKAGE__->type_filter($value, $prefix);
21 my ($key, $value, $prefix) = @_;
22 return or => [ map { $prefix . $_ => $value } qw(ordnumber quonumber customer.name vendor.name transaction_description) ]
28 my $type = lc(shift || '');
29 my $prefix = shift || '';
31 return (and => [ "!${prefix}customer_id" => undef, "${prefix}quotation" => 1 ]) if $type eq 'sales_quotation';
32 return (and => [ "!${prefix}vendor_id" => undef, "${prefix}quotation" => 1 ]) if $type eq 'request_quotation';
33 return (and => [ "!${prefix}customer_id" => undef, or => [ "${prefix}quotation" => 0, "${prefix}quotation" => undef ] ]) if $type eq 'sales_order';
34 return (and => [ "!${prefix}vendor_id" => undef, or => [ "${prefix}quotation" => 0, "${prefix}quotation" => undef ] ]) if $type eq 'purchase_order';
36 die "Unknown type $type";
41 default => [ 'transdate', 1 ],
43 transaction_description => 'FIRST',
44 customer_name => 'FIRST',
45 vendor_name => 'FIRST',
50 customer => 'lower(customer.name)',
51 vendor => 'lower(vendor.name)',
52 globalprojectnumber => 'lower(globalproject.projectnumber)',
54 # Bug in Rose::DB::Object: the next should be
55 # "globalproject.project_type.description". This workaround will
56 # only work if no other table with "project_type" is visible in
58 globalproject_type => 'lower(project_type.description)',
60 map { ( $_ => "lower(oe.$_)" ) } qw(ordnumber quonumber cusordnumber shippingpoint shipvia notes intnotes transaction_description),
64 sub default_objects_per_page { 40 }