use of org.compiere.model.MAccount in project adempiere by adempiere.
the class Doc_PPCostCollector method createVariance.
protected Fact createVariance(MAcctSchema acctSchema, int varianceAcctType) {
final Fact fact = new Fact(this, acctSchema, Fact.POST_Actual);
final MProduct product = costCollector.getM_Product();
MAccount varianceAccount = docLineCostCollector.getAccount(varianceAcctType, acctSchema);
MAccount workInProcess = docLineCostCollector.getAccount(ProductCost.ACCTTYPE_P_WorkInProcess, acctSchema);
for (MCostDetail costDetail : docLineCostCollector.getCostDetail(acctSchema, false)) {
MCostElement costElement = MCostElement.get(getCtx(), costDetail.getM_CostElement_ID());
BigDecimal absoluteCost = costDetail.getTotalCost(costDetail, acctSchema);
if (absoluteCost.signum() == 0)
continue;
BigDecimal cost = costDetail.getQty().signum() < 0 ? absoluteCost.negate() : absoluteCost;
if (cost == null)
cost = BigDecimal.ZERO;
if (cost.scale() > acctSchema.getStdPrecision())
cost = cost.setScale(acctSchema.getStdPrecision(), RoundingMode.HALF_UP);
BigDecimal qty = costDetail.getQty();
createLines(costElement, acctSchema, fact, product, varianceAccount, workInProcess, cost, qty);
}
return fact;
}
use of org.compiere.model.MAccount in project adempiere by adempiere.
the class AcctSchemaCopyAcct method copyGL.
// doIt
/**
* Copy GL
* @param targetAS target
* @throws Exception
*/
private void copyGL(MAcctSchema targetAS) throws Exception {
MAcctSchemaGL source = MAcctSchemaGL.get(getCtx(), p_SourceAcctSchema_ID);
MAcctSchemaGL target = new MAcctSchemaGL(getCtx(), 0, get_TrxName());
target.setC_AcctSchema_ID(p_TargetAcctSchema_ID);
ArrayList<KeyNamePair> list = source.getAcctInfo();
for (int i = 0; i < list.size(); i++) {
KeyNamePair pp = list.get(i);
int sourceC_ValidCombination_ID = pp.getKey();
String columnName = pp.getName();
MAccount sourceAccount = MAccount.get(getCtx(), sourceC_ValidCombination_ID);
MAccount targetAccount = createAccount(targetAS, sourceAccount);
target.setValue(columnName, new Integer(targetAccount.getC_ValidCombination_ID()));
}
if (!target.save())
throw new AdempiereSystemError("Could not Save GL");
}
Aggregations