Verwendete Lizenz eindeutig bennennen.
[kivitendo-erp.git] / SL / GL.pm
index 7eccc0d..660c148 100644 (file)
--- a/SL/GL.pm
+++ b/SL/GL.pm
@@ -377,7 +377,7 @@ sub all_transactions {
   }
 
   my $query =
-    qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link,
+    qq|SELECT ac.oid AS acoid, g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link,
                  g.description, ac.transdate, ac.source, ac.trans_id,
                 ac.amount, c.accno, c.gifi_accno, g.notes, t.chart_id, ac.oid
                  FROM gl g, acc_trans ac, chart c LEFT JOIN tax t ON
@@ -386,7 +386,7 @@ sub all_transactions {
                 AND ac.chart_id = c.id
                 AND g.id = ac.trans_id
        UNION
-                SELECT a.id, 'ar' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
+                SELECT ac.oid AS acoid, a.id, 'ar' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
                 ct.name, ac.transdate, ac.source, ac.trans_id,
                 ac.amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid
                 FROM ar a, acc_trans ac, customer ct, chart c LEFT JOIN tax t ON
@@ -396,7 +396,7 @@ sub all_transactions {
                 AND a.customer_id = ct.id
                 AND a.id = ac.trans_id
        UNION
-                SELECT a.id, 'ap' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
+                SELECT ac.oid AS acoid, a.id, 'ap' AS type, a.invoice, a.invnumber, ac.taxkey, c.link,
                 ct.name, ac.transdate, ac.source, ac.trans_id,
                 ac.amount, c.accno, c.gifi_accno, a.notes, t.chart_id, ac.oid
                 FROM ap a, acc_trans ac, vendor ct, chart c LEFT JOIN tax t ON
@@ -405,7 +405,7 @@ sub all_transactions {
                 AND ac.chart_id = c.id
                 AND a.vendor_id = ct.id
                 AND a.id = ac.trans_id
-                ORDER BY $sortorder transdate, trans_id, taxkey DESC, oid|;
+                ORDER BY $sortorder transdate,acoid, trans_id, taxkey DESC|;
 
   # Show all $query in Debuglevel LXDebug::QUERY
   $callingdetails = (caller (0))[3];
@@ -616,17 +616,9 @@ sub transaction {
     $sth->finish;
 
     # retrieve individual rows
-    $query = "SELECT c.accno, c.taxkey_id AS accnotaxkey, a.amount, project_id,
-                (SELECT p.projectnumber FROM project p
-                WHERE a.project_id = p.id) AS projectnumber, a.taxkey, (SELECT c1.accno FROM chart c1, tax t WHERE t.taxkey=a.taxkey AND c1.id=t.chart_id) AS taxaccno, (SELECT t1.rate FROM tax t1 WHERE t1.taxkey=a.taxkey) AS taxrate 
-             FROM acc_trans a, chart c
-             WHERE a.chart_id = c.id
-             AND a.trans_id = $form->{id}
-             ORDER BY a.oid";
-
     $query = qq|SELECT c.accno, t.taxkey AS accnotaxkey, a.amount, a.memo,
                 a.transdate, a.cleared, a.project_id, p.projectnumber,(SELECT p.projectnumber FROM project p
-                WHERE a.project_id = p.id) AS projectnumber, a.taxkey, t.rate AS taxrate, t.id, (SELECT c1.accno FROM chart c1, tax t1 WHERE t1.id=t.id AND c1.id=t.chart_id) AS taxaccno
+                WHERE a.project_id = p.id) AS projectnumber, a.taxkey, t.rate AS taxrate, t.id, (SELECT c1.accno FROM chart c1, tax t1 WHERE t1.id=t.id AND c1.id=t.chart_id) AS taxaccno, t.id AS tax_id
                FROM acc_trans a
                JOIN chart c ON (c.id = a.chart_id)
                LEFT JOIN project p ON (p.id = a.project_id)