IDEMPIERE-4723 - Clean up code -> MD/ME/MG/MF classes (#787)

This commit is contained in:
Diego Ruiz 2021-07-23 08:18:03 +02:00 committed by GitHub
parent 86de1669a4
commit 3f52286bbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 16 additions and 261 deletions

View File

@ -130,8 +130,6 @@ public class MDepositBatch extends X_C_DepositBatch
/** Process Message */
private String m_processMsg = null;
/** Just Prepared Flag */
// private boolean m_justPrepared = false;
/**
* Unlock Document.
@ -224,10 +222,7 @@ public class MDepositBatch extends X_C_DepositBatch
*/
public File createPDF (File file)
{
// ReportEngine re = ReportEngine.get (getCtx(), ReportEngine.INVOICE, getC_Invoice_ID());
// if (re == null)
return null;
// return re.getPDF(file);
return null;
} // createPDF

View File

@ -194,8 +194,6 @@ public class MDepreciation extends X_A_Depreciation implements ImmutablePOSuppor
{
String depreciationType = getDepreciationType();
BigDecimal retValue = null;
//~ int offset = getFixMonthOffset();
//~ A_Current_Period += offset;
if(CLogMgt.isLevelFinest())
{
@ -376,9 +374,6 @@ public class MDepreciation extends X_A_Depreciation implements ImmutablePOSuppor
*/
private BigDecimal apply_ARH_AD1(MDepreciationWorkfile wk, MAssetAcct assetAcct, int A_Current_Period,BigDecimal Accum_Dep)
{
//~ /** Current Worksheet */
//~ MDepreciationWorkfile wk = MDepreciationWorkfile.get(getCtx(), A_Asset_ID, PostingType);
/** FAs' value = acquisition value - the amount recovered */
BigDecimal assetAmt = wk.getActualCost();
/** Life in months */
@ -387,29 +382,16 @@ public class MDepreciation extends X_A_Depreciation implements ImmutablePOSuppor
int A_Current_Year = (int)(A_Current_Period / 12);
/** Life in years = integer part of (the life in months / 12) => first year will be 0 */
int A_Life_Year = (int)(A_Life_Period / 12);
//~ /** Number of years of use remaining (including current year) */
//~ int A_RemainingLife_Year = A_Life_Year - A_Current_Year;
/** Coefficient K */
/* @win : looks like a country specific requirement
BigDecimal coef_K = get_AD_K(A_Life_Year);
*/
/** Linear damping coefficient for one year = 1 / total number of years */
BigDecimal coef_sl = BigDecimal.ONE.divide(new BigDecimal(A_Life_Year), getPrecision() + 2, RoundingMode.DOWN);
/** Degressive damping coefficient for one year = one-year linear depreciation * coeficient K */
//BigDecimal coef_ad1 = coef_sl.multiply(coef_K); //commented by @win
BigDecimal coef_ad1 = coef_sl.multiply(BigDecimal.valueOf(2.0)); //added by @win
/** AD2 */
//~ BigDecimal DUR = BD_100.multiply(
// logging
if (log.isLoggable(Level.FINE)) {
log.fine("assetAmt=" + assetAmt + ", A_Life_Period=" + A_Life_Period);
log.fine("A_Current_Year=" + A_Current_Year + ", A_Life_Year=" + A_Life_Year);
//log.fine("coef_K=" + coef_K + ", coef_sl=" + coef_sl + ", coef_ad1=" + coef_ad1); //commented out by @win
}
/** Depreciation for the current year, is calculated below */
@ -470,30 +452,6 @@ public class MDepreciation extends X_A_Depreciation implements ImmutablePOSuppor
throw new AssetNotImplementedException("AD2");
}
/** For depreciation regime skimmed returns coefficient K depending on the life of FAs
* @param A_Life_Year life in years
* @return coeficient K degressive method for
* @see #apply_ARH_AD1(int, int, String, int, BigDecimal)
*/
/*private static BigDecimal get_AD_K(int A_Life_Year)
{
if (A_Life_Year < 2) {
throw new IllegalArgumentException("@A_Life_Year@ = " + A_Life_Year + " < 2");
}
// A_Life_Year in [2, 5]
else if (A_Life_Year <= 5) {
return new BigDecimal(1.5);
}
// A_Life_Year in (5, 10]
else if (A_Life_Year <= 10) {
return new BigDecimal(2.0);
}
// A_Life_Year in (10, infinit)
else {
return new BigDecimal(2.5);
}
}*/
/** Calculate the value of depreciation over a month (period). In the last month of the year we add errors from the adjustment calculation
* @param A_Current_Period current month's index
* @param amtPerYear value of depreciation per year

View File

@ -30,9 +30,6 @@ public class MDepreciationConvention extends X_A_Depreciation_Convention impleme
public MDepreciationConvention(Properties ctx, int A_Depreciation_Convention_ID, String trxName)
{
super (ctx, A_Depreciation_Convention_ID, trxName);
//~ if (A_Depreciation_Convention_ID == 0)
//~ {
//~ }
} // MDepreciationConvention
/**
@ -78,8 +75,6 @@ public class MDepreciationConvention extends X_A_Depreciation_Convention impleme
/** Cache */
private static ImmutableIntPOCache<Integer,MDepreciationConvention> s_cache = new ImmutableIntPOCache<Integer,MDepreciationConvention>(Table_Name, 5);
//~ /** Static logger */
//~ private static Logger s_log = CLogger.getCLogger(MDepreciationConvention.class);
/**
* Get MDepreciationConvention from cache (immutable)

View File

@ -181,7 +181,6 @@ implements DocAction
public boolean unlockIt()
{
if (log.isLoggable(Level.INFO)) log.info("unlockIt - " + toString());
// setProcessing(false);
return true;
} // unlockIt

View File

@ -31,20 +31,6 @@ public class MDepreciationExp extends X_A_Depreciation_Exp
public MDepreciationExp(Properties ctx, int A_Depreciation_Exp_ID, String trxName)
{
super (ctx, A_Depreciation_Exp_ID, trxName);
/**
if (A_Depreciation_Exp_ID == 0)
{
setA_Account_Number (0);
setA_Asset_ID (0);
setA_Depreciation_Exp_ID (0);
setA_Entry_Type (null);
setA_Period (0);
setDescription (null);
setExpense (Env.ZERO);
setIsDepreciated (false);
setProcessed (false);
}
*/
}
/** Load Constructor */
@ -209,7 +195,6 @@ public class MDepreciationExp extends X_A_Depreciation_Exp
Collection<MDepreciationWorkfile> workFiles = MDepreciationWorkfile.forA_Asset_ID(getCtx(), getA_Asset_ID(), get_TrxName());
for(MDepreciationWorkfile assetwk : workFiles) {
// TODO : check if we can reverse it (check period, check dateacct etc)
//MDepreciationWorkfile assetwk = getA_Depreciation_Workfile();
assetwk.adjustAccumulatedDepr(getA_Accumulated_Depr().negate(), getA_Accumulated_Depr_F().negate(), false);
assetwk.saveEx();
}
@ -236,7 +221,6 @@ public class MDepreciationExp extends X_A_Depreciation_Exp
{
Collection<MDepreciationWorkfile> workFiles = MDepreciationWorkfile.forA_Asset_ID(getCtx(), getA_Asset_ID(), get_TrxName());
for(MDepreciationWorkfile wk : workFiles) {
//MDepreciationWorkfile wk = getA_Depreciation_Workfile();
wk.setA_Current_Period();
wk.saveEx();
}

View File

@ -107,21 +107,6 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
return asset.getAssetServiceDate();
}
/** Gets asset's class
* @return asset class id
*/
/* commented out by @win
public int getA_Asset_Class_ID()
{
MAsset asset = getAsset();
if (asset == null) {
return 0;
}
return asset.getA_Asset_Class_ID();
}
*/ // end comment by @win
/** After save
* @param newRecord
* @return true on success
@ -431,32 +416,6 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
newCost = newCost.add(deltaAmt);
newQty = newQty.add(deltaQty);
// TODO: crashes if I cancel an Issue:
// if (newQty.signum() < 0) {
// throw new ArhRuntimeException(getCtx(), "@A_QTY_Current@ < 0");
// }
//
// There must be verified that the remaining value to be greater than the amount diminished
// total devaluation because if the entire asset value (A_Asset_Cost) must be brought to 0.
// if (deltaAmt.signum() < 0)
// {
// BigDecimal remainingAmt_C = getRemainingCost(null, false);
// if (remainingAmt_C.compareTo(deltaAmt.negate()) < 0)
// {
// throw new ArhRuntimeException(getCtx(), "@A_Asset_Remaining@ < @DeltaAmt@")
// .addInfo("@A_Asset_Cost@=", getA_Asset_Cost())
// .addInfo("@A_Accumulated_Depr@=", getA_Accumulated_Depr());
// }
// BigDecimal remainingAmt_F = getRemainingCost(null, true);
// if (remainingAmt_F.compareTo(deltaAmt.negate()) < 0)
// {
// throw new ArhRuntimeException(getCtx(), "@A_Asset_Remaining_F@ < @DeltaAmt@")
// .addInfo("@A_Asset_Cost=@", getA_Asset_Cost())
// .addInfo("@A_Accumulated_Depr@=", getA_Accumulated_Depr_F());
// }
// }
setA_Asset_Cost(newCost);
setA_QTY_Current(newQty);
@ -639,8 +598,6 @@ public class MDepreciationWorkfile extends X_A_Depreciation_Workfile
// TODO: teo_sarca: need to evaluate what happens when we change Depreciation method !!!
MDepreciation depreciation_C = MDepreciation.get(getCtx(), assetacct.getA_Depreciation_ID());
MDepreciation depreciation_F = MDepreciation.get(getCtx(), assetacct.getA_Depreciation_F_ID());
//~ int offset_C = depreciation_C.getFixMonthOffset();
//~ int offset_F = depreciation_F.getFixMonthOffset();
int offset_C = 0, offset_F = 0;
BigDecimal assetCost = getActualCost();

View File

@ -91,13 +91,11 @@ public class MDiscountSchema extends X_M_DiscountSchema implements ImmutablePOSu
super (ctx, M_DiscountSchema_ID, trxName);
if (M_DiscountSchema_ID == 0)
{
// setName();
setDiscountType (DISCOUNTTYPE_FlatPercent);
setFlatDiscount(Env.ZERO);
setIsBPartnerFlatDiscount (false);
setIsQuantityBased (true); // Y
setCumulativeLevel(CUMULATIVELEVEL_Line);
// setValidFrom (new Timestamp(System.currentTimeMillis()));
}
} // MDiscountSchema

View File

@ -267,9 +267,6 @@ public class MDistribution extends X_GL_Distribution
super (ctx, GL_Distribution_ID, trxName);
if (GL_Distribution_ID == 0)
{
// setC_AcctSchema_ID (0);
// setName (null);
//
setAnyAcct (true); // Y
setAnyActivity (true); // Y
setAnyBPartner (true); // Y
@ -442,7 +439,6 @@ public class MDistribution extends X_GL_Distribution
dl.calculateQty (Qty);
total = total.add(dl.getAmt());
totalQty = totalQty.add(dl.getQty());
// log.fine("distribute - Line=" + dl.getLine() + " - " + dl.getPercent() + "% " + dl.getAmt() + " - Total=" + total);
// Remainder
if (dl.getPercent().compareTo(Env.ZERO) == 0)
indexZeroPercent = i;
@ -460,12 +456,10 @@ public class MDistribution extends X_GL_Distribution
{
if (indexZeroPercent != -1)
{
// log.fine("distribute - Difference=" + difference + " - 0%Line=" + m_lines[indexZeroPercent]);
m_lines[indexZeroPercent].setAmt (difference);
}
else if (indexBiggest != -1)
{
// log.fine("distribute - Difference=" + difference + " - MaxLine=" + m_lines[indexBiggest] + " - " + m_lines[indexBiggest].getAmt());
m_lines[indexBiggest].setAmt (m_lines[indexBiggest].getAmt().add(difference));
}
else
@ -477,12 +471,10 @@ public class MDistribution extends X_GL_Distribution
{
if (indexZeroPercent != -1)
{
// log.fine("distribute - Difference=" + difference + " - 0%Line=" + m_lines[indexZeroPercent]);
m_lines[indexZeroPercent].setQty (differenceQty);
}
else if (indexBiggest != -1)
{
// log.fine("distribute - Difference=" + difference + " - MaxLine=" + m_lines[indexBiggest] + " - " + m_lines[indexBiggest].getAmt());
m_lines[indexBiggest].setQty (m_lines[indexBiggest].getQty().add(differenceQty));
}
else

View File

@ -49,9 +49,6 @@ public class MDistributionLine extends X_GL_DistributionLine
super (ctx, GL_DistributionLine_ID, trxName);
if (GL_DistributionLine_ID == 0)
{
// setGL_Distribution_ID (0); // Parent
// setLine (0);
//
setOverwriteAcct (false);
setOverwriteActivity (false);
setOverwriteBPartner (false);

View File

@ -202,7 +202,6 @@ public class MDistributionRunLine extends X_M_DistributionRunLine
m_actualQty = Env.ZERO;
m_actualMin = Env.ZERO;
m_actualAllocation = Env.ZERO;
// m_lastDifference = Env.ZERO;
m_maxAllocation = Env.ZERO;
} // resetCalculations

View File

@ -131,10 +131,6 @@ public class MDocType extends X_C_DocType implements ImmutablePOSupport
super(ctx, C_DocType_ID, trxName);
if (C_DocType_ID == 0)
{
// setName (null);
// setPrintName (null);
// setDocBaseType (null);
// setGL_Category_ID (0);
setDocumentCopies (0);
setHasCharges (false);
setIsDefault (false);
@ -143,7 +139,6 @@ public class MDocType extends X_C_DocType implements ImmutablePOSupport
setIsPickQAConfirm(false);
setIsShipConfirm(false);
setIsSplitWhenDifference(false);
//
setIsCreateCounter(true);
setIsDefaultCounterDoc(false);
setIsIndexed(true);
@ -297,8 +292,6 @@ public class MDocType extends X_C_DocType implements ImmutablePOSupport
*/
protected boolean beforeSave (boolean newRecord)
{
/*if (getAD_Org_ID() != 0)
setAD_Org_ID(0);*/
return true;
} // beforeSave

View File

@ -52,7 +52,6 @@ public class MDunningRun extends X_C_DunningRun
super (ctx, C_DunningRun_ID, trxName);
if (C_DunningRun_ID == 0)
{
// setC_DunningLevel_ID (0);
setDunningDate (new Timestamp(System.currentTimeMillis()));
setProcessed (false);
}

View File

@ -58,12 +58,6 @@ public class MDunningRunEntry extends X_C_DunningRunEntry
super (ctx, C_DunningRunEntry_ID, trxName);
if (C_DunningRunEntry_ID == 0)
{
// setC_BPartner_ID (0);
// setC_BPartner_Location_ID (0);
// setAD_User_ID (0);
// setSalesRep_ID (0);
// setC_Currency_ID (0);
setAmt (Env.ZERO);
setQty (Env.ZERO);
setProcessed (false);
@ -264,17 +258,6 @@ public class MDunningRunEntry extends X_C_DunningRunEntry
return retValue;
} // hasInvoices
/**
* Get Parent
* @return Dunning Run
*/
/*private MDunningRun getParent()
{
if (m_parent == null)
m_parent = new MDunningRun(getCtx(), getC_DunningRun_ID (), get_TrxName());
return m_parent;
} // getParent*/
@Override
protected boolean beforeSave (boolean newRecord)
{

View File

@ -199,28 +199,6 @@ public class MDunningRunLine extends X_C_DunningRunLine
return m_payment;
} // getPayment
/**
* Set Payment
*
public void setPayment (MPayment payment)
{
m_payment = payment;
if (payment != null)
{
m_C_CurrencyFrom_ID = payment.getC_Currency_ID();
setAmt(payment.getPayAmt()); // need to reverse
setOpenAmt(getAmt()); // not correct
setConvertedAmt (MConversionRate.convert(getCtx(), getOpenAmt(),
getC_CurrencyFrom_ID(), getC_CurrencyTo_ID(), getAD_Client_ID(), getAD_Org_ID()));
}
else
{
m_C_CurrencyFrom_ID = 0;
setAmt(Env.ZERO);
setConvertedAmt(Env.ZERO);
}
} // setPayment
/**
* Set Payment
* @param C_Payment_ID

View File

@ -103,8 +103,6 @@ public class MEXPFormatLine extends X_EXP_FormatLine implements ImmutablePOSuppo
StringBuilder sql = new StringBuilder("SELECT * ")
.append(" FROM ").append(X_EXP_FormatLine.Table_Name)
.append(" WHERE ").append(X_EXP_Format.COLUMNNAME_Value).append("=?")
//.append(" AND IsActive = ?")
//.append(" AND AD_Client_ID = ?")
.append(" AND ").append(X_EXP_Format.COLUMNNAME_EXP_Format_ID).append(" = ?")
;
PreparedStatement pstmt = null;

View File

@ -45,9 +45,6 @@ public class MElement extends X_C_Element
super(ctx, C_Element_ID, trxName);
if (C_Element_ID == 0)
{
// setName (null);
// setAD_Tree_ID (0);
// setElementType (null); // A
setIsBalancing (false);
setIsNaturalAccount (false);
}

View File

@ -52,9 +52,6 @@ public class MElementValue extends X_C_ElementValue implements ImmutablePOSuppor
super(ctx, C_ElementValue_ID, trxName);
if (C_ElementValue_ID == 0)
{
// setC_Element_ID (0); // Parent
// setName (null);
// setValue (null);
setIsSummary (false);
setAccountSign (ACCOUNTSIGN_Natural);
setAccountType (ACCOUNTTYPE_Expense);
@ -167,13 +164,6 @@ public class MElementValue extends X_C_ElementValue implements ImmutablePOSuppor
setPostBudget(imp.isPostBudget());
setPostEncumbrance(imp.isPostEncumbrance());
setPostStatistical(imp.isPostStatistical());
//
// setC_BankAccount_ID(imp.getC_BankAccount_ID());
// setIsForeignCurrency(imp.isForeignCurrency());
// setC_Currency_ID(imp.getC_Currency_ID());
// setIsBankAccount(imp.isIsBankAccount());
// setValidFrom(null);
// setValidTo(null);
} // set

View File

@ -187,31 +187,7 @@ public class MEntityType extends X_AD_EntityType implements ImmutablePOSupport
return false;
}
}
else // new
{
/*
setEntityType(getEntityType().toUpperCase()); // upper case
if (getEntityType().trim().length() < 4)
{
log.saveError("FillMandatory", Msg.getElement(getCtx(), "EntityType")
+ " - 4 Characters");
return false;
}
boolean ok = true;
char[] cc = getEntityType().toCharArray();
for (int i = 0; i < cc.length; i++)
{
char c = cc[i];
if (Character.isDigit(c) || (c >= 'A' && c <= 'Z'))
continue;
//
log.saveError("FillMandatory", Msg.getElement(getCtx(), "EntityType")
+ " - Must be ASCII Letter or Digit");
return false;
}
*/
//setAD_EntityType_ID();
} // new
return true;
} // beforeSave

