From 4d25027290ffb49359567b29530bce27035dccc9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Wed, 20 Feb 2019 11:29:30 +0100 Subject: [PATCH] SL::DB::BankTransactions(linked_invoices): Returns an array of record objects MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 3 ++- SL/DB/BankTransaction.pm | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/SL/Controller/BankTransaction.pm b/SL/Controller/BankTransaction.pm index 3d98e9fec..3606fa600 100644 --- a/SL/Controller/BankTransaction.pm +++ b/SL/Controller/BankTransaction.pm @@ -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 } }, diff --git a/SL/DB/BankTransaction.pm b/SL/DB/BankTransaction.pm index 06302bb01..cdc181881 100644 --- a/SL/DB/BankTransaction.pm +++ b/SL/DB/BankTransaction.pm @@ -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 -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. -- 2.20.1