Merge branch 'master' of github.com:kivitendo/kivitendo-erp
[kivitendo-erp.git] / SL / DB / Warehouse.pm
1 package SL::DB::Warehouse;
2
3 use strict;
4
5 use SL::DB::MetaSetup::Warehouse;
6 use SL::DB::Manager::Warehouse;
7 use SL::DB::Helper::ActsAsList;
8
9 __PACKAGE__->meta->add_relationship(
10   bins => {
11     type         => 'one to many',
12     class        => 'SL::DB::Bin',
13     column_map   => { id => 'warehouse_id' },
14   }
15 );
16
17 __PACKAGE__->meta->initialize;
18
19 sub bins_sorted {
20   return [ sort { $a->id <=> $b->id } @{ shift()->bins || [] } ];
21 }
22
23 sub first_bin {
24   return shift()->bins_sorted->[0];
25 }
26
27 1;