]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Einkaufsrechnungen: Neu buchen SQL Fehler behoben
authorSven Schöling <s.schoeling@linet-services.de>
Thu, 22 Oct 2015 11:26:34 +0000 (13:26 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 3 Nov 2015 10:04:22 +0000 (11:04 +0100)
Fehler trat auf, wenn Aufwandsmethode eingestellt war, und eine
Einkaufsrechnung, für die bereits eine Verkaufsrechnung existierte
geändert wurde. Dann wurde fälschlicherweise beim Umkehren der Rechnung
versucht die Warenbestandsbuchungen zu ändern.

Ohne Verkaufsrechnung existieren die allocated < 0 Positionen nicht.

SL/IR.pm

index ad28c968b240ce72c4cf894cbaa69572f9e31dfa..fbff03e1be26ad6a55b0aa84af9fd6b2596b85ee 100644 (file)
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -873,17 +873,20 @@ sub reverse_invoice {
         #adjust allocated
         $form->update_balance($dbh, "invoice", "allocated", qq|id = $pthref->{id}|, $qty);
 
         #adjust allocated
         $form->update_balance($dbh, "invoice", "allocated", qq|id = $pthref->{id}|, $qty);
 
-        $form->update_balance($dbh, "acc_trans", "amount",
-                              qq|    (trans_id = $pthref->{trans_id})
-                                 AND (chart_id = $ref->{expense_accno_id})
-                                 AND (transdate = '$pthref->{transdate}')|,
-                              $amount);
-
-        $form->update_balance($dbh, "acc_trans", "amount",
-                              qq|    (trans_id = $pthref->{trans_id})
-                                 AND (chart_id = $ref->{inventory_accno_id})
-                                 AND (transdate = '$pthref->{transdate}')|,
-                              $amount * -1);
+        if  ( $::instance_conf->get_inventory_system eq 'perpetual' ) {
+
+          $form->update_balance($dbh, "acc_trans", "amount",
+                                qq|    (trans_id = $pthref->{trans_id})
+                                   AND (chart_id = $ref->{expense_accno_id})
+                                   AND (transdate = '$pthref->{transdate}')|,
+                                $amount);
+
+          $form->update_balance($dbh, "acc_trans", "amount",
+                                qq|    (trans_id = $pthref->{trans_id})
+                                   AND (chart_id = $ref->{inventory_accno_id})
+                                   AND (transdate = '$pthref->{transdate}')|,
+                                $amount * -1);
+        }
 
         last if (($ref->{allocated} -= $qty) <= 0);
       }
 
         last if (($ref->{allocated} -= $qty) <= 0);
       }