Search in sources :

Example 1 with MHRPaySelectionCheck

use of org.eevolution.model.MHRPaySelectionCheck in project adempiere by adempiere.

the class WHRPayPrint method cmd_print.

//  cmd_EFT
/**
	 *  Print Checks and/or Remittance
	 */
private void cmd_print() {
    if (fPaymentRule.getSelectedItem() == null)
        return;
    String PaymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
    log.info(PaymentRule);
    if (!getChecks(PaymentRule))
        return;
    //	for all checks
    List<File> pdfList = new ArrayList<File>();
    for (MHRPaySelectionCheck check : m_checks) {
        //	ReportCtrl will check BankAccountDoc for PrintFormat
        ReportEngine re = ReportEngine.get(Env.getCtx(), ReportEngine.HR_CHECK, check.get_ID());
        try {
            File file = File.createTempFile("WHRPayPrint", null);
            re.getPDF(file);
            pdfList.add(file);
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
            return;
        }
    }
    SimplePDFViewer chequeViewer = null;
    try {
        File outFile = File.createTempFile("WHRPayPrint", null);
        AEnv.mergePdf(pdfList, outFile);
        chequeViewer = new SimplePDFViewer(form.getFormName(), new FileInputStream(outFile));
        chequeViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
        chequeViewer.setWidth("100%");
    } catch (Exception e) {
        log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        return;
    }
    //	Update BankAccountDoc
    int lastDocumentNo = MHRPaySelectionCheck.confirmPrint(m_checks, m_batch);
    if (lastDocumentNo != 0) {
        StringBuffer sb = new StringBuffer();
        sb.append("UPDATE C_BankAccountDoc SET CurrentNext=").append(++lastDocumentNo).append(" WHERE C_BankAccount_ID=").append(m_C_BankAccount_ID).append(" AND PaymentRule='").append(PaymentRule).append("'");
        DB.executeUpdate(sb.toString(), null);
    }
    SimplePDFViewer remitViewer = null;
    if (FDialog.ask(m_WindowNo, form, "VPayPrintPrintRemittance")) {
        pdfList = new ArrayList<File>();
        for (MHRPaySelectionCheck check : m_checks) {
            ReportEngine re = ReportEngine.get(Env.getCtx(), ReportEngine.HR_REMITTANCE, check.get_ID());
            try {
                File file = File.createTempFile("WHRPayPrint", null);
                re.getPDF(file);
                pdfList.add(file);
            } catch (Exception e) {
                log.log(Level.SEVERE, e.getLocalizedMessage(), e);
            }
        }
        try {
            File outFile = File.createTempFile("WHRPayPrint", null);
            AEnv.mergePdf(pdfList, outFile);
            String name = Msg.translate(Env.getCtx(), "Remittance");
            remitViewer = new SimplePDFViewer(form.getFormName() + " - " + name, new FileInputStream(outFile));
            remitViewer.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
            remitViewer.setWidth("100%");
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getLocalizedMessage(), e);
        }
    }
    dispose();
    if (chequeViewer != null)
        SessionManager.getAppDesktop().showWindow(chequeViewer);
    if (remitViewer != null)
        SessionManager.getAppDesktop().showWindow(remitViewer);
}
Also used : ReportEngine(org.compiere.print.ReportEngine) SimplePDFViewer(org.adempiere.webui.window.SimplePDFViewer) ArrayList(java.util.ArrayList) MHRPaySelectionCheck(org.eevolution.model.MHRPaySelectionCheck) File(java.io.File) FileInputStream(java.io.FileInputStream) HRPayPrint(org.eevolution.service.HRPayPrint)

Example 2 with MHRPaySelectionCheck

use of org.eevolution.model.MHRPaySelectionCheck in project adempiere by adempiere.

the class VHRPayPrint method cmd_print.

//  cmd_EFT
/**
	 *  Print Checks and/or Remittance
	 */
