From 22df2fec30951e6c247f8af82e599ec885831de6 Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Fri, 8 Aug 2008 06:49:30 +0000 Subject: [PATCH] BF [ 1896885 ] BS Line: don't update header if after save/delete fails --- .../compiere/model/MBankStatementLine.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/base/src/org/compiere/model/MBankStatementLine.java b/base/src/org/compiere/model/MBankStatementLine.java index 450ee8b1b3..c12ecf68de 100644 --- a/base/src/org/compiere/model/MBankStatementLine.java +++ b/base/src/org/compiere/model/MBankStatementLine.java @@ -30,6 +30,9 @@ import org.compiere.util.*; * * Carlos Ruiz - globalqss - integrate bug fixing from Teo Sarca * [ 1619076 ] Bank statement's StatementDifference becames NULL + * + * @author Teo Sarca, SC ARHIPAC SERVICE SRL + *
  • BF [ 1896885 ] BS Line: don't update header if after save/delete fails */ public class MBankStatementLine extends X_C_BankStatementLine { @@ -188,8 +191,9 @@ import org.compiere.util.*; */ protected boolean afterSave (boolean newRecord, boolean success) { - updateHeader(); - return success; + if (!success) + return success; + return updateHeader(); } // afterSave /** @@ -199,24 +203,34 @@ import org.compiere.util.*; */ protected boolean afterDelete (boolean success) { - updateHeader(); - return success; + if (!success) + return success; + return updateHeader(); } // afterSave /** * Update Header */ - private void updateHeader() + private boolean updateHeader() { String sql = "UPDATE C_BankStatement bs" + " SET StatementDifference=(SELECT COALESCE(SUM(StmtAmt),0) FROM C_BankStatementLine bsl " + "WHERE bsl.C_BankStatement_ID=bs.C_BankStatement_ID AND bsl.IsActive='Y') " + "WHERE C_BankStatement_ID=" + getC_BankStatement_ID(); - DB.executeUpdate(sql, get_TrxName()); + int no = DB.executeUpdate(sql, get_TrxName()); + if (no != 1) { + log.warning("StatementDifference #" + no); + return false; + } sql = "UPDATE C_BankStatement bs" + " SET EndingBalance=BeginningBalance+StatementDifference " + "WHERE C_BankStatement_ID=" + getC_BankStatement_ID(); - DB.executeUpdate(sql, get_TrxName()); + no = DB.executeUpdate(sql, get_TrxName()); + if (no != 1) { + log.warning("Balance #" + no); + return false; + } + return true; } // updateHeader } // MBankStatementLine