X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FBackgroundJob%2FSelfTest%2FTransactions.pm;h=ab145ceceb2bfb156d6d233eba015e54737fac12;hb=2f318813a8d22ef9ddd2de7a454b6264d7ba4024;hp=3eeb57f0926024d3d464cf49996d7cbeeeef21e3;hpb=644b730bf07a0187ea05439bfd36b4e75fad2a3d;p=kivitendo-erp.git diff --git a/SL/BackgroundJob/SelfTest/Transactions.pm b/SL/BackgroundJob/SelfTest/Transactions.pm index 3eeb57f09..ab145cece 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 => 32); + $self->tester->plan(tests => 34); $self->check_konten_mit_saldo_nicht_in_guv; $self->check_bilanzkonten_mit_pos_eur; @@ -208,22 +208,35 @@ sub check_invnumbers_unique { sub check_summe_stornobuchungen { my ($self) = @_; - my $query = qq| - SELECT sum(amount) from ar a WHERE a.id IN - (SELECT id from ap where storno is true - AND a.transdate >= ? and a.transdate <= ?)|; - my ($summe_stornobuchungen_ar) = selectfirst_array_query($::form, $self->dbh, $query, $self->fromdate, $self->todate); - - $query = qq| - SELECT sum(amount) from ap a WHERE a.id IN - (SELECT id from ap where storno is true - AND a.transdate >= ? and a.transdate <= ?)|; - my ($summe_stornobuchungen_ap) = selectfirst_array_query($::form, $self->dbh, $query, $self->fromdate, $self->todate); - - $self->tester->ok($summe_stornobuchungen_ap == 0, 'Summe aller Einkaufsrechnungen (stornos + stornierte) soll 0 sein'); - $self->tester->ok($summe_stornobuchungen_ar == 0, 'Summe aller Verkaufsrechnungen (stornos + stornierte) soll 0 sein'); - $self->tester->diag("Summe Verkaufsrechnungen (ar): $summe_stornobuchungen_ar") if $summe_stornobuchungen_ar; - $self->tester->diag("Summe Einkaufsrechnungen (ap): $summe_stornobuchungen_ap") if $summe_stornobuchungen_ap; + my %sums_canceled; + my %sums_storno; + foreach my $table (qw(ar ap)) { + # check invoices canceled (stornoed) in consideration period (corresponding stornos do not have to be in this period) + my $query = qq| + SELECT sum(amount) FROM $table WHERE id IN ( + SELECT id FROM $table WHERE storno IS TRUE AND storno_id IS NULL AND transdate >= ? AND transdate <= ? + UNION + SELECT id FROM $table WHERE storno IS TRUE AND storno_id IS NOT NULL AND storno_id IN + (SELECT id FROM $table WHERE storno IS TRUE AND storno_id IS NULL AND transdate >= ? AND transdate <= ?) + )|; + ($sums_canceled{$table}) = selectfirst_array_query($::form, $self->dbh, $query, $self->fromdate, $self->todate, $self->fromdate, $self->todate); + + # check storno invoices in consideration period (corresponding canceled (stornoed) invoices do not have to be in this period) + $query = qq| + SELECT sum(amount) FROM $table WHERE id IN ( + SELECT storno_id FROM $table WHERE storno IS TRUE AND storno_id IS NOT NULL AND transdate >= ? AND transdate <= ? + UNION + SELECT id FROM $table WHERE storno IS TRUE AND storno_id IS NOT NULL AND transdate >= ? AND transdate <= ? + )|; + ($sums_storno{$table}) = selectfirst_array_query($::form, $self->dbh, $query, $self->fromdate, $self->todate, $self->fromdate, $self->todate); + + my $text_rg = ($table eq 'ar') ? 'Verkaufsrechnungen' : 'Einkaufsrechnungen'; + + $self->tester->ok($sums_canceled{$table} == 0, "Summe aller $text_rg (stornos + stornierte) soll 0 sein (für stornierte Rechnungen)"); + $self->tester->ok($sums_storno {$table} == 0, "Summe aller $text_rg (stornos + stornierte) soll 0 sein (für Storno-Rechnungen)"); + $self->tester->diag("Summe $text_rg ($table) (für stornierte Rechnungen) : " . $sums_canceled{$table}) if $sums_canceled{$table} != 0; + $self->tester->diag("Summe $text_rg ($table) (für Storno-Rechnungen) : " . $sums_storno {$table}) if $sums_storno {$table} != 0; + } } sub check_ar_paid { @@ -459,6 +472,7 @@ sub check_ar_acc_trans_amount { from acc_trans ac left join ar on (ac.trans_id = ar.id) WHERE ac.chart_link like 'AR_amount%' AND ac.transdate >= ? AND ac.transdate <= ? + AND ar.type = 'invoice' group by invnumber,netamount having sum(ac.amount) <> ar.netamount|; my $ar_amount_not_ac_amount = selectall_hashref_query($::form, $self->dbh, $query, $self->fromdate, $self->todate); @@ -801,10 +815,6 @@ SL::BackgroundJob::SelfTest::Transactions - base tests Several tests for data integrity. -=head1 FUNCTIONS - -=head1 BUGS - =head1 AUTHOR G. Richardson Einformation@richardson-bueren.deE @@ -812,4 +822,3 @@ Jan Büren Einformation@richardson-bueren.deE Sven Schoeling Es.schoeling@linet-services.deE =cut -