FR [ 2552834 ] Refactor as.isSkipOrg(...) code
https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2552834&group_id=176962 Please help me reviewing this
This commit is contained in:
parent
1b4c0e3e8e
commit
2edca69820
|
@ -616,11 +616,6 @@ public abstract class Doc
|
|||
boolean skip = false;
|
||||
if (m_ass[i].getAD_OrgOnly_ID() != 0)
|
||||
{
|
||||
if (m_ass[i].getOnlyOrgs() == null)
|
||||
m_ass[i].setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
|
||||
0, MAcctSchemaElement.ELEMENTTYPE_Organization,
|
||||
m_ass[i].getAD_OrgOnly_ID()));
|
||||
|
||||
// Header Level Org
|
||||
skip = m_ass[i].isSkipOrg(getAD_Org_ID());
|
||||
// Line Level Org
|
||||
|
|
|
@ -21,8 +21,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.report.MReportTree;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
/**
|
||||
|
@ -139,9 +139,6 @@ public class MAcctSchema extends X_C_AcctSchema
|
|||
private static CCache<Integer,MAcctSchema[]> s_schema = new CCache<Integer,MAcctSchema[]>("AD_ClientInfo", 3); // 3 clients
|
||||
/** Cache of AcctSchemas **/
|
||||
private static CCache<Integer,MAcctSchema> s_cache = new CCache<Integer,MAcctSchema>("C_AcctSchema", 3); // 3 accounting schemas
|
||||
|
||||
/** Logger */
|
||||
private static CLogger s_log = CLogger.getCLogger(MAcctSchema.class);
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
|
@ -386,26 +383,34 @@ public class MAcctSchema extends X_C_AcctSchema
|
|||
} // getDueFrom_Acct
|
||||
|
||||
/**
|
||||
* Set Only Org Childs
|
||||
* @param orgs
|
||||
* Set Only Org Childs
|
||||
* @param orgs
|
||||
* @deprecated only orgs are now fetched automatically
|
||||
* @throws IllegalStateException every time when you call it
|
||||
*/
|
||||
public void setOnlyOrgs (Integer[] orgs)
|
||||
{
|
||||
m_onlyOrgs = orgs;
|
||||
// m_onlyOrgs = orgs;
|
||||
throw new IllegalStateException("The OnlyOrgs are now fetched automatically");
|
||||
} // setOnlyOrgs
|
||||
|
||||
/**
|
||||
* Set Only Org Childs
|
||||
* @return orgs
|
||||
* Get Only Org Children
|
||||
* @return array of AD_Org_ID
|
||||
*/
|
||||
public Integer[] getOnlyOrgs()
|
||||
{
|
||||
if (m_onlyOrgs == null)
|
||||
{
|
||||
m_onlyOrgs = MReportTree.getChildIDs(getCtx(),
|
||||
0, MAcctSchemaElement.ELEMENTTYPE_Organization,
|
||||
getAD_OrgOnly_ID());
|
||||
}
|
||||
return m_onlyOrgs;
|
||||
} // getOnlyOrgs
|
||||
|
||||
/**
|
||||
* Skip creating postings for this Org.
|
||||
* Requires setOnlyOrgs (MReportTree requires MTree in Basis)
|
||||
* @param AD_Org_ID
|
||||
* @return true if to skip
|
||||
*/
|
||||
|
@ -421,11 +426,14 @@ public class MAcctSchema extends X_C_AcctSchema
|
|||
// Not Summary Only - i.e. skip it
|
||||
if (!m_onlyOrg.isSummary())
|
||||
return true;
|
||||
if (m_onlyOrgs == null)
|
||||
return false;
|
||||
for (int i = 0; i < m_onlyOrgs.length; i++)
|
||||
final Integer[] onlyOrgs = getOnlyOrgs();
|
||||
if (onlyOrgs == null)
|
||||
{
|
||||
if (AD_Org_ID == m_onlyOrgs[i].intValue())
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < onlyOrgs.length; i++)
|
||||
{
|
||||
if (AD_Org_ID == onlyOrgs[i].intValue())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Properties;
|
|||
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.DocumentEngine;
|
||||
import org.compiere.report.MReportTree;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -936,7 +935,7 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
* @param Qty
|
||||
* @return
|
||||
*/
|
||||
private String createCostDetail(MInventoryLine line,int M_AttributeSetInstance_ID, BigDecimal qty)
|
||||
private String createCostDetail(MInventoryLine line, int M_AttributeSetInstance_ID, BigDecimal qty)
|
||||
{
|
||||
// Get Account Schemas to create MCostDetail
|
||||
MAcctSchema[] acctschemas = MAcctSchema.getClientAcctSchema(getCtx(), getAD_Client_ID());
|
||||
|
@ -944,21 +943,10 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
{
|
||||
MAcctSchema as = acctschemas[asn];
|
||||
|
||||
boolean skip = false;
|
||||
if (as.getAD_OrgOnly_ID() != 0)
|
||||
if (as.isSkipOrg(getAD_Org_ID()) || as.isSkipOrg(line.getAD_Org_ID()))
|
||||
{
|
||||
if (as.getOnlyOrgs() == null)
|
||||
as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
|
||||
0, MAcctSchemaElement.ELEMENTTYPE_Organization,
|
||||
as.getAD_OrgOnly_ID()));
|
||||
|
||||
// Header Level Org
|
||||
skip = as.isSkipOrg(getAD_Org_ID());
|
||||
// Line Level Org
|
||||
skip = as.isSkipOrg(line.getAD_Org_ID());
|
||||
}
|
||||
if (skip)
|
||||
continue;
|
||||
}
|
||||
|
||||
ProductCost pc = new ProductCost (Env.getCtx(),
|
||||
line.getM_Product_ID(), M_AttributeSetInstance_ID, line.get_TrxName());
|
||||
|
|
|
@ -544,9 +544,9 @@ public class MInvoice extends X_C_Invoice implements DocAction
|
|||
+ "WHERE AD_Client_ID=? AND DocBaseType=?"
|
||||
+ " AND IsActive='Y' "
|
||||
+ "ORDER BY IsDefault DESC";
|
||||
int C_DocType_ID = DB.getSQLValue(null, sql, getAD_Client_ID(), DocBaseType);
|
||||
int C_DocType_ID = DB.getSQLValueEx(null, sql, getAD_Client_ID(), DocBaseType);
|
||||
if (C_DocType_ID <= 0)
|
||||
log.log(Level.SEVERE, "Not found for AC_Client_ID="
|
||||
log.log(Level.SEVERE, "Not found for AD_Client_ID="
|
||||
+ getAD_Client_ID() + " - " + DocBaseType);
|
||||
else
|
||||
{
|
||||
|
@ -1834,21 +1834,11 @@ public class MInvoice extends X_C_Invoice implements DocAction
|
|||
{
|
||||
MAcctSchema as = acctschemas[asn];
|
||||
|
||||
boolean skip = false;
|
||||
if (as.getAD_OrgOnly_ID() != 0)
|
||||
if (as.isSkipOrg(getAD_Org_ID()) // Header Level Org
|
||||
|| as.isSkipOrg(m_invoiceLine.getAD_Org_ID()) ) // Line Level Org
|
||||
{
|
||||
if (as.getOnlyOrgs() == null)
|
||||
as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
|
||||
0, MAcctSchemaElement.ELEMENTTYPE_Organization,
|
||||
as.getAD_OrgOnly_ID()));
|
||||
|
||||
// Header Level Org
|
||||
skip = as.isSkipOrg(getAD_Org_ID());
|
||||
// Line Level Org
|
||||
skip = as.isSkipOrg(m_invoiceLine.getAD_Org_ID());
|
||||
}
|
||||
if (skip)
|
||||
continue;
|
||||
}
|
||||
|
||||
BigDecimal LineNetAmt = m_invoiceLine.getLineNetAmt();
|
||||
BigDecimal multiplier = inv.getQty()
|
||||
|
@ -2387,17 +2377,10 @@ public class MInvoice extends X_C_Invoice implements DocAction
|
|||
{
|
||||
MAcctSchema as = acctschemas[asn];
|
||||
|
||||
boolean skip = false;
|
||||
if (as.getAD_OrgOnly_ID() != 0)
|
||||
if (as.isSkipOrg(getAD_Org_ID()))
|
||||
{
|
||||
if (as.getOnlyOrgs() == null)
|
||||
as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
|
||||
0, MAcctSchemaElement.ELEMENTTYPE_Organization,
|
||||
as.getAD_OrgOnly_ID()));
|
||||
skip = as.isSkipOrg(getAD_Org_ID());
|
||||
}
|
||||
if (skip)
|
||||
continue;
|
||||
}
|
||||
|
||||
// update/delete Cost Detail and recalculate Current Cost
|
||||
MCostDetail cd = MCostDetail.get (getCtx(), "C_InvoiceLine_ID=?",
|
||||
|
|
|
@ -425,17 +425,10 @@ public class MMatchInv extends X_M_MatchInv
|
|||
{
|
||||
MAcctSchema as = acctschemas[asn];
|
||||
|
||||
boolean skip = false;
|
||||
if (as.getAD_OrgOnly_ID() != 0)
|
||||
if (as.isSkipOrg(getAD_Org_ID()))
|
||||
{
|
||||
if (as.getOnlyOrgs() == null)
|
||||
as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
|
||||
0, MAcctSchemaElement.ELEMENTTYPE_Organization,
|
||||
as.getAD_OrgOnly_ID()));
|
||||
skip = as.isSkipOrg(getAD_Org_ID());
|
||||
}
|
||||
if (skip)
|
||||
continue;
|
||||
}
|
||||
|
||||
BigDecimal LineNetAmt = invoiceLine.getLineNetAmt();
|
||||
BigDecimal multiplier = getQty()
|
||||
|
@ -505,17 +498,10 @@ public class MMatchInv extends X_M_MatchInv
|
|||
{
|
||||
MAcctSchema as = acctschemas[asn];
|
||||
|
||||
boolean skip = false;
|
||||
if (as.getAD_OrgOnly_ID() != 0)
|
||||
if (as.isSkipOrg(getAD_Org_ID()))
|
||||
{
|
||||
if (as.getOnlyOrgs() == null)
|
||||
as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
|
||||
0, MAcctSchemaElement.ELEMENTTYPE_Organization,
|
||||
as.getAD_OrgOnly_ID()));
|
||||
skip = as.isSkipOrg(getAD_Org_ID());
|
||||
}
|
||||
if (skip)
|
||||
continue;
|
||||
}
|
||||
|
||||
// update/delete Cost Detail and recalculate Current Cost
|
||||
MCostDetail cd = MCostDetail.get (getCtx(), "C_InvoiceLine_ID=?",
|
||||
|
|
|
@ -866,17 +866,10 @@ public class MMatchPO extends X_M_MatchPO
|
|||
{
|
||||
MAcctSchema as = acctschemas[asn];
|
||||
|
||||
boolean skip = false;
|
||||
if (as.getAD_OrgOnly_ID() != 0)
|
||||
if (as.isSkipOrg(getAD_Org_ID()))
|
||||
{
|
||||
if (as.getOnlyOrgs() == null)
|
||||
as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
|
||||
0, MAcctSchemaElement.ELEMENTTYPE_Organization,
|
||||
as.getAD_OrgOnly_ID()));
|
||||
skip = as.isSkipOrg(getAD_Org_ID());
|
||||
}
|
||||
if (skip)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Purchase Order Line
|
||||
BigDecimal poCost = oLine.getPriceCost();
|
||||
|
@ -958,17 +951,10 @@ public class MMatchPO extends X_M_MatchPO
|
|||
{
|
||||
MAcctSchema as = acctschemas[asn];
|
||||
|
||||
boolean skip = false;
|
||||
if (as.getAD_OrgOnly_ID() != 0)
|
||||
if (as.isSkipOrg(getAD_Org_ID()))
|
||||
{
|
||||
if (as.getOnlyOrgs() == null)
|
||||
as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
|
||||
0, MAcctSchemaElement.ELEMENTTYPE_Organization,
|
||||
as.getAD_OrgOnly_ID()));
|
||||
skip = as.isSkipOrg(getAD_Org_ID());
|
||||
}
|
||||
if (skip)
|
||||
continue;
|
||||
}
|
||||
|
||||
// update/delete Cost Detail and recalculate Current Cost
|
||||
MCostDetail cd = MCostDetail.get (getCtx(), "C_OrderLine_ID=?",
|
||||
|
|
|
@ -2342,17 +2342,10 @@ public class MOrder extends X_C_Order implements DocAction
|
|||
{
|
||||
MAcctSchema as = acctschemas[asn];
|
||||
|
||||
boolean skip = false;
|
||||
if (as.getAD_OrgOnly_ID() != 0)
|
||||
if (as.isSkipOrg(getAD_Org_ID()))
|
||||
{
|
||||
if (as.getOnlyOrgs() == null)
|
||||
as.setOnlyOrgs(MReportTree.getChildIDs(getCtx(),
|
||||
0, MAcctSchemaElement.ELEMENTTYPE_Organization,
|
||||
as.getAD_OrgOnly_ID()));
|
||||
skip = as.isSkipOrg(getAD_Org_ID());
|
||||
}
|
||||
if (skip)
|
||||
continue;
|
||||
}
|
||||
|
||||
// update/delete Cost Detail and recalculate Current Cost
|
||||
MMatchPO[] mPO = MMatchPO.getOrderLine(getCtx(), line.getC_OrderLine_ID(), get_TrxName());
|
||||
|
|
|
@ -821,28 +821,24 @@ public class Login
|
|||
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(Env.getCtx(), AD_Client_ID);
|
||||
if(ass != null && ass.length > 1)
|
||||
{
|
||||
for(MAcctSchema as: ass)
|
||||
for(MAcctSchema as : ass)
|
||||
{
|
||||
C_AcctSchema_ID = MClientInfo.get(Env.getCtx(), AD_Client_ID).getC_AcctSchema1_ID();
|
||||
boolean skip = false;
|
||||
if (as.getAD_OrgOnly_ID() != 0)
|
||||
C_AcctSchema_ID = MClientInfo.get(Env.getCtx(), AD_Client_ID).getC_AcctSchema1_ID();
|
||||
if (as.getAD_OrgOnly_ID() != 0)
|
||||
{
|
||||
if (as.isSkipOrg(AD_Org_ID))
|
||||
{
|
||||
if (as.getOnlyOrgs() == null)
|
||||
as.setOnlyOrgs(MReportTree.getChildIDs(Env.getCtx(),
|
||||
0, MAcctSchemaElement.ELEMENTTYPE_Organization,
|
||||
as.getAD_OrgOnly_ID()));
|
||||
skip = as.isSkipOrg(AD_Org_ID);
|
||||
if(skip)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
C_AcctSchema_ID = as.getC_AcctSchema_ID();
|
||||
Env.setContext(m_ctx, "$C_AcctSchema_ID", C_AcctSchema_ID);
|
||||
Env.setContext(m_ctx, "$C_Currency_ID", as.getC_Currency_ID());
|
||||
Env.setContext(m_ctx, "$HasAlias", as.isHasAlias());
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
C_AcctSchema_ID = as.getC_AcctSchema_ID();
|
||||
Env.setContext(m_ctx, "$C_AcctSchema_ID", C_AcctSchema_ID);
|
||||
Env.setContext(m_ctx, "$C_Currency_ID", as.getC_Currency_ID());
|
||||
Env.setContext(m_ctx, "$HasAlias", as.isHasAlias());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import javax.swing.JFileChooser;
|
|||
import junit.framework.TestCase;
|
||||
|
||||
import org.compiere.util.CLogMgt;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.Trx;
|
||||
|
@ -32,8 +33,8 @@ import org.compiere.util.Trx;
|
|||
* ADempiere Base Test Case
|
||||
* @author Teo Sarca
|
||||
*/
|
||||
public class AdempiereTestCase extends TestCase {
|
||||
|
||||
public class AdempiereTestCase extends TestCase
|
||||
{
|
||||
// Test: General
|
||||
protected Properties testProperties = null;
|
||||
protected String testPropertiesFileName = "test.properties";
|
||||
|
@ -65,6 +66,9 @@ public class AdempiereTestCase extends TestCase {
|
|||
public final String LogLevel_Key = "LogLevel";
|
||||
private String LogLevel_DefaultValue = Level.FINEST.toString();
|
||||
private Level LogLevel_Value = Level.FINEST;
|
||||
|
||||
/** Logger */
|
||||
protected final CLogger log = CLogger.getCLogger(getClass());
|
||||
|
||||
/** Trx name */
|
||||
private String trxName = Trx.createTrxName(getClass().getName()+"_");
|
||||
|
@ -120,6 +124,7 @@ public class AdempiereTestCase extends TestCase {
|
|||
testProperties = new Properties();
|
||||
File file = new File(testPropertiesFileName);
|
||||
if (!file.isFile()) {
|
||||
log.warning("File not found - "+file.getAbsolutePath());
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
int returnVal = chooser.showOpenDialog(null);
|
||||
if(returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
|
|
Loading…
Reference in New Issue