private void cmd_print() {
    String PaymentRule = ((ValueNamePair) fPaymentRule.getSelectedItem()).getValue();
    log.info(PaymentRule);
    if (!getChecks(PaymentRule))
        return;
    panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    boolean somethingPrinted = false;
    boolean directPrint = !Ini.isPropertyBool(Ini.P_PRINTPREVIEW);
    //	for all checks
    for (MHRPaySelectionCheck check : m_checks) {
        //	ReportCtrl will check BankAccountDoc for PrintFormat
        boolean ok = ReportCtl.startDocumentPrint(ReportEngine.HR_CHECK, check.get_ID(), null, Env.getWindowNo(panel), directPrint);
        if (!somethingPrinted && ok)
            somethingPrinted = true;
    }
    //	Confirm Print and Update BankAccountDoc
    if (somethingPrinted && ADialog.ask(m_WindowNo, panel, "VPayPrintSuccess?")) {
        int lastDocumentNo = MHRPaySelectionCheck.confirmPrint(m_checks, m_batch);
        if (lastDocumentNo != 0) {
            StringBuffer sb = new StringBuffer();
            sb.append("UPDATE C_BankAccountDoc SET CurrentNext=").append(++lastDocumentNo).append(" WHERE C_BankAccount_ID=").append(m_C_BankAccount_ID).append(" AND PaymentRule='").append(PaymentRule).append("'");
            DB.executeUpdate(sb.toString(), null);
        }
    }
    if (ADialog.ask(m_WindowNo, panel, "VPayPrintPrintRemittance")) {
        for (MHRPaySelectionCheck check : m_checks) {
            ReportCtl.startDocumentPrint(ReportEngine.HR_REMITTANCE, check.get_ID(), null, Env.getWindowNo(panel), directPrint);
        }
    }
    //	remittance
    panel.setCursor(Cursor.getDefaultCursor());
    dispose();
}
Also used : MHRPaySelectionCheck(org.eevolution.model.MHRPaySelectionCheck) ValueNamePair(org.compiere.util.ValueNamePair) HRPayPrint(org.eevolution.service.HRPayPrint)

Example 3 with MHRPaySelectionCheck

use of org.eevolution.model.MHRPaySelectionCheck in project adempiere by adempiere.

the class HRGenericPaymentExport method exportToFile.

/**************************************************************************
	 *  Export to File
	 *  @param checks array of checks
	 *  @param file file to export checks
	 *  @return number of lines
	 */
public int exportToFile(List<MHRPaySelectionCheck> checks, File file, StringBuffer err) {
    if (checks == null || checks.size() == 0)
        return 0;
    //  Must be a file
    if (file.isDirectory()) {
        err.append("No se puede escribir, el archivo seleccionado es un directorio - " + file.getAbsolutePath());
        s_log.log(Level.SEVERE, err.toString());
        return -1;
    }
    //  delete if exists
    try {
        if (file.exists())
            file.delete();
    } catch (Exception e) {
        s_log.log(Level.WARNING, "Could not delete - " + file.getAbsolutePath(), e);
    }
    //  ease
    char x = '"';
    int noLines = 0;
    StringBuffer line = null;
    try {
        FileWriter fw = new FileWriter(file);
        //  write header
        line = new StringBuffer();
        line.append(x).append("Value").append(x).append(",").append(x).append("Name").append(x).append(",").append(x).append("Contact").append(x).append(",").append(x).append("Addr1").append(x).append(",").append(x).append("Addr2").append(x).append(",").append(x).append("City").append(x).append(",").append(x).append("State").append(x).append(",").append(x).append("ZIP").append(x).append(",").append(x).append("Country").append(x).append(",").append(x).append("ReferenceNo").append(x).append(",").append(x).append("DocumentNo").append(x).append(",").append(x).append("PayDate").append(x).append(",").append(x).append("Currency").append(x).append(",").append(x).append("PayAmount").append(x).append(",").append(x).append("Comment").append(x).append(Env.NL);
        fw.write(line.toString());
        noLines++;
        //  write lines
        for (MHRPaySelectionCheck mpp : checks) {
            if (mpp == null)
                continue;
            //  BPartner Info
            String[] bp = getBPartnerInfo(mpp.getC_BPartner_ID());
            //  Comment - list of invoice document no
            StringBuffer comment = new StringBuffer();
            List<MHRPaySelectionLine> psls = mpp.getPaySelectionLines(false);
            for (MHRPaySelectionLine psl : psls) {
                comment.append(psl.getHR_Movement().getHR_Concept().getName());
            }
            line = new StringBuffer();
            // Value
            line.append(x).append(bp[BP_VALUE]).append(x).append(",").append(x).append(bp[BP_NAME]).append(x).append(// Name
            ",").append(x).append(bp[BP_CONTACT]).append(x).append(// Contact
            ",").append(x).append(bp[BP_ADDR1]).append(x).append(// Addr1
            ",").append(x).append(bp[BP_ADDR2]).append(x).append(// Addr2
            ",").append(x).append(bp[BP_CITY]).append(x).append(// City
            ",").append(x).append(bp[BP_REGION]).append(x).append(// State
            ",").append(x).append(bp[BP_POSTAL]).append(x).append(// ZIP
            ",").append(x).append(bp[BP_COUNTRY]).append(x).append(// Country
            ",").append(x).append(bp[BP_REFNO]).append(x).append(// ReferenceNo
            ",").append(x).append(mpp.getDocumentNo()).append(x).append(// DocumentNo
            ",").append(mpp.getParent().getPayDate()).append(// PayDate
            ",").append(x).append(MCurrency.getISO_Code(Env.getCtx(), mpp.getParent().getC_Currency_ID())).append(x).append(// Currency
            ",").append(mpp.getPayAmt()).append(// PayAmount
            ",").append(x).append(comment.toString()).append(// Comment
            x).append(Env.NL);
            fw.write(line.toString());
            noLines++;
        }
        //  write line
        fw.flush();
        fw.close();
    } catch (Exception e) {
        err.append(e.toString());
        s_log.log(Level.SEVERE, "", e);
        return -1;
    }
    return noLines;
}
Also used : MHRPaySelectionLine(org.eevolution.model.MHRPaySelectionLine) FileWriter(java.io.FileWriter) MHRPaySelectionCheck(org.eevolution.model.MHRPaySelectionCheck) SQLException(java.sql.SQLException)

