use SL::Locale::String qw(t8);
my @types = qw(
- customer vendor business partsgroup qty reqdate pricegroup
+ part customer vendor business partsgroup qty reqdate pricegroup
);
my %ops = (
'vendor' => { description => t8('Vendor'), customer => 0, vendor => 1, data_type => 'int', data => sub { $_[0]->vendor->id }, },
'business' => { description => t8('Type of Business'), customer => 1, vendor => 1, data_type => 'int', data => sub { $_[0]->customervendor->business_id }, exclude_nulls => 1 },
'reqdate' => { description => t8('Reqdate'), customer => 1, vendor => 1, data_type => 'date', data => sub { $_[0]->reqdate }, ops => 'date' },
+ 'part' => { description => t8('Part'), customer => 1, vendor => 0, data_type => 'int', data => sub { $_[1]->part->id }, },
'pricegroup' => { description => t8('Pricegroup'), customer => 1, vendor => 1, data_type => 'int', data => sub { $_[1]->pricegroup_id }, exclude_nulls => 1 },
'partsgroup' => { description => t8('Group'), customer => 1, vendor => 1, data_type => 'int', data => sub { $_[1]->part->partsgroup_id }, exclude_nulls => 1 },
'qty' => { description => t8('Qty'), customer => 1, vendor => 1, data_type => 'num', data => sub { $_[1]->qty }, ops => 'num' },
sub match_partsgroup {
$_[0]->value_int == $_[1]{record_item}->parts->partsgroup_id;
}
+sub match_part {
+ $_[0]->value_int == $_[1]{record_item}->parts_id;
+}
sub match_qty {
if ($_[0]->op eq 'eq') {
return $_[0]->value_num == $_[1]{record_item}->qty
$_[0]->value_int == $_[1]{record_item}->customervendor->pricegroup_id;
}
+sub part {
+ require SL::DB::Part;
+ SL::DB::Part->load_cached($_[0]->value_int);
+}
sub customer {
require SL::DB::Customer;
SL::DB::Customer->load_cached($_[0]->value_int);
: $type eq 'business' ? t8('Type of Business') . ' ' . $self->business->displayable_name
: $type eq 'partsgroup' ? t8('Group') . ' ' . $self->partsgroup->displayable_name
: $type eq 'pricegroup' ? t8('Pricegroup') . ' ' . $self->pricegroup->displayable_name
+ : $type eq 'part' ? t8('Part') . ' ' . $self->part->long_description
: $type eq 'qty' ? (
$op eq 'eq' ? t8('Qty equals #1', $self->value_num_as_number)
: $op eq 'lt' ? t8('Qty less than #1', $self->value_num_as_number)
[% L.hidden_tag('price_rule.items[+].id', item.id) %]
[% L.hidden_tag('price_rule.items[].type', item.type) %]
[%- SWITCH item.type %]
+ [% CASE 'part' %]
+ [% 'Part' | $T8 %] [% 'is' | $T8 %] [% L.part_picker('price_rule.items[].value_int', item.part) %]
[% CASE 'customer' %]
[% 'Customer' | $T8 %] [% 'is' | $T8 %] [% L.customer_vendor_picker('price_rule.items[].value_int', item.customer, type='customer') %]
[% CASE 'vendor' %]