private int deleteCostDetail( IDocumentLine model, I_C_AcctSchema as, int M_CostElement_ID, int M_AttributeSetInstance_ID) { // Delete Unprocessed zero Differences String sql = "DELETE FROM " + MCostDetail.Table_Name + " WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0" + " AND " + model.get_TableName() + "_ID=?" + " AND " + MCostDetail.COLUMNNAME_C_AcctSchema_ID + "=?" + " AND " + MCostDetail.COLUMNNAME_M_AttributeSetInstance_ID + "=?" // + " AND "+MCostDetail.COLUMNNAME_M_CostType_ID+"=?" + " AND " + MCostDetail.COLUMNNAME_M_CostElement_ID + "=?"; Object[] parameters = new Object[] { model.get_ID(), as.getC_AcctSchema_ID(), M_AttributeSetInstance_ID, // as.getM_CostType_ID(), M_CostElement_ID }; int no = DB.executeUpdateEx(sql, parameters, model.get_TrxName()); if (no != 0) log.info("Deleted #" + no); return no; }
/** * Get Cost Detail * * @param model Model Inventory Line * @param as Account Schema * @param M_CostElement_ID Cost Element * @param M_AttributeSetInstance_ID * @return MCostDetail */ private MCostDetail getCostDetail( IDocumentLine model, MTransaction mtrx, I_C_AcctSchema as, int M_CostElement_ID) { final String whereClause = "AD_Client_ID=? AND AD_Org_ID=?" + " AND " + model.get_TableName() + "_ID=?" + " AND " + MCostDetail.COLUMNNAME_M_Product_ID + "=?" + " AND " + MCostDetail.COLUMNNAME_M_AttributeSetInstance_ID + "=?" + " AND " + MCostDetail.COLUMNNAME_C_AcctSchema_ID + "=?" // +" AND "+MCostDetail.COLUMNNAME_M_CostType_ID+"=?" + " AND " + MCostDetail.COLUMNNAME_M_CostElement_ID + "=?"; final Object[] params = new Object[] { mtrx.getAD_Client_ID(), mtrx.getAD_Org_ID(), model.get_ID(), mtrx.getM_Product_ID(), mtrx.getM_AttributeSetInstance_ID(), as.getC_AcctSchema_ID(), // as.getM_CostType_ID(), M_CostElement_ID, }; return new Query(mtrx.getCtx(), MCostDetail.Table_Name, whereClause, mtrx.get_TrxName()) .setParameters(params) .firstOnly(); }