-package SL::Helper::Inventory::Allocation {
- my @attributes = qw(parts_id qty bin_id warehouse_id chargenumber bestbefore comment reserve_for_id reserve_for_table for_object_id);
- my %attributes = map { $_ => 1 } @attributes;
-
- for my $name (@attributes) {
- no strict 'refs';
- *{"SL::Helper::Inventory::Allocation::$name"} = sub { $_[0]{$name} };
- }
-
- sub new {
- my ($class, %params) = @_;
-
- Carp::croak("missing attribute $_") for grep { !exists $params{$_} } @attributes;
- Carp::croak("unknown attribute $_") for grep { !exists $attributes{$_} } keys %params;
- Carp::croak("$_ must be set") for grep { !$params{$_} } qw(parts_id qty bin_id);
- Carp::croak("$_ must be positive") for grep { !($params{$_} > 0) } qw(parts_id qty bin_id);
-
- bless { %params }, $class;
- }