From 9699a47545d92bd083ef54bebd87b237829b79bb Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Fri, 20 Feb 2009 15:38:07 +0000 Subject: [PATCH] [ 2615593 ] Implementation the Manufacturing Cost Engine https://sourceforge.net/tracker/index.php?func=detail&aid=2615593&group_id=176962&atid=934929 * Removing libero dependencies from adempiere core classes --- .../org/compiere/model/I_M_Product_Acct.java | 210 +++++++++++++++ base/src/org/compiere/model/MProduct.java | 33 +++ base/src/org/compiere/model/MResource.java | 39 +-- .../org/compiere/model/X_M_Product_Acct.java | 254 +++++++++++++++++- base/src/org/compiere/wf/MWFNode.java | 71 ----- .../org/eevolution/model/MPPProductBOM.java | 1 + 6 files changed, 506 insertions(+), 102 deletions(-) diff --git a/base/src/org/compiere/model/I_M_Product_Acct.java b/base/src/org/compiere/model/I_M_Product_Acct.java index 1019d6ea26..8417f02928 100644 --- a/base/src/org/compiere/model/I_M_Product_Acct.java +++ b/base/src/org/compiere/model/I_M_Product_Acct.java @@ -20,6 +20,7 @@ package org.compiere.model; import java.math.BigDecimal; +import java.sql.Timestamp; import org.compiere.util.KeyNamePair; /** Generated Interface for M_Product_Acct @@ -43,6 +44,14 @@ public interface I_M_Product_Acct /** Load Meta Data */ + /** Column name AD_Client_ID */ + public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID"; + + /** Get Client. + * Client/Tenant for this installation. + */ + public int getAD_Client_ID(); + /** Column name AD_Org_ID */ public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID"; @@ -71,6 +80,35 @@ public interface I_M_Product_Acct public I_C_AcctSchema getC_AcctSchema() throws RuntimeException; + /** Column name Created */ + public static final String COLUMNNAME_Created = "Created"; + + /** Get Created. + * Date this record was created + */ + public Timestamp getCreated(); + + /** Column name CreatedBy */ + public static final String COLUMNNAME_CreatedBy = "CreatedBy"; + + /** Get Created By. + * User who created this records + */ + public int getCreatedBy(); + + /** Column name IsActive */ + public static final String COLUMNNAME_IsActive = "IsActive"; + + /** Set Active. + * The record is active in the system + */ + public void setIsActive (boolean IsActive); + + /** Get Active. + * The record is active in the system + */ + public boolean isActive(); + /** Column name M_Product_ID */ public static final String COLUMNNAME_M_Product_ID = "M_Product_ID"; @@ -99,6 +137,19 @@ public interface I_M_Product_Acct */ public int getP_Asset_Acct(); + /** Column name P_Burden_Acct */ + public static final String COLUMNNAME_P_Burden_Acct = "P_Burden_Acct"; + + /** Set Burden. + * The Burden account is the account used Manufacturing Order + */ + public void setP_Burden_Acct (int P_Burden_Acct); + + /** Get Burden. + * The Burden account is the account used Manufacturing Order + */ + public int getP_Burden_Acct(); + /** Column name P_COGS_Acct */ public static final String COLUMNNAME_P_COGS_Acct = "P_COGS_Acct"; @@ -125,6 +176,19 @@ public interface I_M_Product_Acct */ public int getP_CostAdjustment_Acct(); + /** Column name P_CostOfProduction_Acct */ + public static final String COLUMNNAME_P_CostOfProduction_Acct = "P_CostOfProduction_Acct"; + + /** Set Cost Of Production. + * The Cost Of Production account is the account used Manufacturing Order + */ + public void setP_CostOfProduction_Acct (int P_CostOfProduction_Acct); + + /** Get Cost Of Production. + * The Cost Of Production account is the account used Manufacturing Order + */ + public int getP_CostOfProduction_Acct(); + /** Column name P_Expense_Acct */ public static final String COLUMNNAME_P_Expense_Acct = "P_Expense_Acct"; @@ -138,6 +202,19 @@ public interface I_M_Product_Acct */ public int getP_Expense_Acct(); + /** Column name P_FloorStock_Acct */ + public static final String COLUMNNAME_P_FloorStock_Acct = "P_FloorStock_Acct"; + + /** Set Floor Stock. + * The Floor Stock account is the account used Manufacturing Order + */ + public void setP_FloorStock_Acct (int P_FloorStock_Acct); + + /** Get Floor Stock. + * The Floor Stock account is the account used Manufacturing Order + */ + public int getP_FloorStock_Acct(); + /** Column name P_InventoryClearing_Acct */ public static final String COLUMNNAME_P_InventoryClearing_Acct = "P_InventoryClearing_Acct"; @@ -164,6 +241,71 @@ public interface I_M_Product_Acct */ public int getP_InvoicePriceVariance_Acct(); + /** Column name P_Labor_Acct */ + public static final String COLUMNNAME_P_Labor_Acct = "P_Labor_Acct"; + + /** Set Labor. + * The Labor account is the account used Manufacturing Order + */ + public void setP_Labor_Acct (int P_Labor_Acct); + + /** Get Labor. + * The Labor account is the account used Manufacturing Order + */ + public int getP_Labor_Acct(); + + /** Column name P_MethodChangeVariance_Acct */ + public static final String COLUMNNAME_P_MethodChangeVariance_Acct = "P_MethodChangeVariance_Acct"; + + /** Set Method Change Variance. + * The Method Change Variance account is the account used Manufacturing Order + */ + public void setP_MethodChangeVariance_Acct (int P_MethodChangeVariance_Acct); + + /** Get Method Change Variance. + * The Method Change Variance account is the account used Manufacturing Order + */ + public int getP_MethodChangeVariance_Acct(); + + /** Column name P_MixVariance_Acct */ + public static final String COLUMNNAME_P_MixVariance_Acct = "P_MixVariance_Acct"; + + /** Set Mix Variance. + * The Mix Variance account is the account used Manufacturing Order + */ + public void setP_MixVariance_Acct (int P_MixVariance_Acct); + + /** Get Mix Variance. + * The Mix Variance account is the account used Manufacturing Order + */ + public int getP_MixVariance_Acct(); + + /** Column name P_OutsideProcessing_Acct */ + public static final String COLUMNNAME_P_OutsideProcessing_Acct = "P_OutsideProcessing_Acct"; + + /** Set Outside Processing. + * The Outside Processing Account is the account used in Manufacturing Order + */ + public void setP_OutsideProcessing_Acct (int P_OutsideProcessing_Acct); + + /** Get Outside Processing. + * The Outside Processing Account is the account used in Manufacturing Order + */ + public int getP_OutsideProcessing_Acct(); + + /** Column name P_Overhead_Acct */ + public static final String COLUMNNAME_P_Overhead_Acct = "P_Overhead_Acct"; + + /** Set Overhead. + * The Overhead account is the account used in Manufacturing Order + */ + public void setP_Overhead_Acct (int P_Overhead_Acct); + + /** Get Overhead. + * The Overhead account is the account used in Manufacturing Order + */ + public int getP_Overhead_Acct(); + /** Column name P_PurchasePriceVariance_Acct */ public static final String COLUMNNAME_P_PurchasePriceVariance_Acct = "P_PurchasePriceVariance_Acct"; @@ -177,6 +319,19 @@ public interface I_M_Product_Acct */ public int getP_PurchasePriceVariance_Acct(); + /** Column name P_RateVariance_Acct */ + public static final String COLUMNNAME_P_RateVariance_Acct = "P_RateVariance_Acct"; + + /** Set Rate Variance. + * The Rate Variance account is the account used Manufacturing Order + */ + public void setP_RateVariance_Acct (int P_RateVariance_Acct); + + /** Get Rate Variance. + * The Rate Variance account is the account used Manufacturing Order + */ + public int getP_RateVariance_Acct(); + /** Column name P_Revenue_Acct */ public static final String COLUMNNAME_P_Revenue_Acct = "P_Revenue_Acct"; @@ -190,6 +345,19 @@ public interface I_M_Product_Acct */ public int getP_Revenue_Acct(); + /** Column name P_Scrap_Acct */ + public static final String COLUMNNAME_P_Scrap_Acct = "P_Scrap_Acct"; + + /** Set Scrap. + * The Scrap account is the account used in Manufacturing Order + */ + public void setP_Scrap_Acct (int P_Scrap_Acct); + + /** Get Scrap. + * The Scrap account is the account used in Manufacturing Order + */ + public int getP_Scrap_Acct(); + /** Column name P_TradeDiscountGrant_Acct */ public static final String COLUMNNAME_P_TradeDiscountGrant_Acct = "P_TradeDiscountGrant_Acct"; @@ -215,4 +383,46 @@ public interface I_M_Product_Acct * Trade Discount Receivable Account */ public int getP_TradeDiscountRec_Acct(); + + /** Column name P_UsageVariance_Acct */ + public static final String COLUMNNAME_P_UsageVariance_Acct = "P_UsageVariance_Acct"; + + /** Set Usage Variance. + * The Usage Variance account is the account used Manufacturing Order + */ + public void setP_UsageVariance_Acct (int P_UsageVariance_Acct); + + /** Get Usage Variance. + * The Usage Variance account is the account used Manufacturing Order + */ + public int getP_UsageVariance_Acct(); + + /** Column name P_WIP_Acct */ + public static final String COLUMNNAME_P_WIP_Acct = "P_WIP_Acct"; + + /** Set Work In Process. + * The Work in Process account is the account used Manufacturing Order + */ + public void setP_WIP_Acct (int P_WIP_Acct); + + /** Get Work In Process. + * The Work in Process account is the account used Manufacturing Order + */ + public int getP_WIP_Acct(); + + /** Column name Updated */ + public static final String COLUMNNAME_Updated = "Updated"; + + /** Get Updated. + * Date this record was updated + */ + public Timestamp getUpdated(); + + /** Column name UpdatedBy */ + public static final String COLUMNNAME_UpdatedBy = "UpdatedBy"; + + /** Get Updated By. + * User who updated this records + */ + public int getUpdatedBy(); } diff --git a/base/src/org/compiere/model/MProduct.java b/base/src/org/compiere/model/MProduct.java index 61c3bd9a47..bbb1074506 100644 --- a/base/src/org/compiere/model/MProduct.java +++ b/base/src/org/compiere/model/MProduct.java @@ -103,6 +103,39 @@ public class MProduct extends X_M_Product return(q.list()); } + /** + * Get Product from Cache + * @param ctx context + * @param S_Resource_ID resource ID + * @return MProduct or null if not found + */ + public static MProduct forS_Resource_ID(Properties ctx, int S_Resource_ID) + { + if (S_Resource_ID <= 0) + { + return null; + } + + // Try Cache + for (MProduct p : s_cache.values()) + { + if (p.getS_Resource_ID() == S_Resource_ID) + { + return p; + } + } + // Load from DB + MProduct p = new Query(ctx, Table_Name, COLUMNNAME_S_Resource_ID+"=?", null) + .setParameters(new Object[]{S_Resource_ID}) + .firstOnly(); + if (p != null) + { + s_cache.put(p.get_ID(), p); + } + return p; + } + + /** * Is Product Stocked * @param ctx context diff --git a/base/src/org/compiere/model/MResource.java b/base/src/org/compiere/model/MResource.java index 3558b2efc9..fcec10e3b2 100644 --- a/base/src/org/compiere/model/MResource.java +++ b/base/src/org/compiere/model/MResource.java @@ -16,13 +16,11 @@ *****************************************************************************/ package org.compiere.model; -import java.math.BigDecimal; import java.sql.ResultSet; import java.util.Properties; import org.adempiere.exceptions.AdempiereException; import org.compiere.util.CCache; -import org.compiere.util.DB; /** @@ -111,6 +109,10 @@ public class MResource extends X_S_Resource */ public MProduct getProduct() { + if (get_TrxName() == null) + { + return MProduct.forS_Resource_ID(getCtx(), get_ID()); + } if (m_product == null) { MProduct[] products = MProduct.get(getCtx(), "S_Resource_ID=" + getS_Resource_ID(), get_TrxName()); @@ -120,6 +122,11 @@ public class MResource extends X_S_Resource return m_product; } // getProduct + public int getC_UOM_ID() + { + return getProduct().getC_UOM_ID(); + } + /** * Before Save * @param newRecord new @@ -163,34 +170,6 @@ public class MResource extends X_S_Resource return success; } // afterSave - /** - * Get Rate for this Resource - * @param CostElementType Cost Element Type (Labor and Overhead.) - * @param S_Resource_ID Resource - * @param AD_Org_ID Organization - * @return Rate for Resource - */ - public double getResouceRate(int C_AcctSchema_ID,int M_CostType_ID, String CostElementType , int AD_Org_ID) - { - - final String sql = "SELECT SUM(c."+MCost.COLUMNNAME_CurrentCostPrice+")" - +" FROM M_Cost c, M_CostElement ce, M_Product p" - +" WHERE c.AD_Client_ID=? AND c.AD_Org_ID=?" - +" AND c."+MCost.COLUMNNAME_C_AcctSchema_ID+"=?" - +" AND c."+MCost.COLUMNNAME_M_CostType_ID+"=?" - // Cost Element Type - +" AND ce."+MCostElement.COLUMNNAME_M_CostElement_ID+"=c."+MCost.COLUMNNAME_M_CostElement_ID - +" AND ce."+MCostElement.COLUMNNAME_CostElementType+"=?" - // Product / Resource - +" AND p."+MProduct.COLUMNNAME_M_Product_ID+"=c."+MCost.COLUMNNAME_M_Product_ID - +" AND p."+MProduct.COLUMNNAME_S_Resource_ID+"=?" - ; - BigDecimal rate = DB.getSQLValueBDEx(get_TrxName(), sql, getAD_Client_ID(), AD_Org_ID, - C_AcctSchema_ID, M_CostType_ID, - CostElementType, getS_Resource_ID()); - return (rate != null ? rate.doubleValue() : 0); - } - public String toString() { StringBuffer sb = new StringBuffer ("MResource[") diff --git a/base/src/org/compiere/model/X_M_Product_Acct.java b/base/src/org/compiere/model/X_M_Product_Acct.java index 965c5e8bdb..dd4d105030 100644 --- a/base/src/org/compiere/model/X_M_Product_Acct.java +++ b/base/src/org/compiere/model/X_M_Product_Acct.java @@ -31,7 +31,7 @@ public class X_M_Product_Acct extends PO implements I_M_Product_Acct, I_Persiste /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 20081221L; /** Standard Constructor */ public X_M_Product_Acct (Properties ctx, int M_Product_Acct_ID, String trxName) @@ -42,15 +42,27 @@ public class X_M_Product_Acct extends PO implements I_M_Product_Acct, I_Persiste setC_AcctSchema_ID (0); setM_Product_ID (0); setP_Asset_Acct (0); + setP_Burden_Acct (0); setP_COGS_Acct (0); setP_CostAdjustment_Acct (0); + setP_CostOfProduction_Acct (0); setP_Expense_Acct (0); + setP_FloorStock_Acct (0); setP_InventoryClearing_Acct (0); setP_InvoicePriceVariance_Acct (0); + setP_Labor_Acct (0); + setP_MethodChangeVariance_Acct (0); + setP_MixVariance_Acct (0); + setP_OutsideProcessing_Acct (0); + setP_Overhead_Acct (0); setP_PurchasePriceVariance_Acct (0); + setP_RateVariance_Acct (0); setP_Revenue_Acct (0); + setP_Scrap_Acct (0); setP_TradeDiscountGrant_Acct (0); setP_TradeDiscountRec_Acct (0); + setP_UsageVariance_Acct (0); + setP_WIP_Acct (0); } */ } @@ -178,6 +190,26 @@ public class X_M_Product_Acct extends PO implements I_M_Product_Acct, I_Persiste return ii.intValue(); } + /** Set Burden. + @param P_Burden_Acct + The Burden account is the account used Manufacturing Order + */ + public void setP_Burden_Acct (int P_Burden_Acct) + { + set_Value (COLUMNNAME_P_Burden_Acct, Integer.valueOf(P_Burden_Acct)); + } + + /** Get Burden. + @return The Burden account is the account used Manufacturing Order + */ + public int getP_Burden_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_Burden_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } + /** Set Product COGS. @param P_COGS_Acct Account for Cost of Goods Sold @@ -218,6 +250,26 @@ public class X_M_Product_Acct extends PO implements I_M_Product_Acct, I_Persiste return ii.intValue(); } + /** Set Cost Of Production. + @param P_CostOfProduction_Acct + The Cost Of Production account is the account used Manufacturing Order + */ + public void setP_CostOfProduction_Acct (int P_CostOfProduction_Acct) + { + set_Value (COLUMNNAME_P_CostOfProduction_Acct, Integer.valueOf(P_CostOfProduction_Acct)); + } + + /** Get Cost Of Production. + @return The Cost Of Production account is the account used Manufacturing Order + */ + public int getP_CostOfProduction_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_CostOfProduction_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } + /** Set Product Expense. @param P_Expense_Acct Account for Product Expense @@ -238,6 +290,26 @@ public class X_M_Product_Acct extends PO implements I_M_Product_Acct, I_Persiste return ii.intValue(); } + /** Set Floor Stock. + @param P_FloorStock_Acct + The Floor Stock account is the account used Manufacturing Order + */ + public void setP_FloorStock_Acct (int P_FloorStock_Acct) + { + set_Value (COLUMNNAME_P_FloorStock_Acct, Integer.valueOf(P_FloorStock_Acct)); + } + + /** Get Floor Stock. + @return The Floor Stock account is the account used Manufacturing Order + */ + public int getP_FloorStock_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_FloorStock_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } + /** Set Inventory Clearing. @param P_InventoryClearing_Acct Product Inventory Clearing Account @@ -278,6 +350,106 @@ public class X_M_Product_Acct extends PO implements I_M_Product_Acct, I_Persiste return ii.intValue(); } + /** Set Labor. + @param P_Labor_Acct + The Labor account is the account used Manufacturing Order + */ + public void setP_Labor_Acct (int P_Labor_Acct) + { + set_Value (COLUMNNAME_P_Labor_Acct, Integer.valueOf(P_Labor_Acct)); + } + + /** Get Labor. + @return The Labor account is the account used Manufacturing Order + */ + public int getP_Labor_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_Labor_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Method Change Variance. + @param P_MethodChangeVariance_Acct + The Method Change Variance account is the account used Manufacturing Order + */ + public void setP_MethodChangeVariance_Acct (int P_MethodChangeVariance_Acct) + { + set_Value (COLUMNNAME_P_MethodChangeVariance_Acct, Integer.valueOf(P_MethodChangeVariance_Acct)); + } + + /** Get Method Change Variance. + @return The Method Change Variance account is the account used Manufacturing Order + */ + public int getP_MethodChangeVariance_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_MethodChangeVariance_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Mix Variance. + @param P_MixVariance_Acct + The Mix Variance account is the account used Manufacturing Order + */ + public void setP_MixVariance_Acct (int P_MixVariance_Acct) + { + set_Value (COLUMNNAME_P_MixVariance_Acct, Integer.valueOf(P_MixVariance_Acct)); + } + + /** Get Mix Variance. + @return The Mix Variance account is the account used Manufacturing Order + */ + public int getP_MixVariance_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_MixVariance_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Outside Processing. + @param P_OutsideProcessing_Acct + The Outside Processing Account is the account used in Manufacturing Order + */ + public void setP_OutsideProcessing_Acct (int P_OutsideProcessing_Acct) + { + set_Value (COLUMNNAME_P_OutsideProcessing_Acct, Integer.valueOf(P_OutsideProcessing_Acct)); + } + + /** Get Outside Processing. + @return The Outside Processing Account is the account used in Manufacturing Order + */ + public int getP_OutsideProcessing_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_OutsideProcessing_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Overhead. + @param P_Overhead_Acct + The Overhead account is the account used in Manufacturing Order + */ + public void setP_Overhead_Acct (int P_Overhead_Acct) + { + set_Value (COLUMNNAME_P_Overhead_Acct, Integer.valueOf(P_Overhead_Acct)); + } + + /** Get Overhead. + @return The Overhead account is the account used in Manufacturing Order + */ + public int getP_Overhead_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_Overhead_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } + /** Set Purchase Price Variance. @param P_PurchasePriceVariance_Acct Difference between Standard Cost and Purchase Price (PPV) @@ -298,6 +470,26 @@ public class X_M_Product_Acct extends PO implements I_M_Product_Acct, I_Persiste return ii.intValue(); } + /** Set Rate Variance. + @param P_RateVariance_Acct + The Rate Variance account is the account used Manufacturing Order + */ + public void setP_RateVariance_Acct (int P_RateVariance_Acct) + { + set_Value (COLUMNNAME_P_RateVariance_Acct, Integer.valueOf(P_RateVariance_Acct)); + } + + /** Get Rate Variance. + @return The Rate Variance account is the account used Manufacturing Order + */ + public int getP_RateVariance_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_RateVariance_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } + /** Set Product Revenue. @param P_Revenue_Acct Account for Product Revenue (Sales Account) @@ -318,6 +510,26 @@ public class X_M_Product_Acct extends PO implements I_M_Product_Acct, I_Persiste return ii.intValue(); } + /** Set Scrap. + @param P_Scrap_Acct + The Scrap account is the account used in Manufacturing Order + */ + public void setP_Scrap_Acct (int P_Scrap_Acct) + { + set_Value (COLUMNNAME_P_Scrap_Acct, Integer.valueOf(P_Scrap_Acct)); + } + + /** Get Scrap. + @return The Scrap account is the account used in Manufacturing Order + */ + public int getP_Scrap_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_Scrap_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } + /** Set Trade Discount Granted. @param P_TradeDiscountGrant_Acct Trade Discount Granted Account @@ -357,4 +569,44 @@ public class X_M_Product_Acct extends PO implements I_M_Product_Acct, I_Persiste return 0; return ii.intValue(); } + + /** Set Usage Variance. + @param P_UsageVariance_Acct + The Usage Variance account is the account used Manufacturing Order + */ + public void setP_UsageVariance_Acct (int P_UsageVariance_Acct) + { + set_Value (COLUMNNAME_P_UsageVariance_Acct, Integer.valueOf(P_UsageVariance_Acct)); + } + + /** Get Usage Variance. + @return The Usage Variance account is the account used Manufacturing Order + */ + public int getP_UsageVariance_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_UsageVariance_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } + + /** Set Work In Process. + @param P_WIP_Acct + The Work in Process account is the account used Manufacturing Order + */ + public void setP_WIP_Acct (int P_WIP_Acct) + { + set_Value (COLUMNNAME_P_WIP_Acct, Integer.valueOf(P_WIP_Acct)); + } + + /** Get Work In Process. + @return The Work in Process account is the account used Manufacturing Order + */ + public int getP_WIP_Acct () + { + Integer ii = (Integer)get_Value(COLUMNNAME_P_WIP_Acct); + if (ii == null) + return 0; + return ii.intValue(); + } } \ No newline at end of file diff --git a/base/src/org/compiere/wf/MWFNode.java b/base/src/org/compiere/wf/MWFNode.java index f55b62d689..20e77e220a 100644 --- a/base/src/org/compiere/wf/MWFNode.java +++ b/base/src/org/compiere/wf/MWFNode.java @@ -663,75 +663,4 @@ public class MWFNode extends X_AD_WF_Node return false; return true; } - - /** - * Calculate the cost for this node using the Cost Element Type - * @param CostElementType Cost Element Type (Labor or Burden) - * @param C_AcctSchema_ID AcctSchema - * @param M_CostType_ID Cost Type - * @param AD_Org_ID Organization - * @param setuptime Setup Time - * @param duration Duration - * @return cost for this Cost Element Type (Labor or Burden) - * @throws Exception when the UOM do not is Hours - */ - public BigDecimal getCostForCostElementType(String CostElementType, int C_AcctSchema_ID, int M_CostType_ID, int AD_Org_ID, - int setuptime, int duration) - { - MResource resource = MResource.get(getCtx(), getS_Resource_ID()); - if(resource == null) - return Env.ZERO; - - BigDecimal cost = Env.ZERO; - - // Validate the CostingLevel - MAcctSchema as = MAcctSchema.get(getCtx(), C_AcctSchema_ID); - final int precision = as.getCostingPrecision(); - MProduct product = resource.getProduct(); - if(MAcctSchema.COSTINGLEVEL_Client.equals(product.getCostingLevel(as))) - { - AD_Org_ID = 0; - } - - // - // Get Resource Rate - double rate = resource.getResouceRate(C_AcctSchema_ID, M_CostType_ID,CostElementType, AD_Org_ID); - if (rate == 0) - { - return Env.ZERO; - } - - // - // Calculate duration in hours - double hours; - int C_UOM_ID = DB.getSQLValueEx(get_TrxName(),"SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? " , getS_Resource_ID()); - MUOM uom = MUOM.get(getCtx(), C_UOM_ID); - if (uom.isHour()) - { - MWorkflow workflow = getWorkflow(); - hours = (setuptime / workflow.getQtyBatchSize().doubleValue() + duration) - * workflow.getDurationBaseSec() / 3600; - } - else - { - throw new AdempiereException("@NotSupported@ @C_UOM_ID@="+uom.getName()); - } - - // - // Calculate Activity Cost - double nodeCost = rate * hours; - cost = cost.add(new BigDecimal(nodeCost)); - - // - // Round to Costing Precision - if (cost.scale() > precision) - { - cost = cost.setScale(precision, RoundingMode.HALF_UP); - } - - log.info("Node: " + getName() + ", Resouce: " + resource.getName() +", CostElementType: " + CostElementType); - log.info("Duration (H): " + hours + " Rate: " + rate); - log.info("Activity Cost: " + nodeCost +" => Cost: "+cost); - return cost; - } } // M_WFNext diff --git a/base/src/org/eevolution/model/MPPProductBOM.java b/base/src/org/eevolution/model/MPPProductBOM.java index b77bcf6db5..e6f5f4c7d2 100644 --- a/base/src/org/eevolution/model/MPPProductBOM.java +++ b/base/src/org/eevolution/model/MPPProductBOM.java @@ -185,6 +185,7 @@ public class MPPProductBOM extends X_PP_Product_BOM final String whereClause = MPPProductBOMLine.COLUMNNAME_PP_Product_BOM_ID+"=?"; this.m_lines = new Query(getCtx(), MPPProductBOMLine.Table_Name, whereClause, get_TrxName()) .setParameters(new Object[]{getPP_Product_BOM_ID()}) + .setOnlyActiveRecords(true) .setOrderBy(MPPProductBOMLine.COLUMNNAME_Line) .list(); }