Search in sources :

Example 1 with ValuationEffectiveDate

use of org.eevolution.process.ValuationEffectiveDate in project adempiere by adempiere.

the class CostResult method createTrxAndInventoryValuationReport.

void createTrxAndInventoryValuationReport() {
    int AD_Process_ID = MProcess.getProcess_ID("Transaction Valuation", trxName);
    ProcessInfo pi = new ProcessInfo("Transaction Valuation", AD_Process_ID);
    MPInstance instance = new MPInstance(getCtx(), AD_Process_ID, 0);
    instance.saveEx();
    pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
    pi.setAD_Client_ID(Env.getAD_Client_ID(getCtx()));
    //	Add Parameters
    MPInstancePara para = new MPInstancePara(instance, 10);
    para.setParameter(MCostDetail.COLUMNNAME_M_Product_ID, product.getM_Product_ID());
    para.saveEx();
    para = new MPInstancePara(instance, 20);
    para.setParameter(MCostDetail.COLUMNNAME_M_CostType_ID, 50000);
    para.saveEx();
    para = new MPInstancePara(instance, 30);
    para.setParameter(MCostDetail.COLUMNNAME_M_CostElement_ID, 100);
    para.saveEx();
    pi.setTransactionName(trxName);
    //ReportCtl.startStandardReport(pi);	
    ReportEngine re = ReportEngine.get(getCtx(), pi);
    File trxValuation = null;
    trxValuation = re.getPDF();
    AD_Process_ID = MProcess.getProcess_ID("Valuation Effective Date", trxName);
    pi = new ProcessInfo("Valuation Effective Date", AD_Process_ID);
    instance = new MPInstance(getCtx(), AD_Process_ID, 0);
    instance.saveEx();
    pi.setAD_PInstance_ID(instance.getAD_PInstance_ID());
    pi.setAD_Client_ID(Env.getAD_Client_ID(getCtx()));
    para = new MPInstancePara(instance, 10);
    para.setParameter("DateValue", new Timestamp(System.currentTimeMillis()));
    para.saveEx();
    //	Add Parameters
    para = new MPInstancePara(instance, 20);
    para.setParameter(MCostDetail.COLUMNNAME_M_Product_ID, product.getM_Product_ID());
    para.saveEx();
    para = new MPInstancePara(instance, 30);
    para.setParameter(MCostDetail.COLUMNNAME_M_CostType_ID, 50000);
    para.saveEx();
    para = new MPInstancePara(instance, 40);
    para.setParameter(MCostDetail.COLUMNNAME_M_CostElement_ID, 100);
    para.saveEx();
    ValuationEffectiveDate process = new ValuationEffectiveDate();
    process.startProcess(getCtx(), pi, Trx.get(trxName, false));
    pi.setTransactionName(trxName);
    re = ReportEngine.get(getCtx(), pi);
    File report = null;
    report = re.getPDF();
    EMail email = new EMail(getCtx(), "smtp.gmail.com", "victor.perez@e-evolution.com", "victor.perez@e-evolution.com", "Transaction and Inventory Valuation Report Test", "Transaction and Inventory Valuation " + new Timestamp(System.currentTimeMillis()));
    email.addAttachment(trxValuation);
    email.addAttachment(report);
    email.createAuthenticator(Mail, MailPassword);
    String msg = email.send();
    System.out.println(msg);
}
Also used : ValuationEffectiveDate(org.eevolution.process.ValuationEffectiveDate) MPInstancePara(org.compiere.model.MPInstancePara) MPInstance(org.compiere.model.MPInstance) ReportEngine(org.compiere.print.ReportEngine) ProcessInfo(org.compiere.process.ProcessInfo) EMail(org.compiere.util.EMail) File(java.io.File) Timestamp(java.sql.Timestamp)

Aggregations

File (java.io.File)1 Timestamp (java.sql.Timestamp)1 MPInstance (org.compiere.model.MPInstance)1 MPInstancePara (org.compiere.model.MPInstancePara)1 ReportEngine (org.compiere.print.ReportEngine)1 ProcessInfo (org.compiere.process.ProcessInfo)1 EMail (org.compiere.util.EMail)1 ValuationEffectiveDate (org.eevolution.process.ValuationEffectiveDate)1