From a695cc30eec6422260f0e9a9b00bbc209649d212 Mon Sep 17 00:00:00 2001 From: "Martin Helmling martin.helmling@octosoft.eu" Date: Wed, 31 Jan 2018 08:24:33 +0100 Subject: [PATCH] Bankimport: Rundungsproblem beim Vergleich Rechnungsbetrag - Kontobetrag MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Durch explizites Runden konnte die perl Floatingpoint Arithmetik nicht überzeugt werden, deshalb werden nun die Formatierten Strings der Beträge noch zusätzlich verglichen. Hiermit wird der "exact_match" beim Vergleich von z.B. 3456,28 und 3456,29 nicht mehr gefunden behebt teilweise Issue #201 --- SL/DB/BankTransaction.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/SL/DB/BankTransaction.pm b/SL/DB/BankTransaction.pm index b41660645..eee6e000e 100644 --- a/SL/DB/BankTransaction.pm +++ b/SL/DB/BankTransaction.pm @@ -111,18 +111,27 @@ sub get_agreement_with_invoice { $invoice->{datediff} = $datediff; # compare amount - if (abs(abs($invoice->amount) - abs($self->amount)) < 0.01) { + if (abs(abs($invoice->amount) - abs($self->amount)) < 0.01 && + $::form->format_amount(\%::myconfig,abs($invoice->amount),2) eq + $::form->format_amount(\%::myconfig,abs($self->amount),2) + ) { $agreement += $points{exact_amount}; $rule_matches .= 'exact_amount(' . $points{'exact_amount'} . ') '; } # compare open amount, preventing double points when open amount = invoice amount - if ( $invoice->amount != $invoice->open_amount && abs(abs($invoice->open_amount) - abs($self->amount)) < 0.01) { + if ( $invoice->amount != $invoice->open_amount && abs(abs($invoice->open_amount) - abs($self->amount)) < 0.01 && + $::form->format_amount(\%::myconfig,abs($invoice->amount_less_skonto),2) eq + $::form->format_amount(\%::myconfig,abs($self->amount),2) + ) { $agreement += $points{exact_open_amount}; $rule_matches .= 'exact_open_amount(' . $points{'exact_open_amount'} . ') '; } - if ( $invoice->skonto_date && abs(abs($invoice->amount_less_skonto) - abs($self->amount)) < 0.01) { + if ( $invoice->skonto_date && abs(abs($invoice->amount_less_skonto) - abs($self->amount)) < 0.01 && + $::form->format_amount(\%::myconfig,abs($invoice->amount_less_skonto),2) eq + $::form->format_amount(\%::myconfig,abs($self->amount),2) + ) { $agreement += $points{skonto_exact_amount}; $rule_matches .= 'skonto_exact_amount(' . $points{'skonto_exact_amount'} . ') '; $invoice->{skonto_type} = 'with_skonto_pt'; -- 2.20.1