exact match funktion wieder hergestellt nach dem letzten commit
[kivitendo-erp.git] / SL / GL.pm
index fb7b534..e6c87b3 100644 (file)
--- a/SL/GL.pm
+++ b/SL/GL.pm
@@ -171,10 +171,10 @@ sub post_transaction {
         qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
                                   source, memo, project_id, taxkey, tax_id, chart_link)
            VALUES (?, (SELECT chart_id FROM tax WHERE id = ?),
-                   ?, ?, ?, ?, ?, ?, ?, (SELECT link 
-                                         FROM chart 
-                                         WHERE id = (SELECT chart_id 
-                                                     FROM tax 
+                   ?, ?, ?, ?, ?, ?, ?, (SELECT link
+                                         FROM chart
+                                         WHERE id = (SELECT chart_id
+                                                     FROM tax
                                                      WHERE id = ?)))|;
       @values = (conv_i($form->{id}), conv_i($form->{"tax_id_$i"}),
                  $tax, conv_date($form->{transdate}), $form->{"source_$i"},
@@ -198,6 +198,7 @@ sub post_transaction {
       dbh        => $dbh,
       from       => $transdate,
       to         => $transdate,
+      trans_id   => $form->{id},
     );
 
     $datev->export;
@@ -284,10 +285,8 @@ sub all_transactions {
     push(@arvalues, '%' . $form->{description} . '%');
     push(@apvalues, '%' . $form->{description} . '%');
   }
-  if ($form->{employee} =~ /--/) {
-    ($form->{employee_id},$form->{employee_name}) = split(/--/,$form->{employee});
-  #if ($form->{employee_id}) {
+
+  if ($form->{employee_id}) {
     $glwhere .= " AND g.employee_id = ? ";
     $arwhere .= " AND a.employee_id = ? ";
     $apwhere .= " AND a.employee_id = ? ";
@@ -355,8 +354,6 @@ sub all_transactions {
     }
   }
 
-  my $false = ($myconfig->{dbdriver} eq 'Pg') ? "FALSE" : q|'0'|;
-
   my %sort_columns =  (
     'id'           => [ qw(id)                   ],
     'transdate'    => [ qw(transdate id)         ],
@@ -370,7 +367,7 @@ sub all_transactions {
     'source'          => { 'gl' => 'ac.source',     'arap' => 'ac.source',   },
     'description'     => { 'gl' => 'g.description', 'arap' => 'ct.name',     },
     );
-  
+
   # sortdir = sort direction (ascending or descending)
   my $sortdir   = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
   my $sortkey   = $sort_columns{$form->{sort}} ? $form->{sort} : $form->{datesort};  # default used to be transdate
@@ -386,7 +383,7 @@ sub all_transactions {
 
   $query =
     qq|SELECT
-        ac.acc_trans_id, g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link,
+        ac.acc_trans_id, g.id, 'gl' AS type, FALSE AS invoice, g.reference, ac.taxkey, c.link,
         g.description, ac.transdate, ac.gldate, ac.source, ac.trans_id,
         ac.amount, c.accno, g.notes, t.chart_id,
         CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee
@@ -803,5 +800,24 @@ sub get_chart_balances {
   $main::lxdebug->leave_sub();
 }
 
+sub get_tax_dropdown {
+  my $myconfig = \%main::myconfig;
+  my $form = $main::form;
+
+  my $dbh = $form->get_standard_dbh($myconfig);
+
+  my $query = qq|SELECT category FROM chart WHERE accno = ?|;
+  my ($category) = selectrow_query($form, $dbh, $query, $form->{accno});
+
+  $query = qq|SELECT * FROM tax WHERE chart_categories like '%$category%' order by taxkey, rate|;
+
+  my $sth = prepare_execute_query($form, $dbh, $query);
+
+  $form->{TAX_ACCOUNTS} = [];
+  while (my $ref = $sth->fetchrow_hashref("NAME_lc")) {
+    push(@{ $form->{TAX_ACCOUNTS} }, $ref);
+  }
+
+}
 
 1;