From daaac66a83e3dbdcc910731a1695e7e59b9cbbc6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Thu, 18 Aug 2016 13:23:45 +0200 Subject: [PATCH] Weiteren Transaction-Selftest Falls ein datepaid im Nebenbuch gesetzt ist, so darf paid nicht auf 0 sein, wenn es keine Zahlungen in der acc_trans hierzu gibt. --- SL/BackgroundJob/SelfTest/Transactions.pm | 29 ++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/SL/BackgroundJob/SelfTest/Transactions.pm b/SL/BackgroundJob/SelfTest/Transactions.pm index 1f706e540..5900689b7 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 => 23); + $self->tester->plan(tests => 24); $self->check_konten_mit_saldo_nicht_in_guv; $self->check_bilanzkonten_mit_pos_eur; @@ -40,6 +40,7 @@ sub run { $self->check_bank_transactions_overpayments; $self->check_ar_paid_acc_trans; $self->check_ap_paid_acc_trans; + $self->check_zero_amount_paid_but_datepaid_exists; } sub _setup { @@ -592,6 +593,32 @@ sub check_ap_paid_acc_trans { } } +sub check_zero_amount_paid_but_datepaid_exists { + my ($self) = @_; + + my $query = qq|(SELECT invnumber,datepaid from ar where datepaid is NOT NULL AND paid = 0 + AND id not IN (select trans_id from acc_trans WHERE chart_link like '%paid%' AND acc_trans.trans_id = ar.id) + AND datepaid >= ? AND datepaid <= ?) + UNION + (SELECT invnumber,datepaid from ap where datepaid is NOT NULL AND paid = 0 + AND id not IN (select trans_id from acc_trans WHERE chart_link like '%paid%' AND acc_trans.trans_id = ap.id) + AND datepaid >= ? AND datepaid <= ?)|; + + my $datepaid_should_be_null = selectall_hashref_query($::form, $self->dbh, $query, + $self->fromdate, $self->todate, + $self->fromdate, $self->todate); + + if ( scalar @{ $datepaid_should_be_null } > 0 ) { + $self->tester->ok(0, "Folgende Rechnungen haben ein Bezahl-Datum, aber keinen Bezahl-Wert im Nebenbuch:"); + + for my $datepaid_should_be_null_nok (@{ $datepaid_should_be_null } ) { + $self->tester->diag("Rechnungsnummer: $datepaid_should_be_null_nok->{invnumber} + Bezahl-Datum: $datepaid_should_be_null_nok->{datepaid}"); + } + } else { + $self->tester->ok(1, "Hauptbuch Bezahl-Wert und Kreditoren-Nebenbuch-Bezahlwert stimmen überein."); + } +} 1; -- 2.20.1