X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FBackgroundJob%2FSelfTest%2FTransactions.pm;h=b64966a74c7ef0c678da218d9f599a6ff57d54c4;hb=8012fdcb36e7282586e1f38698461921765fd6e6;hp=a05ecd741f572596930073008e9a9b9aab9cdc35;hpb=d3bb5fcb76634f72b0e5dc7b639d8d32cba17a4d;p=kivitendo-erp.git diff --git a/SL/BackgroundJob/SelfTest/Transactions.pm b/SL/BackgroundJob/SelfTest/Transactions.pm index a05ecd741..b64966a74 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 { @@ -478,7 +479,7 @@ sub check_ap_acc_trans_amount { my $query = qq| select sum(ac.amount) as amount, ap.invnumber,ap.netamount from acc_trans ac left join ap on (ac.trans_id = ap.id) - WHERE ac.chart_link like '%AP_amount%' + WHERE ac.chart_link like '%AP_amount%' OR ac.chart_link like '%IC_cogs%' AND ac.transdate >= ? AND ac.transdate <= ? group by invnumber,trans_id,netamount having sum(ac.amount) <> ap.netamount*-1|; @@ -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__