FR [ 2079083 ] Add MFactAcct.deleteEx method

This commit is contained in:
teo_sarca 2008-08-27 20:54:17 +00:00
parent 7c98840275
commit c1e2d1cc4a
6 changed files with 56 additions and 35 deletions

View File

@ -307,8 +307,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
return false;
}
setPosted(false);
if (MFactAcct.delete (Table_ID, get_ID(), trxName) < 0)
return false;
MFactAcct.deleteEx (Table_ID, get_ID(), trxName);
}
// Mark as Inactive
setIsActive(false); // updated DB for line delete/process
@ -721,8 +720,7 @@ public final class MAllocationHdr extends X_C_AllocationHdr implements DocAction
throw new IllegalStateException("Cannot de-activate allocation");
// Delete Posting
int no = MFactAcct.delete(MAllocationHdr.Table_ID, getC_AllocationHdr_ID(), get_TrxName());
log.fine("Fact_Acct deleted #" + no);
MFactAcct.deleteEx(MAllocationHdr.Table_ID, getC_AllocationHdr_ID(), get_TrxName());
// Unlink Invoices
getLines(true);

View File

@ -466,8 +466,7 @@ public class MBankStatement extends X_C_BankStatement implements DocAction
m_processMsg = "@PeriodClosed@";
return false;
}
if (MFactAcct.delete(Table_ID, getC_BankStatement_ID(), get_TrxName()) < 0)
return false; // could not delete
MFactAcct.deleteEx(Table_ID, getC_BankStatement_ID(), get_TrxName());
}
//Added Lines by AZ Goodwill

View File

@ -680,10 +680,8 @@ public class MCash extends X_C_Cash implements DocAction
throw new IllegalStateException("Cannot save journal cash");
// Delete Posting
String sql = "DELETE FROM Fact_Acct WHERE AD_Table_ID=" + MCash.Table_ID
+ " AND Record_ID=" + getC_Cash_ID();
int no = DB.executeUpdate(sql, get_TrxName());
log.fine("Fact_Acct deleted #" + no);
MFactAcct.deleteEx(Table_ID, getC_Cash_ID(), get_TrxName());
return true;
} // reverse

View File

@ -16,10 +16,13 @@
*****************************************************************************/
package org.compiere.model;
import java.sql.*;
import java.util.*;
import java.util.logging.*;
import org.compiere.util.*;
import java.sql.ResultSet;
import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.exceptions.DBException;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
/**
@ -27,29 +30,51 @@ import org.compiere.util.*;
*
* @author Jorg Janke
* @version $Id: MFactAcct.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
*
* @author Teo Sarca, http://www.arhipac.ro
* <li>FR [ 2079083 ] Add MFactAcct.deleteEx method
*/
public class MFactAcct extends X_Fact_Acct
{
private static final long serialVersionUID = 1L;
/**
* Delete Accounting
* @param AD_Table_ID table
* @param Record_ID record
* @param trxName transaction
* @return number of rows or -1 for error
* Delete Accounting
* @param AD_Table_ID table
* @param Record_ID record
* @param trxName transaction
* @return number of rows or -1 for error
* @deprecated Since ADempiere 3.5.2a; please use {@link #deleteEx(int, int, String)} instead.
*/
public static int delete (int AD_Table_ID, int Record_ID, String trxName)
public static int delete00 (int AD_Table_ID, int Record_ID, String trxName)
{
StringBuffer sb = new StringBuffer();
sb.append("DELETE Fact_Acct WHERE AD_Table_ID=").append(AD_Table_ID)
.append(" AND Record_ID=").append(Record_ID);
int no = DB.executeUpdate(sb.toString(), trxName);
if (no == -1)
s_log.log(Level.SEVERE, "failed: AD_Table_ID=" + AD_Table_ID + ", Record_ID" + Record_ID);
else
s_log.fine("delete - AD_Table_ID=" + AD_Table_ID
+ ", Record_ID=" + Record_ID + " - #" + no);
int no = -1;
try {
no = deleteEx(AD_Table_ID, Record_ID, trxName);
}
catch (DBException e) {
s_log.log(Level.SEVERE, "failed: AD_Table_ID=" + AD_Table_ID + ", Record_ID" + Record_ID, e);
no = -1;
}
return no;
} // delete
/**
* Delete Accounting
* @param AD_Table_ID table
* @param Record_ID record
* @param trxName transaction
* @return number of rows deleted
* @throws DBException on database exception
*/
public static int deleteEx(int AD_Table_ID, int Record_ID, String trxName)
throws DBException
{
final String sql = "DELETE Fact_Acct WHERE AD_Table_ID=? AND Record_ID=?";
int no = DB.executeUpdateEx(sql, new Object[]{AD_Table_ID, Record_ID}, trxName);
s_log.fine("delete - AD_Table_ID=" + AD_Table_ID + ", Record_ID=" + Record_ID + " - #" + no);
return no;
}
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger (MFactAcct.class);

View File

@ -39,6 +39,9 @@ import org.compiere.util.Env;
*/
public class MMatchInv extends X_M_MatchInv
{
private static final long serialVersionUID = 1L;
/**
* Get InOut-Invoice Matches
* @param ctx context
@ -356,10 +359,9 @@ public class MMatchInv extends X_M_MatchInv
{
if (isPosted())
{
if (!MPeriod.isOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_MatchInvoice))
return false;
MPeriod.testPeriodOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_MatchInvoice);
setPosted(false);
return MFactAcct.delete (Table_ID, get_ID(), get_TrxName()) >= 0;
MFactAcct.deleteEx (Table_ID, get_ID(), get_TrxName());
}
return true;
} // beforeDelete

View File

@ -658,10 +658,9 @@ public class MMatchPO extends X_M_MatchPO
{
if (isPosted())
{
if (!MPeriod.isOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_MatchPO))
return false;
MPeriod.testPeriodOpen(getCtx(), getDateTrx(), MDocType.DOCBASETYPE_MatchPO);
setPosted(false);
return MFactAcct.delete (Table_ID, get_ID(), get_TrxName()) >= 0;
MFactAcct.deleteEx (Table_ID, get_ID(), get_TrxName());
}
return true;
} // beforeDelete