053a30adc20e80b8edbe2c49532eb3ee599d0ed1
[kivitendo-erp.git] / SL / DB / AccTransaction.pm
1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
3
4 package SL::DB::AccTransaction;
5
6 use strict;
7
8 use SL::DB::MetaSetup::AccTransaction;
9
10 __PACKAGE__->meta->initialize;
11
12 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
13 __PACKAGE__->meta->make_manager_class;
14
15 sub record {
16   my ($self) = @_;
17
18   my @classes = qw(Invoice PurchaseInvoice GLTransaction);
19
20   foreach my $class ( @classes ) {
21     $class = 'SL::DB::' . $class;
22     my $record = $class->new(id => $self->trans_id);
23     return $record if $record->load(speculative => 1);
24   };
25
26 };
27 1;
28 __END__
29
30 =pod
31
32 =encoding utf8
33
34 =head1 NAME
35
36 SL::DB::AccTransaction: Rose model for transactions (table "acc_trans")
37
38 =head1 FUNCTIONS
39
40 =over 4
41
42 =item C<record>
43
44 Returns the ar, ap or gl object of the current acc_trans object.
45
46 Example:
47   my $acc_trans = SL::DB::Manager::AccTransaction->find_by( trans_id => '427' );
48   my $record = $acc_trans->record;
49
50 Each acc_trans entry is associated with an ar, ap or gl record. If we only have
51 an acc_trans object, and we want to find out which kind of record it belongs
52 to, we have to look for its trans_id in the tables ar, ap and gl. C<record>
53 does this for you and returns an Invoice, PurchaseInvoice or GLTransaction
54 object.
55
56 We use the Rose::DB::Object load function with the C<speculative> parameter for
57 each record type, which returns true if the load was successful, so we don't
58 bother to check the ref of the object.
59
60 =back
61
62 =head1 BUGS
63
64 Nothing here yet.
65
66 =head1 AUTHOR
67
68 G. Richardson E<lt>information@kivitendo-premium.deE<gt>
69
70 =cut