View File

@ -83,9 +83,6 @@ public class MField extends X_AD_Field implements ImmutablePOSupport
super (ctx, AD_Field_ID, trxName);
if (AD_Field_ID == 0)
{
// setAD_Tab_ID (0); // parent
// setAD_Column_ID (0);
// setName (null);
setEntityType (ENTITYTYPE_UserMaintained); // U
setIsCentrallyMaintained (true); // Y
setIsDisplayed (true); // Y
@ -95,7 +92,6 @@ public class MField extends X_AD_Field implements ImmutablePOSupport
setIsHeading (false);
setIsReadOnly (false);
setIsSameLine (false);
// setObscureType(OBSCURETYPE_ObscureDigitsButLast4);
}
} // MField

View File

@ -46,8 +46,6 @@ public class MFormAccess extends X_AD_Form_Access
throw new IllegalArgumentException("Multi-Key");
else
{
// setAD_Form_ID (0);
// setAD_Role_ID (0);
setIsReadWrite (true);
}
} // MFormAccess

View File

@ -154,7 +154,6 @@ public class MGLCategory extends X_GL_Category implements ImmutablePOSupport
super (ctx, GL_Category_ID, trxName);
if (GL_Category_ID == 0)
{
// setName (null);
setCategoryType (CATEGORYTYPE_Manual);
setIsDefault (false);
}

