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;
}
Aggregations