kivitendo/SL/DB/Warehouse.pm @ 4b1666b7
82515b2d | Sven Schöling | package SL::DB::Warehouse;
|
||
use strict;
|
||||
use SL::DB::MetaSetup::Warehouse;
|
||||
91b948e4 | Moritz Bunkus | use SL::DB::Manager::Warehouse;
|
||
117fefac | Moritz Bunkus | use SL::DB::Helper::ActsAsList;
|
||
2914c199 | Sven Schöling | |||
82515b2d | Sven Schöling | __PACKAGE__->meta->add_relationship(
|
||
bins => {
|
||||
type => 'one to many',
|
||||
class => 'SL::DB::Bin',
|
||||
column_map => { id => 'warehouse_id' },
|
||||
}
|
||||
);
|
||||
__PACKAGE__->meta->initialize;
|
||||
91b948e4 | Moritz Bunkus | sub bins_sorted {
|
||
return [ sort { $a->id <=> $b->id } @{ shift()->bins || [] } ];
|
||||
}
|
||||
82515b2d | Sven Schöling | sub first_bin {
|
||
91b948e4 | Moritz Bunkus | return shift()->bins_sorted->[0];
|
||
82515b2d | Sven Schöling | }
|
||
1;
|