View File

@ -266,9 +266,6 @@ public class MGoal extends X_PA_Goal
super (ctx, PA_Goal_ID, trxName);
if (PA_Goal_ID == 0)
{
// setName (null);
// setAD_User_ID (0);
// setPA_ColorSchema_ID (0);
setSeqNo (0);
setIsSummary (false);
setMeasureScope (MEASUREDISPLAY_Year);
@ -536,9 +533,6 @@ public class MGoal extends X_PA_Goal
*/
protected boolean beforeSave (boolean newRecord)
{
// if (getMultiplier(this) == null) // error
// setMeasureDisplay(getMeasureScope());
// Measure required if nor Summary
if (!isSummary() && getPA_Measure_ID() == 0)
{

View File

@ -112,29 +112,25 @@ public class MIFixedAsset extends X_I_FixedAsset
/**
*/
private void fixAmount(int idx) {
//~ try {
BigDecimal amt = (BigDecimal)get_Value(idx);
if (amt == null)
return;
int precision = getStdPrecision();
BigDecimal newAmt = amt.setScale(getStdPrecision(), RoundingMode.HALF_UP);
set_Value(idx, newAmt);
if (log.isLoggable(Level.FINE)) log.fine(getInventoryNo() + ": " + get_ColumnName(idx) + "=" + amt + "->" + newAmt + " (precision=" + precision + ")");
//~ } catch (Exception e) {}
BigDecimal amt = (BigDecimal)get_Value(idx);
if (amt == null)
return;
int precision = getStdPrecision();
BigDecimal newAmt = amt.setScale(getStdPrecision(), RoundingMode.HALF_UP);
set_Value(idx, newAmt);
if (log.isLoggable(Level.FINE)) log.fine(getInventoryNo() + ": " + get_ColumnName(idx) + "=" + amt + "->" + newAmt + " (precision=" + precision + ")");
}
/**
*/
private void fixKeyValue(int idx) {
//~ try {
String name = (String)get_Value(idx);
if (name == null)
return;
String newName = name.trim().replaceAll("[ ]+", " ");
if (log.isLoggable(Level.FINE)) log.fine(getInventoryNo() + ": " + get_ColumnName(idx) + "=[" + name + "]->[" + newName + "]");
set_Value(idx, newName);
//~ } catch (Exception e) {}
String name = (String)get_Value(idx);
if (name == null)
return;
String newName = name.trim().replaceAll("[ ]+", " ");
if (log.isLoggable(Level.FINE)) log.fine(getInventoryNo() + ": " + get_ColumnName(idx) + "=[" + name + "]->[" + newName + "]");
set_Value(idx, newName);
}
/**
@ -150,16 +146,6 @@ public class MIFixedAsset extends X_I_FixedAsset
{
throw new FillMandatoryException(COLUMNNAME_UseLifeMonths);
}
/*//comment by @win
if (getA_Asset_Class_ID() <= 0)
{
throw new FillMandatoryException(COLUMNNAME_A_Asset_Class_ID);
}
// Fix Asset Class
MAssetClass assetClass = MAssetClass.get(getCtx(), getA_Asset_Class_ID());
setA_Asset_Class_Value(assetClass.getValue());
*/ //end comment by @win
// Round amounts:
int col_count = get_ColumnCount();
@ -249,12 +235,6 @@ public class MIFixedAsset extends X_I_FixedAsset
*/
public boolean isDepreciating()
{
/* commented by @win
MAssetClass assetClass = MAssetClass.get(getCtx(), getA_Asset_Class_ID());
if (assetClass == null)
return false;
return assetClass.isDepreciated();
*/
//change logic to assetGroup
MAssetGroup assetGroup = MAssetGroup.get(getCtx(), getA_Asset_Group_ID());
if (assetGroup == null)