Search in sources :

Example 1 with I_M_CostElement

use of org.compiere.model.I_M_CostElement in project adempiere by adempiere.

the class Doc_PPCostCollector method createComponentIssue.

/**
	 * The Issue Component product created next account fact
	 * Debit Work in Process Account for each Cost Element using current cost
	 * Create a fact line for each cost element type
	 * 		Material
	 * 		Labor(Resources)
	 * 		Burden
	 * 		Overhead 
	 * 		Outsite Processing	
	 * Credit Product Asset Account for each Cost Element using current cost
	 * Create a fact line for each cost element type
	 * 		Material
	 * 		Labor(Resources)
	 * 		Burden
	 * 		Overhead 
	 * 		Outsite Processing		
	 * Credit Floor Stock Account for each Cost Element using current cost
	 * Create a fact line for each cost element type
	 * 		Material
	 * 		Labor(Resources)
	 * 		Burden
	 * 		Overhead 
	 * 		Outsite Processing		
	 */
protected Fact createComponentIssue(MAcctSchema acctSchema) {
    final Fact fact = new Fact(this, acctSchema, Fact.POST_Actual);
    BigDecimal totalCost = Env.ZERO;
    FactLine debitLine = null;
    FactLine creditLine = null;
    MAccount workInProcessAccount = docLineCostCollector.getAccount(ProductCost.ACCTTYPE_P_WorkInProcess, acctSchema);
    MAccount inventoryAccount = docLineCostCollector.getAccount(ProductCost.ACCTTYPE_P_Asset, acctSchema);
    if (costCollector.isFloorStock())
        inventoryAccount = docLineCostCollector.getAccount(ProductCost.ACCTTYPE_P_FloorStock, acctSchema);
    for (MCostDetail costDetail : docLineCostCollector.getCostDetail(acctSchema, false)) {
        BigDecimal absoluteCost = costDetail.getTotalCost(costDetail, acctSchema);
        if (absoluteCost.signum() == 0)
            continue;
        BigDecimal cost = costDetail.getQty().signum() < 0 ? absoluteCost.negate() : absoluteCost;
        if (cost.compareTo(Env.ZERO) == 0)
            continue;
        if (cost.scale() > acctSchema.getStdPrecision())
            cost = cost.setScale(acctSchema.getStdPrecision(), RoundingMode.HALF_UP);
        debitLine = fact.createLine(docLineCostCollector, workInProcessAccount, acctSchema.getC_Currency_ID(), cost.negate());
        I_M_CostElement costElement = costDetail.getM_CostElement();
        String description = manufacturingOrder.getDocumentNo() + " - " + costDetail.getM_CostType().getName() + " - " + costElement.getName();
        debitLine.setDescription(description);
        totalCost = totalCost.add(cost);
    }
    String description = manufacturingOrder.getDocumentNo();
    creditLine = fact.createLine(docLineCostCollector, inventoryAccount, acctSchema.getC_Currency_ID(), totalCost);
    creditLine.setDescription(description);
    return fact;
}
Also used : MAccount(org.compiere.model.MAccount) MCostDetail(org.compiere.model.MCostDetail) BigDecimal(java.math.BigDecimal) I_M_CostElement(org.compiere.model.I_M_CostElement)

Aggregations

BigDecimal (java.math.BigDecimal)1 I_M_CostElement (org.compiere.model.I_M_CostElement)1 MAccount (org.compiere.model.MAccount)1 MCostDetail (org.compiere.model.MCostDetail)1