use of org.compiere.model.I_M_InOutLine in project adempiere by adempiere.
the class AbstractCostingMethod method createCostDetails.
protected List<MCostDetail> createCostDetails() {
final String idColumnName;
if (model instanceof MMatchPO) {
idColumnName = I_C_OrderLine.COLUMNNAME_C_OrderLine_ID;
} else if (model instanceof MMatchInv) {
idColumnName = I_C_InvoiceLine.COLUMNNAME_C_InvoiceLine_ID;
} else {
idColumnName = model.get_TableName() + "_ID";
}
List<MCostDetail> list = new ArrayList<MCostDetail>();
if (model.isSOTrx() == true || model instanceof MInventoryLine || model instanceof MMovementLine) {
List<CostComponent> costComponents = getCalculatedCosts();
for (CostComponent costComponent : costComponents) {
MCostDetail cost = new MCostDetail(transaction, accountSchema.getC_AcctSchema_ID(), dimension.getM_CostType_ID(), dimension.getM_CostElement_ID(), costComponent.getAmount(), Env.ZERO, costComponent.getQty(), model.get_TrxName());
if (!cost.set_ValueOfColumnReturningBoolean(idColumnName, model.get_ID()))
throw new AdempiereException("Cannot set " + idColumnName);
StringBuilder description = new StringBuilder();
if (!Util.isEmpty(model.getDescription(), true))
description.append(model.getDescription());
if (model.isSOTrx() != false) {
description.append(model.isSOTrx() ? "(|->)" : "(|<-)");
}
if (// TODO: need evaluate anca
model.isSOTrx() != false)
cost.setIsSOTrx(model.isSOTrx());
else
cost.setIsSOTrx(model.isSOTrx());
cost.setM_Transaction_ID(transaction.get_ID());
cost.setDescription(description.toString());
cost.saveEx();
list.add(cost);
}
} else // qty and amt is take from documentline
{
MCostDetail cost = new MCostDetail(transaction, accountSchema.getC_AcctSchema_ID(), dimension.getM_CostType_ID(), dimension.getM_CostElement_ID(), costThisLevel.multiply(model.getMovementQty()), Env.ZERO, model.getMovementQty(), model.get_TrxName());
int id;
if (model instanceof MMatchPO) {
I_M_InOutLine inOutLine = transaction.getM_InOutLine();
I_C_OrderLine orderLine = inOutLine.getC_OrderLine();
id = orderLine.getC_OrderLine_ID();
} else {
id = model.get_ID();
}
if (!cost.set_ValueOfColumnReturningBoolean(idColumnName, id))
throw new AdempiereException("Cannot set " + idColumnName);
if (model.isSOTrx() != false)
cost.setIsSOTrx(model.isSOTrx());
else
cost.setIsSOTrx(model.isSOTrx());
cost.setM_Transaction_ID(transaction.get_ID());
cost.saveEx();
list.add(cost);
}
return list;
}
Aggregations