From 61478ad59461a07ea6ec7d40152de19fa357214b Mon Sep 17 00:00:00 2001 From: Diego Ruiz <12065321+d-ruiz@users.noreply.github.com> Date: Mon, 15 Mar 2021 10:43:02 +0100 Subject: [PATCH] IDEMPIERE-4723 - Clean up dead code on MInvoice*/MInventory* classes (#625) * IDEMPIERE-4723 - Clean up dead code on MInvoice*/MInventory* classes * IDEMPIERE-4723 - Clean up useless if in MInvoiceLine --- .../src/org/compiere/model/MInventory.java | 9 +-- .../org/compiere/model/MInventoryLine.java | 77 ------------------- .../src/org/compiere/model/MInvoice.java | 43 +---------- .../src/org/compiere/model/MInvoiceBatch.java | 3 - .../org/compiere/model/MInvoiceBatchLine.java | 10 --- .../src/org/compiere/model/MInvoiceLine.java | 7 +- .../compiere/model/MInvoicePaySchedule.java | 5 -- 7 files changed, 5 insertions(+), 149 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MInventory.java b/org.adempiere.base/src/org/compiere/model/MInventory.java index 61dac0c240..abc0c4e338 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventory.java +++ b/org.adempiere.base/src/org/compiere/model/MInventory.java @@ -95,8 +95,6 @@ public class MInventory extends X_M_Inventory implements DocAction super (ctx, M_Inventory_ID, trxName); if (M_Inventory_ID == 0) { - // setName (null); - // setM_Warehouse_ID (0); // FK setMovementDate (new Timestamp(System.currentTimeMillis())); setDocAction (DOCACTION_Complete); // CO setDocStatus (DOCSTATUS_Drafted); // DR @@ -271,10 +269,7 @@ public class MInventory extends X_M_Inventory implements DocAction */ 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 @@ -412,7 +407,6 @@ public class MInventory extends X_M_Inventory implements DocAction } // TODO: Add up Amounts - // setApprovalAmt(); m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE); if (m_processMsg != null) @@ -611,7 +605,6 @@ public class MInventory extends X_M_Inventory implements DocAction } } - //sLine.getM_AttributeSetInstance_ID() != 0 // Fallback if (mtrx == null) { diff --git a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java index 3dd23d4a27..20b8cd0638 100644 --- a/org.adempiere.base/src/org/compiere/model/MInventoryLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInventoryLine.java @@ -72,11 +72,7 @@ public class MInventoryLine extends X_M_InventoryLine super (ctx, M_InventoryLine_ID, trxName); if (M_InventoryLine_ID == 0) { - // setM_Inventory_ID (0); // Parent - // setM_InventoryLine_ID (0); // PK - // setM_Locator_ID (0); // FK setLine(0); - // setM_Product_ID (0); // FK setM_AttributeSetInstance_ID(0); // FK setInventoryType (INVENTORYTYPE_InventoryDifference); setQtyBook (Env.ZERO); @@ -127,7 +123,6 @@ public class MInventoryLine extends X_M_InventoryLine setQtyCount (QtyCount); if (QtyInternalUse != null && QtyInternalUse.signum() != 0) setQtyInternalUse (QtyInternalUse); - // m_isManualEntry = false; } // MInventoryLine public MInventoryLine (MInventory inventory, @@ -170,8 +165,6 @@ public class MInventoryLine extends X_M_InventoryLine this.m_product = copy.m_product != null ? new MProduct(ctx, copy.m_product, trxName) : null; } - /** Manually created */ - //protected boolean m_isManualEntry = true; /** Parent */ protected MInventory m_parent = null; /** Product */ @@ -306,15 +299,6 @@ public class MInventoryLine extends X_M_InventoryLine setLine (ii); } - // Enforce QtyCount >= 0 - teo_sarca BF [ 1722982 ] - // GlobalQSS -> reverting this change because of Bug 2904321 - Create Inventory Count List not taking negative qty products - /* - if ( (!newRecord) && is_ValueChanged("QtyCount") && getQtyCount().signum() < 0) - { - log.saveError("Warning", Msg.getElement(getCtx(), COLUMNNAME_QtyCount)+" < 0"); - return false; - } - */ // Enforce Qty UOM if (newRecord || is_ValueChanged("QtyCount")) setQtyCount(getQtyCount()); @@ -403,67 +387,6 @@ public class MInventoryLine extends X_M_InventoryLine return true; } // beforeSave - /** - * After Save - * @param newRecord new - * @param success success - * @return true - */ - //protected boolean afterSave (boolean newRecord, boolean success) - //{ - // if (!success) - // return false; - // - // // Create MA - // //if (newRecord && success - // // && m_isManualEntry && getM_AttributeSetInstance_ID() == 0) - // // createMA(); - // return true; - //} // afterSave - - /** - * Create Material Allocations for new Instances - */ - /*protected void createMA() - { - MStorageOnHand[] storages = MStorageOnHand.getAll(getCtx(), getM_Product_ID(), - getM_Locator_ID(), get_TrxName()); - boolean allZeroASI = true; - for (int i = 0; i < storages.length; i++) - { - if (storages[i].getM_AttributeSetInstance_ID() != 0) - { - allZeroASI = false; - break; - } - } - if (allZeroASI) - return; - - MInventoryLineMA ma = null; - BigDecimal sum = Env.ZERO; - for (int i = 0; i < storages.length; i++) - { - MStorageOnHand storage = storages[i]; - if (storage.getQtyOnHand().signum() == 0) - continue; - if (ma != null - && ma.getM_AttributeSetInstance_ID() == storage.getM_AttributeSetInstance_ID()) - ma.setMovementQty(ma.getMovementQty().add(storage.getQtyOnHand())); - else - ma = new MInventoryLineMA (this, - storage.getM_AttributeSetInstance_ID(), storage.getQtyOnHand()); - if (!ma.save()) - ; - sum = sum.add(storage.getQtyOnHand()); - } - if (sum.compareTo(getQtyBook()) != 0) - { - log.warning("QtyBook=" + getQtyBook() + " corrected to Sum of MA=" + sum); - setQtyBook(sum); - } - } // createMA*/ - /** * Is Internal Use Inventory * @return true if is internal use inventory diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 5d4b5f3418..f63c441d67 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -388,15 +388,9 @@ public class MInvoice extends X_C_Invoice implements DocAction setC_Currency_ID(batch.getC_Currency_ID()); setC_ConversionType_ID(batch.getC_ConversionType_ID()); // - // setPaymentRule(order.getPaymentRule()); - // setC_PaymentTerm_ID(order.getC_PaymentTerm_ID()); - // setPOReference(""); setDescription(batch.getDescription()); - // setDateOrdered(order.getDateOrdered()); - // setAD_OrgTrx_ID(line.getAD_OrgTrx_ID()); setC_Project_ID(line.getC_Project_ID()); - // setC_Campaign_ID(line.getC_Campaign_ID()); setC_Activity_ID(line.getC_Activity_ID()); setUser1_ID(line.getUser1_ID()); setUser2_ID(line.getUser2_ID()); @@ -1267,8 +1261,7 @@ public class MInvoice extends X_C_Invoice implements DocAction DB.close(rs, pstmt); rs = null; pstmt = null; } - // log.fine("getAllocatedAmt - " + retValue); - // ? ROUND(NVL(v_AllocatedAmt,0), 2); + return retValue; } // getAllocatedAmt @@ -1549,13 +1542,6 @@ public class MInvoice extends X_C_Invoice implements DocAction m_processMsg = "@NoLines@"; return DocAction.STATUS_Invalid; } - // No Cash Book // deprecated with IDEMPIERE-170 Complete Cash as Payment functionality -// if (PAYMENTRULE_Cash.equals(getPaymentRule()) -// && MCashBook.get(getCtx(), getAD_Org_ID(), getC_Currency_ID()) == null) -// { -// m_processMsg = "@NoCashBook@"; -// return DocAction.STATUS_Invalid; -// } // Convert/Check DocType if (getC_DocType_ID() != getC_DocTypeTarget_ID() ) @@ -1661,28 +1647,6 @@ public class MInvoice extends X_C_Invoice implements DocAction // New Lines int lineNo = line.getLine (); - //find default BOM with valid dates and to this product - /*MPPProductBOM bom = MPPProductBOM.get(product, getAD_Org_ID(),getDateInvoiced(), get_TrxName()); - if(bom != null) - { - MPPProductBOMLine[] bomlines = bom.getLines(getDateInvoiced()); - for (int j = 0; j < bomlines.length; j++) - { - MPPProductBOMLine bomline = bomlines[j]; - MInvoiceLine newLine = new MInvoiceLine (this); - newLine.setLine (++lineNo); - newLine.setM_Product_ID (bomline.getM_Product_ID ()); - newLine.setC_UOM_ID (bomline.getC_UOM_ID ()); - newLine.setQty (line.getQtyInvoiced().multiply( - bomline.getQtyBOM ())); // Invoiced/Entered - if (bomline.getDescription () != null) - newLine.setDescription (bomline.getDescription ()); - // - newLine.setPrice (); - newLine.saveEx (get_TrxName()); - } - }*/ - for (MProductBOM bom : MProductBOM.getBOMLines(product)) { MInvoiceLine newLine = new MInvoiceLine(this); @@ -2314,7 +2278,7 @@ public class MInvoice extends X_C_Invoice implements DocAction return null; MBPartner counterBP = new MBPartner (getCtx(), counterC_BPartner_ID, null); -// MOrgInfo counterOrgInfo = MOrgInfo.get(getCtx(), counterAD_Org_ID); + if (log.isLoggable(Level.INFO)) log.info("Counter BP=" + counterBP.getName()); // Document Type @@ -2340,9 +2304,6 @@ public class MInvoice extends X_C_Invoice implements DocAction C_DocTypeTarget_ID, !isSOTrx(), true, get_TrxName(), true); // counter.setAD_Org_ID(counterAD_Org_ID); - // counter.setM_Warehouse_ID(counterOrgInfo.getM_Warehouse_ID()); - // -// counter.setBPartner(counterBP);// was set on copyFrom // References (Should not be required) counter.setSalesRep_ID(getSalesRep_ID()); counter.saveEx(get_TrxName()); diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceBatch.java b/org.adempiere.base/src/org/compiere/model/MInvoiceBatch.java index 81bd5017b7..f66577d54b 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceBatch.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceBatch.java @@ -53,14 +53,11 @@ public class MInvoiceBatch extends X_C_InvoiceBatch super (ctx, C_InvoiceBatch_ID, trxName); if (C_InvoiceBatch_ID == 0) { - // setDocumentNo (null); - // setC_Currency_ID (0); // @$C_Currency_ID@ setControlAmt (Env.ZERO); // 0 setDateDoc (new Timestamp(System.currentTimeMillis())); // @#Date@ setDocumentAmt (Env.ZERO); setIsSOTrx (false); // N setProcessed (false); - // setSalesRep_ID (0); } } // MInvoiceBatch diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java b/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java index 76fb56d569..bd1c8f9511 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceBatchLine.java @@ -50,16 +50,6 @@ public class MInvoiceBatchLine extends X_C_InvoiceBatchLine super (ctx, C_InvoiceBatchLine_ID, trxName); if (C_InvoiceBatchLine_ID == 0) { - // setC_InvoiceBatch_ID (0); - /** - setC_BPartner_ID (0); - setC_BPartner_Location_ID (0); - setC_Charge_ID (0); - setC_DocType_ID (0); // @C_DocType_ID@ - setC_Tax_ID (0); - setDocumentNo (null); - setLine (0); // @SQL=SELECT NVL(MAX(Line),0)+10 AS DefaultValue FROM C_InvoiceBatchLine WHERE C_InvoiceBatch_ID=@C_InvoiceBatch_ID@ - **/ setDateAcct (new Timestamp(System.currentTimeMillis())); // @DateDoc@ setDateInvoiced (new Timestamp(System.currentTimeMillis())); // @DateDoc@ setIsTaxIncluded (false); diff --git a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java index e09a10e08a..0a96c612f2 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoiceLine.java @@ -318,7 +318,7 @@ public class MInvoiceLine extends X_C_InvoiceLine // use product UOM if the shipment hasn't the same uom than the order setC_UOM_ID(getProduct().getC_UOM_ID()); setM_AttributeSetInstance_ID(sLine.getM_AttributeSetInstance_ID()); - // setS_ResourceAssignment_ID(sLine.getS_ResourceAssignment_ID()); + if(getM_Product_ID() == 0) setC_Charge_ID(sLine.getC_Charge_ID()); // @@ -388,10 +388,7 @@ public class MInvoiceLine extends X_C_InvoiceLine */ public void setM_AttributeSetInstance_ID (int M_AttributeSetInstance_ID) { - if (M_AttributeSetInstance_ID == 0) // 0 is valid ID - set_Value("M_AttributeSetInstance_ID", Integer.valueOf(0)); - else - super.setM_AttributeSetInstance_ID (M_AttributeSetInstance_ID); + super.setM_AttributeSetInstance_ID (M_AttributeSetInstance_ID); } // setM_AttributeSetInstance_ID diff --git a/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java b/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java index 988a668f63..6a002fd39a 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoicePaySchedule.java @@ -108,11 +108,6 @@ public class MInvoicePaySchedule extends X_C_InvoicePaySchedule super(ctx, C_InvoicePaySchedule_ID, trxName); if (C_InvoicePaySchedule_ID == 0) { - // setC_Invoice_ID (0); - // setDiscountAmt (Env.ZERO); - // setDiscountDate (new Timestamp(System.currentTimeMillis())); - // setDueAmt (Env.ZERO); - // setDueDate (new Timestamp(System.currentTimeMillis())); setIsValid (false); } } // MInvoicePaySchedule