1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
4 package SL::DB::Manager::PriceRuleItem;
8 use SL::DB::Helper::Manager;
9 use base qw(SL::DB::Helper::Manager);
11 sub object_class { 'SL::DB::PriceRuleItem' }
13 __PACKAGE__->make_manager_methods;
15 use SL::Locale::String qw(t8);
18 customer vendor business partsgroup qty reqdate pricegroup
22 'num' => { eq => '=', lt => '<', gt => '>' },
23 'date' => { eq => '=', lt => '<', gt => '>' },
27 'customer' => { description => t8('Customer'), customer => 1, vendor => 0, data_type => 'int', data => sub { $_[0]->customer->id }, },
28 'vendor' => { description => t8('Vendor'), customer => 0, vendor => 1, data_type => 'int', data => sub { $_[0]->vendor->id }, },
29 'business' => { description => t8('Type of Business'), customer => 1, vendor => 1, data_type => 'int', data => sub { $_[0]->customervendor->business_id }, },
30 'reqdate' => { description => t8('Reqdate'), customer => 1, vendor => 1, data_type => 'date', data => sub { $_[0]->reqdate }, ops => 'date' },
31 'pricegroup' => { description => t8('Pricegroup'), customer => 1, vendor => 1, data_type => 'int', data => sub { $_[1]->pricegroup_id }, },
32 'partsgroup' => { description => t8('Group'), customer => 1, vendor => 1, data_type => 'int', data => sub { $_[1]->part->partsgroup_id }, },
33 'qty' => { description => t8('Qty'), customer => 1, vendor => 1, data_type => 'num', data => sub { $_[1]->qty }, ops => 'num' },
36 sub not_matching_sql_and_values {
37 my ($class, %params) = @_;
39 die 'must be called with a customer/vendor type' unless $params{type};
41 my (@tokens, @values);
43 for my $type (@types) {
44 my $def = $types{$type};
45 next unless $def->{$params{type}};
48 my $ops = $ops{$def->{ops}};
52 push @sub_tokens, "op = '$_' AND NOT value_$def->{data_type} $ops->{$_} ?";
53 push @values, $def->{data};
56 push @tokens, "type = '$type' AND " . join ' OR ', map "($_)", @sub_tokens;
58 push @tokens, "type = '$type' AND NOT value_$def->{data_type} = ?";
59 push @values, $def->{data};
63 return join(' OR ', map "($_)", @tokens), @values;
67 my ($class, $vc) = @_;
69 [ map { [ $_, $types{$_}{description} ] } grep { $types{$_}{$vc} } map { $_ } @types ];