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.
4 package SL::DB::AccTransaction;
8 use SL::DB::MetaSetup::AccTransaction;
10 use SL::DB::GLTransaction;
11 require SL::DB::Invoice;
12 require SL::DB::PurchaseInvoice;
14 __PACKAGE__->meta->add_relationship(
16 type => 'many to one',
17 class => 'SL::DB::Invoice',
18 column_map => { trans_id => 'id' },
21 type => 'many to one',
22 class => 'SL::DB::PurchaseInvoice',
23 column_map => { trans_id => 'id' },
26 type => 'many to one',
27 class => 'SL::DB::GLTransaction',
28 column_map => { trans_id => 'id' },
32 __PACKAGE__->meta->initialize;
34 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
35 __PACKAGE__->meta->make_manager_class;
40 my @classes = qw(Invoice PurchaseInvoice GLTransaction);
42 foreach my $class ( @classes ) {
43 $class = 'SL::DB::' . $class;
44 my $record = $class->new(id => $self->trans_id);
45 return $record if $record->load(speculative => 1);
53 my $transaction = SL::DB::Manager::GLTransaction->find_by(id => $self->trans_id);
54 $transaction = SL::DB::Manager::Invoice->find_by(id => $self->trans_id) if not defined $transaction;
55 $transaction = SL::DB::Manager::PurchaseInvoice->find_by(id => $self->trans_id) if not defined $transaction;
69 SL::DB::AccTransaction: Rose model for transactions (table "acc_trans")
77 Returns the ar, ap or gl object of the current acc_trans object.
80 my $acc_trans = SL::DB::Manager::AccTransaction->find_by( trans_id => '427' );
81 my $record = $acc_trans->record;
83 Each acc_trans entry is associated with an ar, ap or gl record. If we only have
84 an acc_trans object, and we want to find out which kind of record it belongs
85 to, we have to look for its trans_id in the tables ar, ap and gl. C<record>
86 does this for you and returns an Invoice, PurchaseInvoice or GLTransaction
89 We use the Rose::DB::Object load function with the C<speculative> parameter for
90 each record type, which returns true if the load was successful, so we don't
91 bother to check the ref of the object.
101 G. Richardson E<lt>information@kivitendo-premium.deE<gt>