Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d1c60741

Von Kivitendo Admin vor fast 10 Jahren hinzugefügt

  • ID d1c607417e61a546f042ee80513741122faaca9b
  • Vorgänger 1a8f793c
  • Nachfolger 048f2af4

ar, ap oder gl Objekt eines acc_trans Objects holen

neue Methode record in SL::DB::AccTransaction

Unterschiede anzeigen:

SL/DB/AccTransaction.pm
12 12
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
13 13
__PACKAGE__->meta->make_manager_class;
14 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
};
15 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

Auch abrufbar als: Unified diff