]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Merge branch 'master' of github.com:kivitendo/kivitendo-erp
authorMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 29 Apr 2013 11:16:48 +0000 (13:16 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 29 Apr 2013 11:16:48 +0000 (13:16 +0200)
SL/GL.pm
SL/IR.pm
bin/mozilla/gl.pl
templates/webpages/gl/search.html

index 10d6ee120a00ecac476d69d550d1fb7b84ed0288..1fc1f3a42c6719e1960203a1a2faf3b661dd70de 100644 (file)
--- a/SL/GL.pm
+++ b/SL/GL.pm
@@ -285,9 +285,7 @@ sub all_transactions {
     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 = ? ";
index 22c5dc124e35d491cc330bfe5af037710f9c4838..73b3e14eda3ac703692421615b680a70bbbdbb64 100644 (file)
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -216,14 +216,16 @@ sub post_invoice {
 
       # check if we sold the item already and
       # make an entry for the expense and inventory
+      my $taxzone = $form->{taxzone_id} * 1;
       $query =
         qq|SELECT i.id, i.qty, i.allocated, i.trans_id, i.base_qty,
-             p.inventory_accno_id, p.expense_accno_id, a.transdate
-           FROM invoice i, ar a, parts p
+             bg.inventory_accno_id, bg.expense_accno_id_${taxzone} AS expense_accno_id, a.transdate
+           FROM invoice i, ar a, parts p, buchungsgruppen bg
            WHERE (i.parts_id = p.id)
              AND (i.parts_id = ?)
              AND ((i.base_qty + i.allocated) > 0)
              AND (i.trans_id = a.id)
+             AND (p.buchungsgruppen_id = bg.id)
            ORDER BY transdate|;
            # ORDER BY transdate guarantees FIFO
 
@@ -269,7 +271,7 @@ sub post_invoice {
 
             # allocated >= 0
             # add entry for inventory, this one is for the sold item
-            $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?,
+            $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id, chart_link) VALUES (?, ?, ?, ?,
                                (SELECT taxkey_id
                                 FROM taxkeys
                                 WHERE chart_id= ?
@@ -280,13 +282,13 @@ sub post_invoice {
                                 WHERE chart_id= ?
                                 AND startdate <= ?
                                 ORDER BY startdate DESC LIMIT 1),
-                               (SELECT chart_link FROM chart WHERE id = ?))|;
+                               (SELECT link FROM chart WHERE id = ?))|;
             @values = ($ref->{trans_id},  $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{transdate}, $ref->{inventory_accno_id}, $ref->{transdate},
                        $ref->{inventory_accno_id});
             do_query($form, $dbh, $query, @values);
 
 # add expense
-            $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id) VALUES (?, ?, ?, ?,
+            $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, tax_id, chart_link) VALUES (?, ?, ?, ?,
                                 (SELECT taxkey_id
                                  FROM taxkeys
                                  WHERE chart_id= ?
@@ -297,7 +299,7 @@ sub post_invoice {
                                  WHERE chart_id= ?
                                  AND startdate <= ?
                                  ORDER BY startdate DESC LIMIT 1),
-                                (SELECT chart_link FROM chart WHERE id = ?))|;
+                                (SELECT link FROM chart WHERE id = ?))|;
             @values = ($ref->{trans_id},  $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id}, $ref->{transdate}, $ref->{expense_accno_id}, $ref->{transdate},
                        $ref->{expense_accno_id});
             do_query($form, $dbh, $query, @values);
index 626d688179aadbad19dc93eb787a50ad8b943045..0d9a92b5de005bc4bc90313aefe2c8cedd84ce0a 100644 (file)
@@ -304,19 +304,21 @@ sub generate_report {
   );
 
   # add employee here, so that variable is still known and passed in url when choosing a different sort order in resulting table
-  my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto employee datesort category l_subtotal);
+  my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto employee_id datesort category l_subtotal);
   push @hidden_variables, map { "l_${_}" } @columns;
   foreach ( @hidden_variables ) {
       print URL "$_\n";
   };
 
+  my $employee = $form->{employee_id} ? SL::DB::Employee->new(id => $form->{employee_id})->load->name : '';
+
   my (@options, @date_options);
   push @options,      $locale->text('Account')     . " : $form->{accno} $form->{account_description}" if ($form->{accno});
   push @options,      $locale->text('Source')      . " : $form->{source}"                             if ($form->{source});
   push @options,      $locale->text('Reference')   . " : $form->{reference}"                          if ($form->{reference});
   push @options,      $locale->text('Description') . " : $form->{description}"                        if ($form->{description});
   push @options,      $locale->text('Notes')       . " : $form->{notes}"                              if ($form->{notes});
-  push @options,      $locale->text('Employee')       . " : $form->{employee_name}"                              if ($form->{employee_name});
+  push @options,      $locale->text('Employee')    . " : $employee"                                   if $employee;
   my $datesorttext = $form->{datesort} eq 'transdate' ? $locale->text('Invoice Date') :  $locale->text('Booking Date');
   push @date_options,      "$datesorttext"                              if ($form->{datesort} and ($form->{datefrom} or $form->{dateto}));
   push @date_options, $locale->text('From'), $locale->date(\%myconfig, $form->{datefrom}, 1)          if ($form->{datefrom});
index 3f1fd404d03760053ff7b04de5a35393ec491100..e7f1cd1b75d19f3b66448d1a96628c6ab93ef622 100644 (file)
@@ -42,7 +42,7 @@
         </tr>
  <tr>
     <th align=right>[% 'Employee' | $T8 %]</th>
-    <td colspan=3>[% L.select_tag('employee', ALL_EMPLOYEES, title_key = 'safe_name', with_empty = 1) %]</td>
+    <td colspan=3>[% L.select_tag('employee_id', ALL_EMPLOYEES, title_key = 'safe_name', with_empty = 1) %]</td>
   </tr>
   <tr>
     <th align=right>[% 'Filter date by' | $T8 %]</th>