From 144e96c1d8d6c966b9f6b3665f5a828b5ad44dc5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Thu, 1 Mar 2018 12:09:00 +0100 Subject: [PATCH] SelfTests/Transactions.pm erweitert MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Da beim Löschen von Zahlungen mittlerweile auch kaskadieren die reconciliation_links gelöscht werden, können verwaiste abgeglichen Bankbewegungen entstehen. Entsprechend Testfall ergänzt. --- SL/BackgroundJob/SelfTest/Transactions.pm | 26 ++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/SL/BackgroundJob/SelfTest/Transactions.pm b/SL/BackgroundJob/SelfTest/Transactions.pm index a05ecd741..d1842c3ee 100644 --- a/SL/BackgroundJob/SelfTest/Transactions.pm +++ b/SL/BackgroundJob/SelfTest/Transactions.pm @@ -15,7 +15,7 @@ sub run { $self->_setup; - $self->tester->plan(tests => 24); + $self->tester->plan(tests => 25); $self->check_konten_mit_saldo_nicht_in_guv; $self->check_bilanzkonten_mit_pos_eur; @@ -41,6 +41,7 @@ sub run { $self->check_ar_paid_acc_trans; $self->check_ap_paid_acc_trans; $self->check_zero_amount_paid_but_datepaid_exists; + $self->check_orphaned_reconciliated_links; } sub _setup { @@ -621,6 +622,29 @@ sub check_zero_amount_paid_but_datepaid_exists { } } +sub check_orphaned_reconciliated_links { + my ($self) = @_; + + my $query = qq| + SELECT purpose from bank_transactions + WHERE cleared is true + AND id not in (SELECT bank_transaction_id from reconciliation_links) + AND transdate >= ? AND transdate <= ?|; + + my $bt_cleared_no_link = selectall_hashref_query($::form, $self->dbh, $query, $self->fromdate, $self->todate); + + if ( scalar @{ $bt_cleared_no_link } > 0 ) { + $self->tester->ok(0, "Verwaiste abgeglichene Bankbewegungen gefunden. Bei folgenden Bankbewegungen ist die abgleichende Verknüpfung gelöscht worden:"); + + for my $bt_orphaned (@{ $bt_cleared_no_link }) { + $self->tester->diag("Verwendungszweck: $bt_orphaned->{purpose}"); + } + } else { + $self->tester->ok(1, "Keine verwaisten Einträge in abgeglichenen Bankbewegungen."); + } +} + + 1; __END__ -- 2.20.1