Pflichtenheft: Zugriff auf nicht vorhandenes »visible_item« verhindern
[kivitendo-erp.git] / SL / DB / InvoiceItem.pm
1 package SL::DB::InvoiceItem;
2
3 use strict;
4
5 use SL::DB::MetaSetup::InvoiceItem;
6 use SL::DB::Helper::ActsAsList;
7 use SL::DB::Helper::LinkedRecords;
8 use SL::DB::Helper::RecordItem;
9 use SL::DB::Helper::CustomVariables (
10   sub_module  => 'invoice',
11   cvars_alias => 1,
12   overloads   => {
13     parts_id => {
14      class => 'SL::DB::Part',
15      module => 'IC',
16     },
17   },
18 );
19
20 __PACKAGE__->meta->make_manager_class;
21
22 __PACKAGE__->configure_acts_as_list(group_by => [qw(trans_id)]);
23
24 __PACKAGE__->meta->add_relationships(
25   invoice          => {
26     type           => 'one to one',
27     class          => 'SL::DB::Invoice',
28     column_map     => { trans_id => 'id' },
29   },
30
31   purchase_invoice => {
32     type           => 'one to one',
33     class          => 'SL::DB::PurchaseInvoice',
34     column_map     => { trans_id => 'id' },
35   },
36 );
37
38 __PACKAGE__->meta->initialize;
39
40 sub record {
41   my ($self) = @_;
42
43   return $self->invoice          if $self->invoice;
44   return $self->purchase_invoice if $self->purchase_invoice;
45   return;
46 };
47
48 1;