]> wagnertech.de Git - mfinanz.git/blobdiff - SL/BackgroundJob/SelfTest/Transactions.pm
TopQuickSearch: changelog Eintrag
[mfinanz.git] / SL / BackgroundJob / SelfTest / Transactions.pm
index 0333ec9b36588bf93be6c597ca77c2e62c1e21ae..5580ba6201c5c59f053575cfb8f4e6a51303b0d9 100644 (file)
@@ -1,4 +1,4 @@
-ackage SL::BackgroundJob::SelfTest::Transactions;
+package SL::BackgroundJob::SelfTest::Transactions;
 
 use utf8;
 use strict;
@@ -43,12 +43,8 @@ sub _setup {
   my ($self) = @_;
 
   # TODO FIXME calc dates better, unless this is wanted
-#  my $year =
-  #$self->fromdate(DateTime->new(day => 1, month => 1, year => DateTime->today->year));
-  #$self->todate($self->fromdate->clone->add(years => 1)->add(days => -1));
-  $self->fromdate(DateTime->new(day => 1, month => 1, year => 2015));
+  $self->fromdate(DateTime->new(day => 1, month => 1, year => DateTime->today->year));
   $self->todate($self->fromdate->clone->add(years => 1)->add(days => -1));
-  $main::lxdebug->message(0, 'hier und dort:' . $self->fromdate . ' mit ' . $self->todate);
   $self->dbh($::form->get_standard_dbh);
 }
 
@@ -140,9 +136,15 @@ sub check_verwaiste_invoice_eintraege {
   my ($self) = @_;
   my $query = qq|
      select * from invoice i
-      where trans_id not in (select id from ar union select id from ap order by id) |;
+      where trans_id not in (select id from ar WHERE ar.transdate >=? AND ar.transdate <=?
+                             UNION
+                             select id from ap WHERE ap.transdate >= ? and ap.transdate <= ?)
+      AND i.transdate >=? AND i.transdate <=?|;
+
+  my $verwaiste_invoice = selectall_hashref_query($::form, $self->dbh, $query, $self->fromdate, $self->todate,
+                                                  $self->fromdate, $self->todate, $self->fromdate, $self->todate);
+
 
-  my $verwaiste_invoice = selectall_hashref_query($::form, $self->dbh, $query);
   if (@$verwaiste_invoice) {
      $self->tester->ok(0, "Es gibt verwaiste invoice Einträge! (wo ar/ap-Eintrag fehlt)");
      for my $invoice ( @{ $verwaiste_invoice }) {
@@ -498,9 +500,9 @@ sub check_missing_tax_bookings {
   # check tax bookings. all taxkey <> 0 should have tax bookings in acc_trans
 
   my $query = qq| select trans_id, chart.accno,transdate from acc_trans left join chart on (chart.id = acc_trans.chart_id)
-                    WHERE taxkey <> 0 AND trans_id NOT IN
+                    WHERE taxkey NOT IN (SELECT taxkey from tax where rate=0) AND trans_id NOT IN
                     (select trans_id from acc_trans where chart_link ilike '%tax%' and trans_id IN
-                    (SELECT trans_id from acc_trans where taxkey <> 0))
+                    (SELECT trans_id from acc_trans where taxkey NOT IN (SELECT taxkey from tax where rate=0)))
                     AND transdate >= ? AND transdate <= ?|;
 
   my $missing_tax_bookings = selectall_hashref_query($::form, $self->dbh, $query, $self->fromdate, $self->todate);