Merge branch 'f-zugferd'
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 13 Mar 2020 13:54:52 +0000 (14:54 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 13 Mar 2020 13:54:52 +0000 (14:54 +0100)
SL/BackgroundJob/SelfTest.pm
SL/BackgroundJob/SelfTest/Transactions.pm
locale/de/all
templates/mail/self_test/status_mail.txt

index d341e64..b715f9e 100644 (file)
@@ -26,7 +26,7 @@ use Rose::Object::MakeMethods::Generic (
    'add_full_diag'  => { interface => 'add', hash_key => 'full_diag' },
   ],
   scalar => [
-   qw(diag tester config aggreg),
+   qw(diag tester config aggreg module_nr),
   ],
 );
 
@@ -88,6 +88,9 @@ sub run_module {
   $module =~ s/[^\w:]//g;
   $module = "SL::BackgroundJob::SelfTest::$module";
 
+  # increase module nr
+  $self->module_nr(($self->module_nr || 0) + 1);
+
   # try to load module;
   (my $file = $module) =~ s|::|/|g;
   eval {
@@ -103,7 +106,7 @@ sub run_module {
   } or $self->add_errors($::locale->text('Could not load class #1, #2', $module, $@)) && return;
 
   $self->add_full_diag($output);
-  $self->{diag_per_module}{$module} = $output;
+  $self->{diag_per_module}{$self->module_nr . ': ' . $module} = $output;
 
   my $parser = TAP::Parser->new({ tap => $output});
   $parser->run;
@@ -188,14 +191,4 @@ SL::BackgroundJob::SelfTest - pluggable self testing
   use SL::BackgroundJob::SelfTest;
   SL::BackgroundJob::SelfTest->new->run;;
 
-=head1 DESCRIPTION
-
-
-
-=head1 FUNCTIONS
-
-=head1 BUGS
-
-=head1 AUTHOR
-
 =cut
index 3eeb57f..9eda722 100644 (file)
@@ -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 {
@@ -801,10 +814,6 @@ SL::BackgroundJob::SelfTest::Transactions - base tests
 
 Several tests for data integrity.
 
-=head1 FUNCTIONS
-
-=head1 BUGS
-
 =head1 AUTHOR
 
 G. Richardson E<lt>information@richardson-bueren.deE<gt>
@@ -812,4 +821,3 @@ Jan Büren E<lt>information@richardson-bueren.deE<gt>
 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>
 
 =cut
-
index 6599fdb..9628145 100755 (executable)
@@ -79,7 +79,7 @@ $self->{texts} = {
   'AP transaction posted.'      => 'Kreditorenbuchung verbucht.',
   'AP transactions changeable'  => 'Änderbarkeit von Kreditorenbuchungen',
   'AP transactions with sales taxkeys and/or AR transactions with input taxkeys' => 'Kreditorenbuchungen mit Umsatzsteuer-Steuerschlüsseln und/oder Debitorenbuchungen mit Vorsteuer-Steuerschlüsseln',
-  'AP/AR Aging & Journal'       => 'Offene Forderungen/Verbindunglichkeiten & Buchungsjournal',
+  'AP/AR Aging & Journal'       => 'Offene Forderungen/Verbindlichkeiten & Buchungsjournal',
   'AR'                          => 'Verkauf',
   'AR Aging'                    => 'Offene Forderungen',
   'AR Transaction'              => 'Debitorenbuchung',
index ac83cce..c2d8f99 100644 (file)
@@ -15,7 +15,7 @@ Result: [% SELF.aggreg.get_status %]
 Full report:
 ------------
 
-[% FOREACH module = SELF.diag_per_module.keys %]
+[% FOREACH module = SELF.diag_per_module.keys.sort %]
 Module: [% module %]
 --------------------