diff --git a/base/src/org/compiere/acct/Doc_InOut.java b/base/src/org/compiere/acct/Doc_InOut.java index 835893c723..df06ac9d24 100644 --- a/base/src/org/compiere/acct/Doc_InOut.java +++ b/base/src/org/compiere/acct/Doc_InOut.java @@ -145,7 +145,6 @@ public class Doc_InOut extends Doc // if Shipment CostDetail exist then get Cost from Cost Detail BigDecimal costs = line.getProductCosts(as, line.getAD_Org_ID(), true, "M_InOutLine_ID=? AND M_AttributeSetInstance_ID=?"); // end MZ - if (costs == null || costs.signum() == 0) // zero costs OK { MProduct product = line.getProduct(); @@ -292,11 +291,7 @@ public class Doc_InOut extends Doc BigDecimal costs = null; MProduct product = line.getProduct(); //get costing method for product - String costingMethod = as.getCostingMethod(); - MProductCategoryAcct pca = MProductCategoryAcct.get(getCtx(), - product.getM_Product_Category_ID(), as.getC_AcctSchema_ID(), getTrxName()); - if (pca.getCostingMethod() != null) - costingMethod = pca.getCostingMethod(); + String costingMethod = product.getCostingMethod(as); if (MAcctSchema.COSTINGMETHOD_AveragePO.equals(costingMethod) || MAcctSchema.COSTINGMETHOD_LastPOPrice.equals(costingMethod) ) { @@ -382,11 +377,7 @@ public class Doc_InOut extends Doc BigDecimal costs = null; MProduct product = line.getProduct(); //get costing method for product - String costingMethod = as.getCostingMethod(); - MProductCategoryAcct pca = MProductCategoryAcct.get(getCtx(), - product.getM_Product_Category_ID(), as.getC_AcctSchema_ID(), getTrxName()); - if (pca.getCostingMethod() != null) - costingMethod = pca.getCostingMethod(); + String costingMethod = product.getCostingMethod(as); if (MAcctSchema.COSTINGMETHOD_AveragePO.equals(costingMethod) || MAcctSchema.COSTINGMETHOD_LastPOPrice.equals(costingMethod) ) { diff --git a/base/src/org/compiere/acct/Doc_MatchPO.java b/base/src/org/compiere/acct/Doc_MatchPO.java index 48891a0aab..b4af5b8fc3 100644 --- a/base/src/org/compiere/acct/Doc_MatchPO.java +++ b/base/src/org/compiere/acct/Doc_MatchPO.java @@ -184,14 +184,9 @@ public class Doc_MatchPO extends Doc // end MZ */ // Calculate PPV for standard costing - String costingMethod = as.getCostingMethod(); MProduct product = MProduct.get(getCtx(), getM_Product_ID()); - MProductCategoryAcct pca = MProductCategoryAcct.get(getCtx(), - product.getM_Product_Category_ID(), as.getC_AcctSchema_ID(), getTrxName()); - if (pca.getCostingMethod() != null) - costingMethod = pca.getCostingMethod(); - - //get standard cost and also makesure cost for other costing method is updated + String costingMethod = product.getCostingMethod(as); + //get standard cost and also make sure cost for other costing method is updated BigDecimal costs = m_pc.getProductCosts(as, getAD_Org_ID(), MAcctSchema.COSTINGMETHOD_StandardCosting, m_C_OrderLine_ID, false); // non-zero costs diff --git a/base/src/org/compiere/acct/Doc_Movement.java b/base/src/org/compiere/acct/Doc_Movement.java index 54048c700d..eefa469198 100644 --- a/base/src/org/compiere/acct/Doc_Movement.java +++ b/base/src/org/compiere/acct/Doc_Movement.java @@ -146,12 +146,7 @@ public class Doc_Movement extends Doc // Only for between-org movements if (dr.getAD_Org_ID() != cr.getAD_Org_ID()) { - String costingLevel = as.getCostingLevel(); - MProductCategoryAcct pca = MProductCategoryAcct.get(getCtx(), - line.getProduct().getM_Product_Category_ID(), - as.getC_AcctSchema_ID(), getTrxName()); - if (pca.getCostingLevel() != null) - costingLevel = pca.getCostingLevel(); + String costingLevel = line.getProduct().getCostingLevel(as); if (!MAcctSchema.COSTINGLEVEL_Organization.equals(costingLevel)) continue; // diff --git a/base/src/org/compiere/model/MCost.java b/base/src/org/compiere/model/MCost.java index 5a4c08f437..b47da8dd19 100644 --- a/base/src/org/compiere/model/MCost.java +++ b/base/src/org/compiere/model/MCost.java @@ -17,13 +17,21 @@ *****************************************************************************/ package org.compiere.model; -import java.sql.*; -import java.math.*; -import java.util.*; -import java.util.logging.*; +import java.math.BigDecimal; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.logging.Level; -import org.compiere.*; -import org.compiere.util.*; +import org.compiere.Adempiere; +import org.compiere.util.CLogger; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.compiere.util.Msg; +import org.compiere.util.Trx; /** * Product Cost Model @@ -36,6 +44,9 @@ import org.compiere.util.*; */ public class MCost extends X_M_Cost { + private static final long serialVersionUID = 1L; + + /** * Retrieve/Calculate Current Cost Price * @param product product @@ -55,16 +66,7 @@ public class MCost extends X_M_Cost BigDecimal qty, int C_OrderLine_ID, boolean zeroCostsOK, String trxName) { - String CostingLevel = as.getCostingLevel(); - MProductCategoryAcct pca = MProductCategoryAcct.get (product.getCtx(), - product.getM_Product_Category_ID(), as.getC_AcctSchema_ID(), null); - if (pca == null) - throw new IllegalStateException("Cannot find Acct for M_Product_Category_ID=" - + product.getM_Product_Category_ID() - + ", C_AcctSchema_ID=" + as.getC_AcctSchema_ID()); - // Costing Level - if (pca.getCostingLevel() != null) - CostingLevel = pca.getCostingLevel(); + String CostingLevel = product.getCostingLevel(as); if (MAcctSchema.COSTINGLEVEL_Client.equals(CostingLevel)) { AD_Org_ID = 0; @@ -77,13 +79,10 @@ public class MCost extends X_M_Cost // Costing Method if (costingMethod == null) { - costingMethod = pca.getCostingMethod(); + costingMethod = product.getCostingMethod(as); if (costingMethod == null) { - costingMethod = as.getCostingMethod(); - if (costingMethod == null) - throw new IllegalArgumentException("No Costing Method"); - // costingMethod = MAcctSchema.COSTINGMETHOD_StandardCosting; + throw new IllegalArgumentException("No Costing Method"); } } @@ -117,7 +116,7 @@ public class MCost extends X_M_Cost { BigDecimal currentCostPrice = null; String costElementType = null; - int M_CostElement_ID = 0; + //int M_CostElement_ID = 0; BigDecimal percent = null; // BigDecimal materialCostEach = Env.ZERO; @@ -700,11 +699,7 @@ public class MCost extends X_M_Cost for (int i = 0; i < mass.length; i++) { MAcctSchema as = mass[i]; - MProductCategoryAcct pca = MProductCategoryAcct.get(product.getCtx(), - product.getM_Product_Category_ID(), as.getC_AcctSchema_ID(), product.get_TrxName()); - String cl = pca.getCostingLevel(); - if (cl == null) - cl = as.getCostingLevel(); + String cl = product.getCostingLevel(as); // Create Std Costing if (MAcctSchema.COSTINGLEVEL_Client.equals(cl)) { @@ -1608,12 +1603,8 @@ public class MCost extends X_M_Cost if (m_manual) { MAcctSchema as = new MAcctSchema (getCtx(), getC_AcctSchema_ID(), null); - String CostingLevel = as.getCostingLevel(); MProduct product = MProduct.get(getCtx(), getM_Product_ID()); - MProductCategoryAcct pca = MProductCategoryAcct.get (getCtx(), - product.getM_Product_Category_ID(), as.getC_AcctSchema_ID(), null); - if (pca.getCostingLevel() != null) - CostingLevel = pca.getCostingLevel(); + String CostingLevel = product.getCostingLevel(as); if (MAcctSchema.COSTINGLEVEL_Client.equals(CostingLevel)) { if (getAD_Org_ID() != 0 || getM_AttributeSetInstance_ID() != 0) diff --git a/base/src/org/compiere/model/MCostDetail.java b/base/src/org/compiere/model/MCostDetail.java index 5a52022718..c19c28baed 100644 --- a/base/src/org/compiere/model/MCostDetail.java +++ b/base/src/org/compiere/model/MCostDetail.java @@ -748,12 +748,8 @@ public class MCostDetail extends X_M_CostDetail // get costing level for product MAcctSchema as = new MAcctSchema (getCtx(), getC_AcctSchema_ID(), null); - String CostingLevel = as.getCostingLevel(); MProduct product = MProduct.get(getCtx(), getM_Product_ID()); - MProductCategoryAcct pca = MProductCategoryAcct.get (getCtx(), - product.getM_Product_Category_ID(), getC_AcctSchema_ID(), null); - if (pca.getCostingLevel() != null) - CostingLevel = pca.getCostingLevel(); + String CostingLevel = product.getCostingLevel(as); // Org Element int Org_ID = getAD_Org_ID(); int M_ASI_ID = getM_AttributeSetInstance_ID(); @@ -1085,12 +1081,8 @@ public class MCostDetail extends X_M_CostDetail boolean ok = false; // get costing level for product MAcctSchema as = new MAcctSchema (getCtx(), getC_AcctSchema_ID(), null); - String CostingLevel = as.getCostingLevel(); MProduct product = MProduct.get(getCtx(), getM_Product_ID()); - MProductCategoryAcct pca = MProductCategoryAcct.get (getCtx(), - product.getM_Product_Category_ID(), getC_AcctSchema_ID(), null); - if (pca.getCostingLevel() != null) - CostingLevel = pca.getCostingLevel(); + String CostingLevel = product.getCostingLevel(as); // Org Element int Org_ID = getAD_Org_ID(); int M_ASI_ID = getM_AttributeSetInstance_ID(); diff --git a/base/src/org/compiere/model/MProduct.java b/base/src/org/compiere/model/MProduct.java index 2136ef1cf5..f8f4afb461 100644 --- a/base/src/org/compiere/model/MProduct.java +++ b/base/src/org/compiere/model/MProduct.java @@ -38,6 +38,8 @@ import org.compiere.util.Msg; * @author Teo Sarca, SC ARHIPAC SERVICE SRL *