From 02d526374276aa07921a04293b3341068f375906 Mon Sep 17 00:00:00 2001 From: Diego Ruiz <12065321+d-ruiz@users.noreply.github.com> Date: Sat, 24 Jul 2021 07:26:36 +0200 Subject: [PATCH] IDEMPIERE-4723 - Clean up code -> MI/MPa classes (#793) --- .../src/org/compiere/model/MIMPProcessor.java | 2 - .../src/org/compiere/model/MInOut.java | 1 - .../src/org/compiere/model/MInfoWindow.java | 15 +--- .../org/compiere/model/MInfoWindowAccess.java | 5 -- .../org/compiere/model/MPAttributeLookup.java | 3 - .../src/org/compiere/model/MPackage.java | 4 -- .../src/org/compiere/model/MPackageLine.java | 2 - .../src/org/compiere/model/MPasswordRule.java | 6 -- .../src/org/compiere/model/MPaySchedule.java | 1 - .../src/org/compiere/model/MPaySelection.java | 3 - .../compiere/model/MPaySelectionCheck.java | 3 - .../org/compiere/model/MPaySelectionLine.java | 4 -- .../src/org/compiere/model/MPayment.java | 71 ++++--------------- .../org/compiere/model/MPaymentAllocate.java | 2 - .../src/org/compiere/model/MPaymentBatch.java | 1 - .../org/compiere/model/MPaymentProcessor.java | 6 -- .../src/org/compiere/model/MPaymentTerm.java | 11 --- .../compiere/model/MPaymentTransaction.java | 7 -- .../org/compiere/model/MPaymentValidate.java | 2 - 19 files changed, 14 insertions(+), 135 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MIMPProcessor.java b/org.adempiere.base/src/org/compiere/model/MIMPProcessor.java index 079f3021bb..2bb123e65a 100644 --- a/org.adempiere.base/src/org/compiere/model/MIMPProcessor.java +++ b/org.adempiere.base/src/org/compiere/model/MIMPProcessor.java @@ -60,7 +60,6 @@ public class MIMPProcessor super(ctx, EXP_ReplicationProcessor_ID, trxName); if (EXP_ReplicationProcessor_ID == 0) { - //setValue (/*client.getName() + " - " +*/ "Default Import Processor"); setName (/*client.getName() + " - " +*/ "Default Import Processor"); setFrequencyType (FREQUENCYTYPE_Hour); setFrequency (1); @@ -147,7 +146,6 @@ public class MIMPProcessor .append(" FROM ").append(X_IMP_ProcessorParameter.Table_Name) .append(" WHERE ").append(X_IMP_ProcessorParameter.COLUMNNAME_IMP_Processor_ID).append("=?") // # 1 .append(" AND IsActive = ?") // # 2 - //.append(" ORDER BY ").append(X_EXP_ProcessorParameter.COLUMNNAME_) ; PreparedStatement pstmt = null; ResultSet rs = null; diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index 807587b4c9..4e0fe9c217 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -1904,7 +1904,6 @@ public class MInOut extends X_M_InOut implements DocAction if (product != null && line.getM_Locator_ID() == 0) { - //MWarehouse w = MWarehouse.get(getCtx(), getM_Warehouse_ID()); line.setM_Warehouse_ID(getM_Warehouse_ID()); line.setM_Locator_ID(inTrx ? Env.ZERO : line.getMovementQty()); // default Locator needSave = true; diff --git a/org.adempiere.base/src/org/compiere/model/MInfoWindow.java b/org.adempiere.base/src/org/compiere/model/MInfoWindow.java index 985bd097b8..74d4f14732 100644 --- a/org.adempiere.base/src/org/compiere/model/MInfoWindow.java +++ b/org.adempiere.base/src/org/compiere/model/MInfoWindow.java @@ -271,18 +271,11 @@ public class MInfoWindow extends X_AD_InfoWindow { if (i != 0) // can also use if i>0 sql.append(","); - sql.append(mColumns[i].getSelectClause());//getColumnSQL()); // Normal and Virtual Column + sql.append(mColumns[i].getSelectClause()); // Normal and Virtual Column } - sql.append(" FROM ").append(fromsql)//getTableName()) - //.append(" WHERE ") - //.append(getWhereClause(false)) + sql.append(" FROM ").append(fromsql) .append(oclause); - //.append("ORDER BY SeqNo"); //.append(get_WhereClause(false)); - // - // int index = -1; - //if (CLogMgt.isLevelFinest()) - //log.finest(getWhereClause(true)); log.info("Generated SQL -- getSql: "+ sql.toString()); return sql.toString(); @@ -299,7 +292,6 @@ public class MInfoWindow extends X_AD_InfoWindow MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); pstmt = DB.prepareStatement(countSql, null); - // pstmt.setString(1, p_tableName); rs = pstmt.executeQuery(); while (rs.next()) { @@ -308,10 +300,7 @@ public class MInfoWindow extends X_AD_InfoWindow } catch (SQLException e) { - //ADialog.error(WindowNo, c, AD_Message) - //Env.getUi().showError(0, null, sql.toString() + "
" + e.getMessage()); log.log(Level.SEVERE, sql, e); - // String error = e.toString(); // show error to user and return: TODO return false; } diff --git a/org.adempiere.base/src/org/compiere/model/MInfoWindowAccess.java b/org.adempiere.base/src/org/compiere/model/MInfoWindowAccess.java index abb47996c8..c55e0f3a9a 100644 --- a/org.adempiere.base/src/org/compiere/model/MInfoWindowAccess.java +++ b/org.adempiere.base/src/org/compiere/model/MInfoWindowAccess.java @@ -26,11 +26,6 @@ public class MInfoWindowAccess extends X_AD_InfoWindow_Access { super(ctx, 0, trxName); if (ignored != 0) throw new IllegalArgumentException("Multi-Key"); - else - { - // setAD_InfoWindow_ID (0); - // setAD_Role_ID (0); - } } /** diff --git a/org.adempiere.base/src/org/compiere/model/MPAttributeLookup.java b/org.adempiere.base/src/org/compiere/model/MPAttributeLookup.java index 33b9725ba0..012c06db9a 100644 --- a/org.adempiere.base/src/org/compiere/model/MPAttributeLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MPAttributeLookup.java @@ -54,11 +54,8 @@ public class MPAttributeLookup extends Lookup public MPAttributeLookup(Properties ctx, int WindowNo) { super(DisplayType.TableDir, WindowNo); -// m_ctx = ctx; } // MPAttribute -// /** Properties */ -// private Properties m_ctx; /** No Instance Value */ private static KeyNamePair NO_INSTANCE = new KeyNamePair (0,""); diff --git a/org.adempiere.base/src/org/compiere/model/MPackage.java b/org.adempiere.base/src/org/compiere/model/MPackage.java index ff08f6aefe..a00a656f64 100644 --- a/org.adempiere.base/src/org/compiere/model/MPackage.java +++ b/org.adempiere.base/src/org/compiere/model/MPackage.java @@ -121,9 +121,6 @@ public class MPackage extends X_M_Package super (ctx, M_Package_ID, trxName); if (M_Package_ID == 0) { - // setM_Shipper_ID (0); - // setDocumentNo (null); - // setM_InOut_ID (0); setShipDate (new Timestamp(System.currentTimeMillis())); MClientInfo clientInfo = MClientInfo.get(ctx, getAD_Client_ID()); @@ -577,7 +574,6 @@ public class MPackage extends X_M_Package st.setSalesRep_ID(ioOut.getSalesRep_ID()); st.setShipDate(getShipDate()); st.setShipperAccount(getShipperAccount()); -// st.setShippingRespMessage(ShippingRespMessage); st.setSurcharges(getSurcharges()); st.setTrackingInfo(getTrackingInfo()); st.setTrackingNo(getTrackingNo()); diff --git a/org.adempiere.base/src/org/compiere/model/MPackageLine.java b/org.adempiere.base/src/org/compiere/model/MPackageLine.java index 90619a73fe..c3b7565d1b 100644 --- a/org.adempiere.base/src/org/compiere/model/MPackageLine.java +++ b/org.adempiere.base/src/org/compiere/model/MPackageLine.java @@ -45,8 +45,6 @@ public class MPackageLine extends X_M_PackageLine super (ctx, M_PackageLine_ID, trxName); if (M_PackageLine_ID == 0) { - // setM_Package_ID (0); - // setM_InOutLine_ID (0); setQty (Env.ZERO); } } // MPackageLine diff --git a/org.adempiere.base/src/org/compiere/model/MPasswordRule.java b/org.adempiere.base/src/org/compiere/model/MPasswordRule.java index 534260598a..c57de3efef 100644 --- a/org.adempiere.base/src/org/compiere/model/MPasswordRule.java +++ b/org.adempiere.base/src/org/compiere/model/MPasswordRule.java @@ -186,12 +186,6 @@ public class MPasswordRule extends X_AD_PasswordRule { WordListDictionary dict = new WordListDictionary(awl); DictionarySubstringRule dictRule = new DictionarySubstringRule(dict); - /*if (getDictWordLength() > 0) {//when update library to passay. this method is miss - dictRule.setWordLength(getDictWordLength()); // size of words to check in the password - } else{ - dictRule.setWordLength(DictionarySubstringRule.DEFAULT_WORD_LENGTH); - }*/ - if (isDictMatchBackwards()) { dictRule.setMatchBackwards(true); // match dictionary words backwards } diff --git a/org.adempiere.base/src/org/compiere/model/MPaySchedule.java b/org.adempiere.base/src/org/compiere/model/MPaySchedule.java index aefec3540f..c2534d08ef 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaySchedule.java +++ b/org.adempiere.base/src/org/compiere/model/MPaySchedule.java @@ -45,7 +45,6 @@ public class MPaySchedule extends X_C_PaySchedule super(ctx, C_PaySchedule_ID, trxName); if (C_PaySchedule_ID == 0) { - // setC_PaymentTerm_ID (0); // Parent setPercentage (Env.ZERO); setDiscount (Env.ZERO); setDiscountDays (0); diff --git a/org.adempiere.base/src/org/compiere/model/MPaySelection.java b/org.adempiere.base/src/org/compiere/model/MPaySelection.java index fdcd931fc4..11087e9658 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaySelection.java +++ b/org.adempiere.base/src/org/compiere/model/MPaySelection.java @@ -47,9 +47,6 @@ public class MPaySelection extends X_C_PaySelection super(ctx, C_PaySelection_ID, trxName); if (C_PaySelection_ID == 0) { - // setC_BankAccount_ID (0); - // setName (null); // @#Date@ - // setPayDate (new Timestamp(System.currentTimeMillis())); // @#Date@ setTotalAmt (Env.ZERO); setIsApproved (false); setProcessed (false); diff --git a/org.adempiere.base/src/org/compiere/model/MPaySelectionCheck.java b/org.adempiere.base/src/org/compiere/model/MPaySelectionCheck.java index c000cff213..5e2dd0b924 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaySelectionCheck.java +++ b/org.adempiere.base/src/org/compiere/model/MPaySelectionCheck.java @@ -523,9 +523,6 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck super(ctx, C_PaySelectionCheck_ID, trxName); if (C_PaySelectionCheck_ID == 0) { - // setC_PaySelection_ID (0); - // setC_BPartner_ID (0); - // setPaymentRule (null); setPayAmt (Env.ZERO); setDiscountAmt(Env.ZERO); setWriteOffAmt(Env.ZERO); diff --git a/org.adempiere.base/src/org/compiere/model/MPaySelectionLine.java b/org.adempiere.base/src/org/compiere/model/MPaySelectionLine.java index 990b9f4093..0619eb96b1 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaySelectionLine.java +++ b/org.adempiere.base/src/org/compiere/model/MPaySelectionLine.java @@ -48,10 +48,6 @@ public class MPaySelectionLine extends X_C_PaySelectionLine super(ctx, C_PaySelectionLine_ID, trxName); if (C_PaySelectionLine_ID == 0) { - // setC_PaySelection_ID (0); - // setPaymentRule (null); // S - // setLine (0); // @SQL=SELECT NVL(MAX(Line),0)+10 AS DefaultValue FROM C_PaySelectionLine WHERE C_PaySelection_ID=@C_PaySelection_ID@ - // setC_Invoice_ID (0); setIsSOTrx (false); setOpenAmt(Env.ZERO); setPayAmt (Env.ZERO); diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index 08e154f186..9c0c1658d8 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -193,7 +193,6 @@ public class MPayment extends X_C_Payment setIsAllocated(false); setIsOnline(false); setIsDelayedCapture (false); - // setC_BPartner_ID(0); setC_Invoice_ID(0); setC_Order_ID(0); setC_Charge_ID(0); @@ -530,24 +529,17 @@ public class MPayment extends X_C_Payment setErrorMessage(Msg.getMsg(Env.getCtx(), "PaymentNoProcessor")); else { - // Validate before trying to process -// String msg = pp.validate(); -// if (msg!=null && msg.trim().length()>0) { -// setErrorMessage(Msg.getMsg(getCtx(), msg)); -// } else { - // Process if validation succeeds - approved = pp.processCC(); - - if (approved) - setErrorMessage(null); + approved = pp.processCC(); + + if (approved) + setErrorMessage(null); + else + { + if(getTrxType().equals(TRXTYPE_Void) || getTrxType().equals(TRXTYPE_CreditPayment)) + setErrorMessage("From " + getCreditCardName() + ": " + getR_VoidMsg()); else - { - if(getTrxType().equals(TRXTYPE_Void) || getTrxType().equals(TRXTYPE_CreditPayment)) - setErrorMessage("From " + getCreditCardName() + ": " + getR_VoidMsg()); - else - setErrorMessage("From " + getCreditCardName() + ": " + getR_RespMsg()); - } -// } + setErrorMessage("From " + getCreditCardName() + ": " + getR_RespMsg()); + } } } catch (Exception e) @@ -679,7 +671,6 @@ public class MPayment extends X_C_Payment return false; } // @Trifon - CashPayments - //if ( getTenderType().equals("X") ) { if ( isCashbookTrx()) { // Cash Book Is mandatory if ( getC_CashBook_ID() <= 0 ) { @@ -887,7 +878,6 @@ public class MPayment extends X_C_Payment + " INNER JOIN C_Payment p ON (al.C_Payment_ID=p.C_Payment_ID) " + "WHERE al.C_Payment_ID=?" + " AND ah.IsActive='Y' AND al.IsActive='Y'"; - // + " AND al.C_Invoice_ID IS NOT NULL"; PreparedStatement pstmt = null; ResultSet rs = null; try @@ -908,8 +898,6 @@ public class MPayment extends X_C_Payment rs = null; pstmt = null; } - // log.fine("getAllocatedAmt - " + retValue); - // ? ROUND(NVL(v_AllocatedAmt,0), 2); return retValue; } // getAllocatedAmt @@ -919,18 +907,6 @@ public class MPayment extends X_C_Payment */ public boolean testAllocation() { - // Cash Trx always allocated!!! WHY??? -/* @Trifon - CashPayments - if (isCashTrx()) - { - if (!isAllocated()) - { - setIsAllocated(true); - return true; - } - return false; - } -*/ // BigDecimal alloc = getAllocatedAmt(); if (alloc == null) @@ -1540,8 +1516,6 @@ public class MPayment extends X_C_Payment */ public void setC_DocType_ID (int C_DocType_ID) { - // if (getDocumentNo() != null && getC_DocType_ID() != C_DocType_ID) - // setDocumentNo(null); super.setC_DocType_ID(C_DocType_ID); } // setC_DocType_ID @@ -2035,11 +2009,6 @@ public class MPayment extends X_C_Payment testAllocation(); } - // Project update - if (getC_Project_ID() != 0) - { - // MProject project = new MProject(getCtx(), getC_Project_ID()); - } // Update BP for Prepayments if (getC_BPartner_ID() != 0 && getC_Invoice_ID() == 0 && getC_Charge_ID() == 0 && MPaymentAllocate.get(this).length == 0 && !createdAllocationRecords) { @@ -2083,7 +2052,6 @@ public class MPayment extends X_C_Payment m_processMsg += " @CounterDoc@: @C_Payment_ID@=" + counter.getDocumentNo(); // @Trifon - CashPayments - //if ( getTenderType().equals("X") ) { if ( isCashbookTrx()) { // Create Cash Book entry if ( getC_CashBook_ID() <= 0 ) { @@ -2108,14 +2076,6 @@ public class MPayment extends X_C_Payment m_processMsg = info.toString(); // Amount BigDecimal amt = this.getPayAmt(); -/* - MDocType dt = MDocType.get(getCtx(), invoice.getC_DocType_ID()); - if (MDocType.DOCBASETYPE_APInvoice.equals( dt.getDocBaseType() ) - || MDocType.DOCBASETYPE_ARCreditMemo.equals( dt.getDocBaseType() ) - ) { - amt = amt.negate(); - } -*/ cl.setAmount( amt ); // cl.setDiscountAmt( Env.ZERO ); @@ -2216,7 +2176,7 @@ public class MPayment extends X_C_Payment return null; MBPartner counterBP = new MBPartner (getCtx(), counterC_BPartner_ID, get_TrxName()); - // MOrgInfo counterOrgInfo = MOrgInfo.get(getCtx(), counterAD_Org_ID); + if (log.isLoggable(Level.INFO)) log.info("Counter BP=" + counterBP.getName()); // Document Type @@ -2517,10 +2477,6 @@ public class MPayment extends X_C_Payment */ protected void deAllocate(boolean accrual) { - // if (getC_Order_ID() != 0) setC_Order_ID(0); // IDEMPIERE-1764 - // if (getC_Invoice_ID() == 0) - // return; - // De-Allocate all MAllocationHdr[] allocations = MAllocationHdr.getOfPayment(getCtx(), getC_Payment_ID(), get_TrxName()); if (log.isLoggable(Level.FINE)) log.fine("#" + allocations.length); @@ -2925,10 +2881,7 @@ public class MPayment extends X_C_Payment */ public File createPDF (File file) { - // ReportEngine re = ReportEngine.get (getCtx(), ReportEngine.PAYMENT, getC_Payment_ID()); - // if (re == null) - return null; - // return re.getPDF(file); + return null; } // createPDF diff --git a/org.adempiere.base/src/org/compiere/model/MPaymentAllocate.java b/org.adempiere.base/src/org/compiere/model/MPaymentAllocate.java index 6a93168800..d93d8a4ebf 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaymentAllocate.java +++ b/org.adempiere.base/src/org/compiere/model/MPaymentAllocate.java @@ -62,8 +62,6 @@ public class MPaymentAllocate extends X_C_PaymentAllocate super (ctx, C_PaymentAllocate_ID, trxName); if (C_PaymentAllocate_ID == 0) { - // setC_Payment_ID (0); // Parent - // setC_Invoice_ID (0); setAmount (Env.ZERO); setDiscountAmt (Env.ZERO); setOverUnderAmt (Env.ZERO); diff --git a/org.adempiere.base/src/org/compiere/model/MPaymentBatch.java b/org.adempiere.base/src/org/compiere/model/MPaymentBatch.java index 4002959151..6af0d76a1f 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaymentBatch.java +++ b/org.adempiere.base/src/org/compiere/model/MPaymentBatch.java @@ -57,7 +57,6 @@ public class MPaymentBatch extends X_C_PaymentBatch super(ctx, C_PaymentBatch_ID, trxName); if (C_PaymentBatch_ID == 0) { - // setName (null); setProcessed (false); setProcessing (false); } diff --git a/org.adempiere.base/src/org/compiere/model/MPaymentProcessor.java b/org.adempiere.base/src/org/compiere/model/MPaymentProcessor.java index 3f65b1b9de..95084576f0 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaymentProcessor.java +++ b/org.adempiere.base/src/org/compiere/model/MPaymentProcessor.java @@ -46,11 +46,6 @@ public class MPaymentProcessor extends X_C_PaymentProcessor super (ctx, C_PaymentProcessor_ID, trxName); if (C_PaymentProcessor_ID == 0) { - // setC_BankAccount_ID (0); // Parent - // setUserID (null); - // setPassword (null); - // setHostAddress (null); - // setHostPort (0); setCommission (Env.ZERO); setAcceptVisa (false); setAcceptMC (false); @@ -64,7 +59,6 @@ public class MPaymentProcessor extends X_C_PaymentProcessor setAcceptATM (false); setAcceptDirectDeposit(false); setAcceptDirectDebit(false); - // setName (null); } } // MPaymentProcessor diff --git a/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java b/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java index e20e35f719..ea80ae8b5a 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java +++ b/org.adempiere.base/src/org/compiere/model/MPaymentTerm.java @@ -137,17 +137,6 @@ public class MPaymentTerm extends X_C_PaymentTerm setIsValid(true); return validMsg; } - // Allow schedules with just one record - // if (m_schedule.length == 1) - // { - // setIsValid(false); - // if (m_schedule[0].isValid()) - // { - // m_schedule[0].setIsValid(false); - // m_schedule[0].saveEx(); - // } - // return "@Invalid@ @Count@ # = 1 (@C_PaySchedule_ID@)"; - // } // Add up BigDecimal total = Env.ZERO; diff --git a/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java b/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java index 1cd3bb7a6e..79af0f84dc 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java +++ b/org.adempiere.base/src/org/compiere/model/MPaymentTransaction.java @@ -244,12 +244,6 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce setErrorMessage(Msg.getMsg(Env.getCtx(), "PaymentNoProcessor")); else { - // Validate before trying to process -// String msg = pp.validate(); -// if (msg!=null && msg.trim().length()>0) { -// setErrorMessage(Msg.getMsg(getCtx(), msg)); -// } else { - // Process if validation succeeds approved = pp.processCC(); setCreditCardNumber(PaymentUtil.encrpytCreditCard(getCreditCardNumber())); setCreditCardVV(PaymentUtil.encrpytCvv(getCreditCardVV())); @@ -287,7 +281,6 @@ public class MPaymentTransaction extends X_C_PaymentTransaction implements Proce else setErrorMessage("From " + getCreditCardName() + ": " + getR_RespMsg()); } -// } } } catch (Exception e) diff --git a/org.adempiere.base/src/org/compiere/model/MPaymentValidate.java b/org.adempiere.base/src/org/compiere/model/MPaymentValidate.java index 6cefd8d3f9..8808bbc934 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaymentValidate.java +++ b/org.adempiere.base/src/org/compiere/model/MPaymentValidate.java @@ -111,8 +111,6 @@ public class MPaymentValidate { if (mm < 1 || mm > 12) return "CreditCardExpMonth"; - // if (yy < 0 || yy > EXP_YEAR) - // return "CreditCardExpYear"; // Today's date Calendar cal = Calendar.getInstance();