From d68654a299b999a740384f682dab0bd40d7fe545 Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Thu, 20 Nov 2008 16:26:38 +0000 Subject: [PATCH] BF [ 2317305 ] Update Invoice header only if doc is not processed --- base/src/org/compiere/model/MInvoiceLine.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/base/src/org/compiere/model/MInvoiceLine.java b/base/src/org/compiere/model/MInvoiceLine.java index 48ae75b266..24c919a82e 100644 --- a/base/src/org/compiere/model/MInvoiceLine.java +++ b/base/src/org/compiere/model/MInvoiceLine.java @@ -851,6 +851,10 @@ public class MInvoiceLine extends X_C_InvoiceLine */ private boolean updateHeaderTax() { + // Update header only if the document is not processed - teo_sarca BF [ 2317305 ] + if (isProcessed() && !is_ValueChanged(COLUMNNAME_Processed)) + return true; + // Recalculate Tax for this Tax if (!updateInvoiceTax(false)) return false; @@ -859,21 +863,21 @@ public class MInvoiceLine extends X_C_InvoiceLine String sql = "UPDATE C_Invoice i" + " SET TotalLines=" + "(SELECT COALESCE(SUM(LineNetAmt),0) FROM C_InvoiceLine il WHERE i.C_Invoice_ID=il.C_Invoice_ID) " - + "WHERE C_Invoice_ID=" + getC_Invoice_ID(); - int no = DB.executeUpdate(sql, get_TrxName()); + + "WHERE C_Invoice_ID=?"; + int no = DB.executeUpdateEx(sql, new Object[]{getC_Invoice_ID()}, get_TrxName()); if (no != 1) log.warning("(1) #" + no); if (isTaxIncluded()) sql = "UPDATE C_Invoice i " + " SET GrandTotal=TotalLines " - + "WHERE C_Invoice_ID=" + getC_Invoice_ID(); + + "WHERE C_Invoice_ID=?"; else sql = "UPDATE C_Invoice i " + " SET GrandTotal=TotalLines+" + "(SELECT COALESCE(SUM(TaxAmt),0) FROM C_InvoiceTax it WHERE i.C_Invoice_ID=it.C_Invoice_ID) " - + "WHERE C_Invoice_ID=" + getC_Invoice_ID(); - no = DB.executeUpdate(sql, get_TrxName()); + + "WHERE C_Invoice_ID=?"; + no = DB.executeUpdateEx(sql, new Object[]{getC_Invoice_ID()}, get_TrxName()); if (no != 1) log.warning("(2) #" + no); m_parent = null;