Example 4 with MHRPaySelectionCheck

use of org.eevolution.model.MHRPaySelectionCheck in project adempiere by adempiere.

the class HRPaySelectionCreateCheck method createCheck.

//	doIt
/**
     * Create Check from line
     *
     * @param paySelectionLine
     */
private void createCheck(MHRPaySelectionLine paySelectionLine) {
    paySelectionChecks.stream().filter(paySelectionCheck -> paySelectionCheck.getC_BPartner_ID() == paySelectionLine.getHR_Movement().getC_BPartner_ID()).forEach(paySelectionCheck -> {
        paySelectionCheck.addLine(paySelectionLine);
        paySelectionCheck.saveEx();
        paySelectionLine.setHR_PaySelectionCheck_ID(paySelectionCheck.getHR_PaySelectionCheck_ID());
        paySelectionLine.setProcessed(true);
        paySelectionCheck.saveEx();
    });
    Optional<String> paymentRuleOptional = Optional.of(paySelectionLine.getPaymentRule());
    MHRPaySelectionCheck paySelectionCheck = new MHRPaySelectionCheck(paySelectionLine, paymentRuleOptional.orElse(MHRPaySelectionCheck.PAYMENTRULE_DirectDeposit));
    paySelectionCheck.setAD_Org_ID(paySelectionLine.getHR_PaySelection().getAD_Org_ID());
    paySelectionCheck.saveEx();
    paySelectionLine.setHR_PaySelectionCheck_ID(paySelectionCheck.getHR_PaySelectionCheck_ID());
    paySelectionLine.setProcessed(true);
    paySelectionLine.saveEx();
    paySelectionChecks.add(paySelectionCheck);
}
Also used : Arrays(java.util.Arrays) List(java.util.List) MHRPaySelectionCheck(org.eevolution.model.MHRPaySelectionCheck) MHRPaySelection(org.eevolution.model.MHRPaySelection) X_C_Order(org.compiere.model.X_C_Order) Optional(java.util.Optional) MHRPaySelectionLine(org.eevolution.model.MHRPaySelectionLine) ArrayList(java.util.ArrayList) MHRPaySelectionCheck(org.eevolution.model.MHRPaySelectionCheck)

Aggregations

MHRPaySelectionCheck (org.eevolution.model.MHRPaySelectionCheck)4 ArrayList (java.util.ArrayList)2 MHRPaySelectionLine (org.eevolution.model.MHRPaySelectionLine)2 HRPayPrint (org.eevolution.service.HRPayPrint)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileWriter (java.io.FileWriter)1 SQLException (java.sql.SQLException)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Optional (java.util.Optional)1 SimplePDFViewer (org.adempiere.webui.window.SimplePDFViewer)1 X_C_Order (org.compiere.model.X_C_Order)1 ReportEngine (org.compiere.print.ReportEngine)1 ValueNamePair (org.compiere.util.ValueNamePair)1 MHRPaySelection (org.eevolution.model.MHRPaySelection)1