use SL::DB::MetaSetup::PriceRuleItem;
use SL::DB::Manager::PriceRuleItem;
-use Rose::DB::Object::Helpers qw(clone_and_reset);
use SL::Locale::String qw(t8);
__PACKAGE__->meta->initialize;
$type eq 'customer' ? t8('Customer') . ' ' . $self->customer->displayable_name
: $type eq 'vendor' ? t8('Vendor') . ' ' . $self->vendor->displayable_name
: $type eq 'business' ? t8('Type of Business') . ' ' . $self->business->displayable_name
- : $type eq 'partsgroup' ? t8('Group') . ' ' . $self->partsgroup->displayable_name
+ : $type eq 'partsgroup' ? t8('Partsgroup') . ' ' . $self->partsgroup->displayable_name
: $type eq 'pricegroup' ? t8('Pricegroup') . ' ' . $self->pricegroup->displayable_name
- : $type eq 'part' ? t8('Part') . ' ' . $self->part->long_description
+ : $type eq 'part' ? t8('Part') . ' ' . $self->part->displayable_name
: $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)
: do { die "unknown type $type" }
}
+sub validate {
+ my ($self) = @_;
+
+ my @errors;
+ push @errors, t8('Rule for part must not be empty') if $self->type eq 'part' && !$self->value_int;
+ push @errors, t8('Rule for customer must not be empty') if $self->type eq 'customer' && !$self->value_int;
+ push @errors, t8('Rule for vendor must not be empty') if $self->type eq 'vendor' && !$self->value_int;
+
+ return @errors;
+}
+
1;