From 338ffe02d70c3e9897f114998f534d4fc0bb2b65 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Tue, 15 Aug 2017 10:27:48 +0200 Subject: [PATCH] Optimierung SEPA-Erkennung #277 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 23 : 11 England gegen Pfalz, überzeugt mich --- SL/DB/BankTransaction.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/SL/DB/BankTransaction.pm b/SL/DB/BankTransaction.pm index 1d8705e9a..a63deb49a 100644 --- a/SL/DB/BankTransaction.pm +++ b/SL/DB/BankTransaction.pm @@ -221,11 +221,15 @@ sub get_agreement_with_invoice { }; # if there is exactly one non-executed sepa_export_item for the invoice - if ( my $seis = $invoice->{sepa_export_item} ) { - if (scalar @$seis == 1) { + if ( my $seis = $invoice->find_sepa_export_items({ executed => 0 }) ) { + if (scalar @$seis == 1) { my $sei = $seis->[0]; - if ( abs(abs($self->amount) - abs($sei->amount)) < 0.01 ) { + # test for amount and id matching only, sepa transfer date and bank + # transaction date needn't match + my $arap = $invoice->is_sales ? 'ar' : 'ap'; + + if (abs($self->amount) == ($sei->amount) && $invoice->id == $sei->arap_id) { $agreement += $points{sepa_export_item}; $rule_matches .= 'sepa_export_item(' . $points{'sepa_export_item'} . ') '; } -- 2.20.1