SelfTests: Transactions um Prüfung auf laxe Buchungskonfiguration erweitert
[kivitendo-erp.git] / SL / BackgroundJob / SelfTest / Transactions.pm
index b64966a..d953966 100644 (file)
@@ -15,7 +15,7 @@ sub run {
 
   $self->_setup;
 
-  $self->tester->plan(tests => 25);
+  $self->tester->plan(tests => 26);
 
   $self->check_konten_mit_saldo_nicht_in_guv;
   $self->check_bilanzkonten_mit_pos_eur;
@@ -42,6 +42,7 @@ sub run {
   $self->check_ap_paid_acc_trans;
   $self->check_zero_amount_paid_but_datepaid_exists;
   $self->check_orphaned_reconciliated_links;
+  $self->check_recommended_client_settings;
 }
 
 sub _setup {
@@ -644,7 +645,33 @@ sub check_orphaned_reconciliated_links {
   }
 }
 
+sub check_recommended_client_settings {
+  my ($self) = @_;
+
+  my $all_ok = 1;
+
+  # expand: check datev && check mark_as_paid
+  my %settings_values_nok = (
+                              SL::DB::Default->get->is_changeable => 1,
+                              SL::DB::Default->get->ar_changeable => 1,
+                              SL::DB::Default->get->ap_changeable => 1,
+                              SL::DB::Default->get->ir_changeable => 1,
+                              SL::DB::Default->get->gl_changeable => 1,
+                             );
+
+  foreach (keys %settings_values_nok) {
+    if ($_ == $settings_values_nok{$_}) {
+      $self->tester->ok(0, "Buchungskonfiguration: Mindestens ein Belegtyp ist immer änderbar.");
+      undef $all_ok;
+    }
+  }
+
+  # payments more strict (avoid losing payments acc_trans_ids)
+  my $payments_ok = SL::DB::Default->get->payments_changeable == 0 ? 1 : 0;
+  $self->tester->ok(0, "Manuelle Zahlungen sind zu lange änderbar (Empfehlung: niemals).") unless $payments_ok;
 
+  $self->tester->ok(1, "Mandantenkonfiguration optimal eingestellt.") if ($payments_ok && $all_ok);
+}
 1;
 
 __END__