use of org.compiere.model.MAcctSchema in project adempiere by adempiere.
the class CostEngine method getAcctSchema.
public static List<MAcctSchema> getAcctSchema(PO po) {
int AD_Org_ID = po.getAD_Org_ID();
MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(po.getCtx(), po.getAD_Client_ID());
ArrayList<MAcctSchema> list = new ArrayList<MAcctSchema>(ass.length);
for (MAcctSchema as : ass) {
if (!as.isSkipOrg(AD_Org_ID))
list.add(as);
}
return list;
}
use of org.compiere.model.MAcctSchema in project adempiere by adempiere.
the class CombinedAgingRevalue method prepare.
/**
* Prepare - e.g., get Parameters.
*/
protected void prepare() {
ProcessInfoParameter[] para = getParameter();
for (int i = 0; i < para.length; i++) {
String name = para[i].getParameterName();
if (para[i].getParameter() == null)
;
else if (name.equals("C_AcctSchema_ID"))
p_C_AcctSchema_ID = ((BigDecimal) para[i].getParameter()).intValue();
else if (name.equals("C_ConversionType_ID"))
p_C_ConversionType_ID = ((BigDecimal) para[i].getParameter()).intValue();
else if (name.equals("StatementDate"))
p_StatementDate = (Timestamp) para[i].getParameter();
else if (name.equals("IsSOTrx") && para[i].getParameter() != null)
p_IsSOTrx = (String) para[i].getParameter();
else if (name.equals("C_Currency_ID"))
p_C_Currency_ID = ((BigDecimal) para[i].getParameter()).intValue();
else if (name.equals("AD_Org_ID"))
p_AD_Org_ID = ((BigDecimal) para[i].getParameter()).intValue();
else if (name.equals("C_BP_Group_ID"))
p_C_BP_Group_ID = ((BigDecimal) para[i].getParameter()).intValue();
else if (name.equals("C_BPartner_ID"))
p_C_BPartner_ID = ((BigDecimal) para[i].getParameter()).intValue();
else if (name.equals("ListSources"))
p_ListSources = "Y".equals(para[i].getParameter());
else if (name.equals("IsIncludePayments"))
p_IncludePayments = "Y".equals(para[i].getParameter());
else
log.log(Level.SEVERE, "Unknown Parameter: " + name);
}
// get currency_id for account schema
final MAcctSchema as = MAcctSchema.get(getCtx(), p_C_AcctSchema_ID);
as_C_Currency_ID = as.getC_Currency_ID();
if (p_StatementDate == null)
p_StatementDate = new Timestamp(System.currentTimeMillis());
else
m_statementOffset = TimeUtil.getDaysBetween(new Timestamp(System.currentTimeMillis()), p_StatementDate);
}
use of org.compiere.model.MAcctSchema in project adempiere by adempiere.
the class ProductCategoryAcctCopy method doIt.
// prepare
/**
* Process
* @return message
* @throws Exception
*/
protected String doIt() throws Exception {
log.info("C_AcctSchema_ID=" + p_C_AcctSchema_ID);
if (p_C_AcctSchema_ID == 0)
throw new AdempiereSystemError("C_AcctSchema_ID=0");
MAcctSchema as = MAcctSchema.get(getCtx(), p_C_AcctSchema_ID);
if (as.get_ID() == 0)
throw new AdempiereSystemError("Not Found - C_AcctSchema_ID=" + p_C_AcctSchema_ID);
// Update
String sql = "UPDATE M_Product_Acct pa " + "SET (P_Revenue_Acct,P_Expense_Acct,P_CostAdjustment_Acct,P_InventoryClearing_Acct,P_Asset_Acct,P_COGS_Acct," + " P_PurchasePriceVariance_Acct,P_InvoicePriceVariance_Acct,P_AverageCostVariance_Acct," + " P_TradeDiscountRec_Acct,P_TradeDiscountGrant_Acct," + " P_WIP_Acct,P_FloorStock_Acct,P_MethodChangeVariance_Acct,P_UsageVariance_Acct,P_RateVariance_Acct," + " P_MixVariance_Acct,P_Labor_Acct,P_Burden_Acct,P_CostOfProduction_Acct,P_OutsideProcessing_Acct,P_Overhead_Acct,P_Scrap_Acct)=" + " (SELECT P_Revenue_Acct,P_Expense_Acct,P_CostAdjustment_Acct,P_InventoryClearing_Acct,P_Asset_Acct,P_COGS_Acct," + " P_PurchasePriceVariance_Acct,P_InvoicePriceVariance_Acct,P_AverageCostVariance_Acct," + " P_TradeDiscountRec_Acct,P_TradeDiscountGrant_Acct," + " P_WIP_Acct,P_FloorStock_Acct,P_MethodChangeVariance_Acct,P_UsageVariance_Acct,P_RateVariance_Acct," + " P_MixVariance_Acct,P_Labor_Acct,P_Burden_Acct,P_CostOfProduction_Acct,P_OutsideProcessing_Acct,P_Overhead_Acct,P_Scrap_Acct" + " FROM M_Product_Category_Acct pca" + " WHERE pca.M_Product_Category_ID=" + p_M_Product_Category_ID + " AND pca.C_AcctSchema_ID=" + p_C_AcctSchema_ID + "), Updated=SysDate, UpdatedBy=0 " + "WHERE pa.C_AcctSchema_ID=" + p_C_AcctSchema_ID + " AND EXISTS (SELECT * FROM M_Product p " + "WHERE p.M_Product_ID=pa.M_Product_ID" + " AND p.M_Product_Category_ID=" + p_M_Product_Category_ID + ")";
int updated = DB.executeUpdate(sql, get_TrxName());
addLog(0, null, new BigDecimal(updated), "@Updated@");
// Insert new Products
sql = "INSERT INTO M_Product_Acct " + "(M_Product_ID, C_AcctSchema_ID," + " AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy," + " P_Revenue_Acct, P_Expense_Acct, P_CostAdjustment_Acct, P_InventoryClearing_Acct, P_Asset_Acct, P_CoGs_Acct," + " P_PurchasePriceVariance_Acct, P_InvoicePriceVariance_Acct, P_AverageCostVariance_Acct," + " P_TradeDiscountRec_Acct, P_TradeDiscountGrant_Acct, " + " P_WIP_Acct,P_FloorStock_Acct, P_MethodChangeVariance_Acct, P_UsageVariance_Acct, P_RateVariance_Acct," + " P_MixVariance_Acct, P_Labor_Acct, P_Burden_Acct, P_CostOfProduction_Acct, P_OutsideProcessing_Acct, P_Overhead_Acct, P_Scrap_Acct) " + "SELECT p.M_Product_ID, acct.C_AcctSchema_ID," + " p.AD_Client_ID, p.AD_Org_ID, 'Y', SysDate, 0, SysDate, 0," + " acct.P_Revenue_Acct, acct.P_Expense_Acct, acct.P_CostAdjustment_Acct, acct.P_InventoryClearing_Acct, acct.P_Asset_Acct, acct.P_CoGs_Acct," + " acct.P_PurchasePriceVariance_Acct, acct.P_InvoicePriceVariance_Acct, acct.P_AverageCostVariance_Acct," + " acct.P_TradeDiscountRec_Acct, acct.P_TradeDiscountGrant_Acct, " + " acct.P_WIP_Acct, acct.P_FloorStock_Acct, acct.P_MethodChangeVariance_Acct, acct.P_UsageVariance_Acct, acct.P_RateVariance_Acct," + " acct.P_MixVariance_Acct, acct.P_Labor_Acct, acct.P_Burden_Acct, acct.P_CostOfProduction_Acct, acct.P_OutsideProcessing_Acct, acct.P_Overhead_Acct, acct.P_Scrap_Acct " + "FROM M_Product p" + " INNER JOIN M_Product_Category_Acct acct ON (acct.M_Product_Category_ID=p.M_Product_Category_ID)" + "WHERE acct.C_AcctSchema_ID=" + // #
p_C_AcctSchema_ID + " AND p.M_Product_Category_ID=" + // #
p_M_Product_Category_ID + " AND NOT EXISTS (SELECT * FROM M_Product_Acct pa " + "WHERE pa.M_Product_ID=p.M_Product_ID" + " AND pa.C_AcctSchema_ID=acct.C_AcctSchema_ID)";
int created = DB.executeUpdate(sql, get_TrxName());
addLog(0, null, new BigDecimal(created), "@Created@");
return "@Created@=" + created + ", @Updated@=" + updated;
}
use of org.compiere.model.MAcctSchema in project adempiere by adempiere.
the class MPPOrder method createStandardCosts.
/**
* Save standard costs records into PP_Order_Cost.
* This will be usefull for calculating standard costs variances
*/
public final void createStandardCosts() {
MAcctSchema as = MClient.get(getCtx(), getAD_Client_ID()).getAcctSchema();
log.info("Cost_Group_ID" + as.getM_CostType_ID());
final TreeSet<Integer> productsAdded = new TreeSet<Integer>();
//
// Create Standard Costs for Order Header (resulting product)
{
final MProduct product = getM_Product();
productsAdded.add(product.getM_Product_ID());
final CostDimension d = new CostDimension(product, as, as.getM_CostType_ID(), getAD_Org_ID(), getM_Warehouse_ID(), getM_AttributeSetInstance_ID(), CostDimension.ANY);
Collection<MCost> costs = d.toQuery(MCost.class, get_TrxName()).list();
for (MCost cost : costs) {
//Create or Update the Order Cost dimension
MPPOrderCost.createOrderCostDimension(get_ID(), cost);
}
}
// Create Standard Costs for Order BOM Line
for (MPPOrderBOMLine line : getLines()) {
final MProduct product = line.getM_Product();
// Check if we already added this product
if (productsAdded.contains(product.getM_Product_ID()))
continue;
productsAdded.add(product.getM_Product_ID());
//
CostDimension d = new CostDimension(line.getM_Product(), as, as.getM_CostType_ID(), line.getAD_Org_ID(), getM_Warehouse_ID(), line.getM_AttributeSetInstance_ID(), CostDimension.ANY);
Collection<MCost> costs = d.toQuery(MCost.class, get_TrxName()).list();
for (MCost cost : costs) {
//Create or Update the Order Cost dimension
MPPOrderCost.createOrderCostDimension(get_ID(), cost);
}
}
// Create Standard Costs from Activity Resources
for (MPPOrderNode node : getMPPOrderWorkflow().getNodes(true)) {
final int S_Resource_ID = node.getS_Resource_ID();
if (S_Resource_ID <= 0)
continue;
final MProduct resourceProduct = MProduct.forS_Resource_ID(getCtx(), S_Resource_ID, null);
// Check if we already added this product
if (productsAdded.contains(resourceProduct.getM_Product_ID()))
continue;
productsAdded.add(resourceProduct.getM_Product_ID());
CostDimension d = new CostDimension(resourceProduct, as, as.getM_CostType_ID(), node.getAD_Org_ID(), getM_Warehouse_ID(), // ASI
0, CostDimension.ANY);
Collection<MCost> costs = d.toQuery(MCost.class, get_TrxName()).list();
for (MCost cost : costs) {
//Create or Update the Order Cost dimension
MPPOrderCost.createOrderCostDimension(get_ID(), cost);
}
}
}
use of org.compiere.model.MAcctSchema in project adempiere by adempiere.
the class MAssetAcct method getP_Asset_Acct.
public MAccount getP_Asset_Acct(int M_Product_ID) {
MAcctSchema as = getC_AcctSchema();
ProductCost pc = new ProductCost(getCtx(), M_Product_ID, 0, null);
return pc.getAccount(ProductCost.ACCTTYPE_P_Asset, as);
}
Aggregations