Neuer SelfTest Testfall: verwaiste invoice Einträge
authorG. Richardson <information@kivitendo-premium.de>
Tue, 18 Feb 2014 16:13:48 +0000 (17:13 +0100)
committerG. Richardson <information@kivitendo-premium.de>
Tue, 18 Feb 2014 16:49:23 +0000 (17:49 +0100)
Suche nach verwaisten Einträgen in invoice, die weder mit ar noch mit ap
verknüpft sind.

SL/BackgroundJob/SelfTest/Transactions.pm

index 9b5daed..939c795 100644 (file)
@@ -15,12 +15,13 @@ sub run {
 
   $self->_setup;
 
-  $self->tester->plan(tests => 16);
+  $self->tester->plan(tests => 17);
 
   $self->check_konten_mit_saldo_nicht_in_guv;
   $self->check_bilanzkonten_mit_pos_eur;
   $self->check_balanced_individual_transactions;
   $self->check_verwaiste_acc_trans_eintraege;
+  $self->check_verwaiste_invoice_eintraege;
   $self->check_netamount_laut_invoice_ar;
   $self->check_invnumbers_unique;
   $self->check_summe_stornobuchungen;
@@ -128,6 +129,23 @@ sub check_verwaiste_acc_trans_eintraege {
   }
 }
 
+sub check_verwaiste_invoice_eintraege {
+ # taxincluded is null sollte nie passieren:
+ # select sum(sellprice*qty) from invoice i where trans_id in (select id from ar where taxincluded is null);
+  my ($self) = @_;
+  my $query = qq|
+     select * from invoice
+       where trans_id not in (select id from ar union select id from ap order by id)
+      and a.transdate >= ? and a.transdate <= ? ;|;
+
+  my $verwaiste_invoice = selectall_hashref_query($::form, $self->dbh, $query, $self->fromdate, $self->todate);                                                              
+  if (@$verwaiste_invoice) {                                                                                                                                                 
+     $self->tester->ok(0, "Es gibt verwaiste invoice Einträge! (wo ar/ap-Eintrag fehlt)");                                                                                   
+     $self->tester->diag($_) for @$verwaiste_acs;                                                                                                                            
+  } else {                                                                                                                                                                   
+     $self->tester->ok(1, "Keine verwaisten invoice Einträge (wo ar/ap-Eintrag fehlt)");                                                                                       }                                                                                                                                                                          
+}
+
 sub check_netamount_laut_invoice_ar {
   my ($self) = @_;
   my $query = qq|