public static boolean createProduction(MAcctSchema as,int AD_Org_ID,int M_Product_ID,int M_AttributeSetInstance_ID,int M_ProductionLine_ID,int M_CostElement_ID,BigDecimal Amt,BigDecimal Qty,String Description,String trxName){
  String sql="DELETE M_CostDetail " + "WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0" + " AND M_ProductionLine_ID=" + M_ProductionLine_ID + " AND C_AcctSchema_ID ="+ as.getC_AcctSchema_ID()+ " AND M_AttributeSetInstance_ID="+ M_AttributeSetInstance_ID;
  int no=DB.executeUpdate(sql,trxName);
  if (no != 0)   s_log.config("Deleted #" + no);
  MCostDetail cd=get(as.getCtx(),"M_ProductionLine_ID=?",M_ProductionLine_ID,M_AttributeSetInstance_ID,as.getC_AcctSchema_ID(),trxName);
  if (cd == null) {
    cd=new MCostDetail(as,AD_Org_ID,M_Product_ID,M_AttributeSetInstance_ID,M_CostElement_ID,Amt,Qty,Description,trxName);
    cd.setM_ProductionLine_ID(M_ProductionLine_ID);
  }
 else {
    cd.setDeltaAmt(Amt.subtract(cd.getAmt()));
    cd.setDeltaQty(Qty.subtract(cd.getQty()));
    if (cd.isDelta()) {
      cd.setProcessed(false);
      cd.setAmt(Amt);
      cd.setQty(Qty);
    }
 else     return true;
  }
  boolean ok=cd.save();
  if (ok && !cd.isProcessed()) {
    MClient client=MClient.get(as.getCtx(),as.getAD_Client_ID());
    if (client.isCostImmediate())     cd.process();
  }
  s_log.config("(" + ok + ") "+ cd);
  return ok;
}

public static boolean createProduction ( MAcctSchema as , int AD_Org_ID , int M_Product_ID , int M_AttributeSetInstance_ID , int M_ProductionLine_ID , int M_CostElement_ID , BigDecimal Amt , BigDecimal Qty , String Description , String trxName ) { String sql = "DELETE M_CostDetail " + "WHERE Processed='N' AND COALESCE(DeltaAmt,0)=0 AND COALESCE(DeltaQty,0)=0" + " AND M_ProductionLine_ID=" + M_ProductionLine_ID + " AND C_AcctSchema_ID =" + as . getC_AcctSchema_ID ( ) + " AND M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID ; int no = DB . executeUpdate ( sql , trxName ) ; if ( no != 0 ) s_log . config ( "Deleted #" + no ) ; MCostDetail cd = get ( as . getCtx ( ) , "M_ProductionLine_ID=?" , M_ProductionLine_ID , M_AttributeSetInstance_ID , as . getC_AcctSchema_ID ( ) , trxName ) ; if ( cd == null ) { cd = new MCostDetail ( as , AD_Org_ID , M_Product_ID , M_AttributeSetInstance_ID , M_CostElement_ID , Amt , Qty , Description , trxName ) ; cd . setM_ProductionLine_ID ( M_ProductionLine_ID ) ; } else { cd . setDeltaAmt ( Amt . subtract ( cd . getAmt ( ) ) ) ; cd . setDeltaQty ( Qty . subtract ( cd . getQty ( ) ) ) ; if ( cd . isDelta ( ) ) { cd . setProcessed ( false ) ; cd . setAmt ( Amt ) ; cd . setQty ( Qty ) ; } else return true ; } boolean ok = cd . save ( ) ; if ( ok && ! cd . isProcessed ( ) ) { MClient client = MClient . get ( as . getCtx ( ) , as . getAD_Client_ID ( ) ) ; if ( client . isCostImmediate ( ) ) cd . process ( ) ; } s_log . config ( "(" + ok + ") " + cd ) ; return ok ; }
create new order cost detail for production . called from doc_production
