Search in sources :

Example 41 with MAccount

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;
}
Also used : MCostElement(org.compiere.model.MCostElement) MProduct(org.compiere.model.MProduct) MAccount(org.compiere.model.MAccount) MCostDetail(org.compiere.model.MCostDetail) BigDecimal(java.math.BigDecimal)

Example 42 with MAccount

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");
}
Also used : MAcctSchemaGL(org.compiere.model.MAcctSchemaGL) AdempiereSystemError(org.compiere.util.AdempiereSystemError) MAccount(org.compiere.model.MAccount) KeyNamePair(org.compiere.util.KeyNamePair)

Aggregations

MAccount (org.compiere.model.MAccount)42 BigDecimal (java.math.BigDecimal)25 ArrayList (java.util.ArrayList)16 MCostDetail (org.compiere.model.MCostDetail)8 PreparedStatement (java.sql.PreparedStatement)7 ResultSet (java.sql.ResultSet)7 MProduct (org.compiere.model.MProduct)6 SQLException (java.sql.SQLException)5 MCostElement (org.compiere.model.MCostElement)5 MJournalLine (org.compiere.model.MJournalLine)4 MCostType (org.compiere.model.MCostType)3 Timestamp (java.sql.Timestamp)2 MAcctSchemaElement (org.compiere.model.MAcctSchemaElement)2 MCharge (org.compiere.model.MCharge)2 MElementValue (org.compiere.model.MElementValue)2 MInvoice (org.compiere.model.MInvoice)2 AdempiereSystemError (org.compiere.util.AdempiereSystemError)2 TreeMap (java.util.TreeMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 I_C_Project (org.compiere.model.I_C_Project)1