SL::DB::BankTransactions(linked_invoices): Returns an array of record objects
authorJan Büren <jan@kivitendo.de>
Wed, 20 Feb 2019 10:29:30 +0000 (11:29 +0100)
committerJan Büren <jan@kivitendo.de>
Fri, 1 Mar 2019 15:10:41 +0000 (16:10 +0100)
Anstatt nur die Namen der Belege werden jetzt die Beleg-Objekte
zurückgegeben. Einziger Aufruf der Methode beim ReportGenerator in
Controller::BankTransactions. Die Stelle entsprechend angepasst

SL/Controller/BankTransaction.pm
SL/DB/BankTransaction.pm

index 3d98e9f..3606fa6 100644 (file)
@@ -797,7 +797,8 @@ sub prepare_report {
                                align => 'right' },
     invoice_amount        => { sub   => sub { $_[0]->invoice_amount_as_number },
                                align => 'right' },
-    invoices              => { sub   => sub { $_[0]->linked_invoices } },
+    invoices              => { sub   => sub { my @invnumbers; for my $obj (@{ $_[0]->linked_invoices }) {
+                                                                next unless $obj; push @invnumbers, $obj->invnumber } return \@invnumbers } },
     currency              => { sub   => sub { $_[0]->currency->name } },
     purpose               => { },
     local_account_number  => { sub   => sub { $_[0]->local_bank_account->account_number } },
index 06302bb..cdc1818 100644 (file)
@@ -40,9 +40,9 @@ sub linked_invoices {
   my $record_links = SL::DB::Manager::RecordLink->get_all(where => [ from_table => 'bank_transactions', from_id => $self->id ]);
 
   foreach my $record_link (@{ $record_links }) {
-    push @linked_invoices, SL::DB::Manager::Invoice->find_by(id => $record_link->to_id)->invnumber         if $record_link->to_table eq 'ar';
-    push @linked_invoices, SL::DB::Manager::PurchaseInvoice->find_by(id => $record_link->to_id)->invnumber if $record_link->to_table eq 'ap';
-    push @linked_invoices, SL::DB::Manager::GLTransaction->find_by(id => $record_link->to_id)->reference   if $record_link->to_table eq 'gl';
+    push @linked_invoices, SL::DB::Manager::Invoice->find_by(id => $record_link->to_id)         if $record_link->to_table eq 'ar';
+    push @linked_invoices, SL::DB::Manager::PurchaseInvoice->find_by(id => $record_link->to_id) if $record_link->to_table eq 'ap';
+    push @linked_invoices, SL::DB::Manager::GLTransaction->find_by(id => $record_link->to_id)   if $record_link->to_table eq 'gl';
   }
 
   return [ @linked_invoices ];
@@ -331,7 +331,7 @@ Example:
 
 =item C<linked_invoices>
 
-Returns an array of record names (invoice number or gl reference)
+Returns an array of record objects (invoices, debit, credit or gl objects)
 which are linked for this bank transaction.
 
 Returns an empty array ref if no links are found.