]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Neue Chart Methode new_chart_valid
authorG. Richardson <information@kivitendo-premium.de>
Tue, 1 Mar 2016 16:21:27 +0000 (17:21 +0100)
committerG. Richardson <information@kivitendo-premium.de>
Tue, 1 Mar 2016 16:28:59 +0000 (17:28 +0100)
die prüft, ob es für das Konto ein Folgekonto gibt, und ob das aktuelle
Tagesdatum >= dem Folgedatum ist, d.h. ob eigentlich das Folgekonto
benutzt werden soll. Diese Abfrage war bisher allerdings kaputt und wird
wahrscheinlich auch nirgends sinnvoll genutzt.

SL/AM.pm
SL/DB/Chart.pm

index b991acf394e1d05f84215bf69e55af9c3ecb9392..f13fcc7eebbec2dac1e79c9f1aa05264675ec93e 100644 (file)
--- a/SL/AM.pm
+++ b/SL/AM.pm
@@ -181,17 +181,8 @@ sub get_account {
   $form->{orphaned} = $chart_obj->has_transaction ? 0 : 1;
 
   # check if new account is active
   $form->{orphaned} = $chart_obj->has_transaction ? 0 : 1;
 
   # check if new account is active
-  $form->{new_chart_valid} = 0;
-  if ($form->{new_chart_id}) {
-    $query = qq|SELECT current_date-valid_from FROM chart
-                WHERE id = ?|;
-    $main::lxdebug->message(LXDebug->QUERY(), "\$query=\n $query");
-    my ($count) = selectrow_query($form, $dbh, $query, $form->{id});
-    if ($count >=0) {
-      $form->{new_chart_valid} = 1;
-    }
-    $sth->finish;
-  }
+  # The old sql query was broken since at least 2006 and always returned 0
+  $form->{new_chart_valid} = $chart_obj->new_chart_valid;
 
   $dbh->disconnect;
 
 
   $dbh->disconnect;
 
index 0c8636c81cbdbd3ef5e5b10f583c5fa3a05011bc..d51332f7d8c1d29cbbd5198dec962693d92ba63d 100644 (file)
@@ -87,6 +87,16 @@ sub has_transaction {
   $self->db->dbh->selectrow_array('select exists(select 1 from acc_trans where chart_id = ?)', {}, $self->id);
 }
 
   $self->db->dbh->selectrow_array('select exists(select 1 from acc_trans where chart_id = ?)', {}, $self->id);
 }
 
+sub new_chart_valid {
+  my ($self) = @_;
+
+  if ( $self->valid_from && DateTime->today >= $self->valid_from ) {
+    return 1;
+  } else {
+    return 0;
+  };
+}
+
 sub displayable_name {
   my ($self) = @_;
 
 sub displayable_name {
   my ($self) = @_;
 
@@ -170,6 +180,12 @@ or not.
 Returns the date of the last transaction of the chart in the database, which
 may lie in the future.
 
 Returns the date of the last transaction of the chart in the database, which
 may lie in the future.
 
+=item C<new_chart_valid>
+
+Checks whether a follow-up chart is configured, and returns 1 or 0 depending on
+whether the valid_from date is before or after the current date.
+Is this even used anywhere?
+
 =back
 
 =head1 BUGS
 =back
 
 =head1 BUGS