Merge von 825,826 aus unstable: Bugfix 165
[kivitendo-erp.git] / SL / GL.pm
index 11cbe36..3b0e74e 100644 (file)
--- a/SL/GL.pm
+++ b/SL/GL.pm
@@ -38,6 +38,8 @@
 
 package GL;
 
+use Data::Dumper;
+
 sub delete_transaction {
   my ($self, $myconfig, $form) = @_;
   $main::lxdebug->enter_sub();
@@ -350,8 +352,10 @@ sub all_transactions {
      map { $sortorder =~ s/$_/$ordinal{$_}/ } keys %ordinal;
    
      if ($form->{sort}) {
-         $sortorder = $form->{sort} . ',' . $sortorder;
-     }
+         $sortorder = $form->{sort} . ",";
+     } else {
+        $sortorder = "";
+      }
   
   my $query =
     qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, t.taxkey AS sorttax,
@@ -382,7 +386,7 @@ sub all_transactions {
                 AND ac.chart_id = c.id
                 AND a.vendor_id = ct.id
                 AND a.id = ac.trans_id
-                ORDER BY $sortorderoid|;
+                ORDER BY $sortorder transdate, trans_id, taxkey DESC, sorttax DESC,oid|;
   my $sth = $dbh->prepare($query);
   $sth->execute || $form->dberror($query);
   my $trans_id = "";
@@ -516,6 +520,7 @@ sub all_transactions {
     ($form->{gifi_account_description}) = $sth->fetchrow_array;
     $sth->finish;
   }
+  print(STDERR Dumper($form->{GL}));
   $main::lxdebug->leave_sub();
 
   $dbh->disconnect;