use strict;
use List::Util qw(sum);
-use SL::AM;
use SL::DB::MetaSetup::OrderItem;
use SL::DB::Manager::OrderItem;
sub_module => 'orderitems',
cvars_alias => 1,
overloads => {
- parts_id => 'SL::DB::Part',
+ parts_id => {
+ class => 'SL::DB::Part',
+ module => 'IC',
+ }
},
);
__PACKAGE__->meta->add_relationship(
unit_obj => {
- type => 'one to one',
+ type => 'many to one',
class => 'SL::DB::Unit',
column_map => { unit => 'name' },
},
my $d_orders = $self->order->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrder');
my @doi = grep { $_->parts_id == $self->parts_id } map { $_->orderitems } @$d_orders;
+ require SL::AM;
return sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi);
}
-sub part {
- # canonial alias for parts.
- goto &parts;
-}
-
-sub order {
- # canonial alias for trans.
- goto &trans;
-}
-
1;