From ce4ec1a8be52421b7b3fed991ec9539523e482a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 28 Mar 2018 11:31:22 +0200 Subject: [PATCH] =?utf8?q?BankTransaction::get=5Fagreement=5Fwith=5Finvoic?= =?utf8?q?e=20-=20sepa=5Fexport=5Fitems=20optional=20=C3=BCbergeben?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/BankTransaction.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SL/DB/BankTransaction.pm b/SL/DB/BankTransaction.pm index e4cf67cd3..511c15f07 100644 --- a/SL/DB/BankTransaction.pm +++ b/SL/DB/BankTransaction.pm @@ -53,7 +53,7 @@ sub is_batch_transaction { sub get_agreement_with_invoice { - my ($self, $invoice) = @_; + my ($self, $invoice, %params) = @_; carp "get_agreement_with_invoice needs an invoice object as its first argument" unless ref($invoice) eq 'SL::DB::Invoice' or ref($invoice) eq 'SL::DB::PurchaseInvoice'; @@ -221,7 +221,10 @@ sub get_agreement_with_invoice { } # if there is exactly one non-executed sepa_export_item for the invoice - if ( my $seis = $invoice->find_sepa_export_items({ executed => 0 }) ) { + my $seis = $params{sepa_export_items} + ? [ grep { $invoice->id == ($invoice->is_sales ? $_->ar_id : $_->ap_id) } @{ $params{sepa_export_items} } ] + : $invoice->find_sepa_export_items({ executed => 0 }); + if ($seis) { if (scalar @$seis == 1) { my $sei = $seis->[0]; -- 2.20.1