IDEMPIERE-1546 There is no OSGi interface for a PaymentExport / thanks to Markus Bozem
This commit is contained in:
parent
4e1f52c9ca
commit
1616e7a95b
|
@ -45,6 +45,7 @@ import org.compiere.model.PaymentProcessor;
|
||||||
import org.compiere.model.StandardTaxProvider;
|
import org.compiere.model.StandardTaxProvider;
|
||||||
import org.compiere.process.ProcessCall;
|
import org.compiere.process.ProcessCall;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.PaymentExport;
|
||||||
import org.compiere.util.ReplenishInterface;
|
import org.compiere.util.ReplenishInterface;
|
||||||
import org.osgi.framework.FrameworkUtil;
|
import org.osgi.framework.FrameworkUtil;
|
||||||
|
|
||||||
|
@ -415,4 +416,38 @@ public class Core {
|
||||||
|
|
||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get PaymentExporter instance
|
||||||
|
*
|
||||||
|
* @param className
|
||||||
|
* @return instance of the PaymentExporterInterface or null
|
||||||
|
*/
|
||||||
|
public static PaymentExport getPaymentExporter (String className){
|
||||||
|
if (className == null || className.length() == 0) {
|
||||||
|
s_log.log(Level.SEVERE, "No PaymentExporter class name");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
PaymentExport myPaymentExporter = null;
|
||||||
|
|
||||||
|
List<IPaymentExporterFactory> factoryList =
|
||||||
|
Service.locator().list(IPaymentExporterFactory.class).getServices();
|
||||||
|
if (factoryList != null) {
|
||||||
|
for(IPaymentExporterFactory factory : factoryList) {
|
||||||
|
PaymentExport exporter = factory.newPaymentExporterInstance(className);
|
||||||
|
if (exporter != null) {
|
||||||
|
myPaymentExporter = exporter;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myPaymentExporter == null) {
|
||||||
|
s_log.log(Level.CONFIG, className + " not found in service/extension registry and classpath");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return myPaymentExporter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: iDempiere Business Suite ERP/CRM/SCM *
|
||||||
|
* Copyright (C) 2017 Markus Bozem *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.adempiere.base;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.base.equinox.EquinoxExtensionLocator;
|
||||||
|
import org.compiere.util.CLogger;
|
||||||
|
import org.compiere.util.PaymentExport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author mbozem
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DefaultPaymentExporterFactory implements IPaymentExporterFactory {
|
||||||
|
|
||||||
|
private final static CLogger s_log = CLogger.getCLogger(DefaultPaymentExporterFactory.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor
|
||||||
|
*/
|
||||||
|
public DefaultPaymentExporterFactory() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PaymentExport newPaymentExporterInstance(String className) {
|
||||||
|
PaymentExport myExporter = null;
|
||||||
|
myExporter = EquinoxExtensionLocator.instance().locate(PaymentExport.class, className, null).getExtension();
|
||||||
|
if (myExporter == null) {
|
||||||
|
//fall back to dynamic java class loadup
|
||||||
|
try {
|
||||||
|
Class<?> peClass = Class.forName(className);
|
||||||
|
if (peClass != null)
|
||||||
|
myExporter = (PaymentExport)peClass.newInstance();
|
||||||
|
} catch (Error e1) { // NoClassDefFound
|
||||||
|
s_log.log(Level.SEVERE, className + " - Error=" + e1.getMessage());
|
||||||
|
return null;
|
||||||
|
} catch (Exception e2) {
|
||||||
|
s_log.log(Level.SEVERE, className, e2);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return myExporter;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: iDempiere Business Suite ERP/CRM/SCM *
|
||||||
|
* Copyright (C) 2017 Markus Bozem *
|
||||||
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
|
* See the GNU General Public License for more details. *
|
||||||
|
* You should have received a copy of the GNU General Public License along *
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.adempiere.base;
|
||||||
|
|
||||||
|
import org.compiere.util.PaymentExport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PaymentExporter factory interface.
|
||||||
|
* @author mbozem
|
||||||
|
*/
|
||||||
|
public interface IPaymentExporterFactory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param className
|
||||||
|
* @return payment exporter instance
|
||||||
|
*/
|
||||||
|
public PaymentExport newPaymentExporterInstance(String className);
|
||||||
|
}
|
|
@ -20,11 +20,14 @@ import java.math.BigDecimal;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
|
import org.compiere.acct.Doc;
|
||||||
import org.compiere.process.DocAction;
|
import org.compiere.process.DocAction;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
@ -43,7 +46,7 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -5752888482207479355L;
|
private static final long serialVersionUID = 2130445794890189020L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Check for Payment
|
* Get Check for Payment
|
||||||
|
@ -385,60 +388,127 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck
|
||||||
* Create Payments the first time
|
* Create Payments the first time
|
||||||
* @param checks checks
|
* @param checks checks
|
||||||
* @param batch batch
|
* @param batch batch
|
||||||
|
* @param createDeposit create deposit batch
|
||||||
* @return last Document number or 0 if nothing printed
|
* @return last Document number or 0 if nothing printed
|
||||||
*/
|
*/
|
||||||
public static int confirmPrint (MPaySelectionCheck[] checks, MPaymentBatch batch)
|
public static int confirmPrint (MPaySelectionCheck[] checks, MPaymentBatch batch, boolean createDepositBatch)
|
||||||
{
|
{
|
||||||
boolean localTrx = false;
|
boolean localTrx = false;
|
||||||
String trxName = null;
|
String trxName = null;
|
||||||
if (checks.length > 0)
|
|
||||||
trxName = checks[0].get_TrxName();
|
|
||||||
Trx trx = null;
|
|
||||||
if (trxName == null) {
|
|
||||||
localTrx = true;
|
|
||||||
trxName = Trx.createTrxName("ConfirmPrintMulti");
|
|
||||||
trx = Trx.get(trxName, true);
|
|
||||||
trx.setDisplayName(MPaySelectionCheck.class.getName()+"_confirmPrints");
|
|
||||||
}
|
|
||||||
int lastDocumentNo = 0;
|
int lastDocumentNo = 0;
|
||||||
try {
|
|
||||||
for (int i = 0; i < checks.length; i++)
|
|
||||||
{
|
|
||||||
MPaySelectionCheck check = checks[i];
|
|
||||||
if (localTrx)
|
|
||||||
check.set_TrxName(trxName);
|
|
||||||
confirmPrint(check, batch);
|
|
||||||
|
|
||||||
// Get Check Document No
|
if (checks.length > 0)
|
||||||
try
|
{
|
||||||
{
|
trxName = checks[0].get_TrxName();
|
||||||
int no = Integer.parseInt(check.getDocumentNo());
|
Properties ctx = checks[0].getCtx();
|
||||||
if (lastDocumentNo < no)
|
int c_BankAccount_ID = checks[0].getC_PaySelection().getC_BankAccount_ID() ;
|
||||||
lastDocumentNo = no;
|
String paymentRule = checks[0].getPaymentRule() ;
|
||||||
}
|
Boolean isDebit ;
|
||||||
catch (NumberFormatException ex)
|
if (MInvoice.PAYMENTRULE_DirectDeposit.compareTo(paymentRule) == 0
|
||||||
{
|
|| MInvoice.PAYMENTRULE_Check.compareTo(paymentRule) == 0
|
||||||
s_log.log(Level.SEVERE, "DocumentNo=" + check.getDocumentNo(), ex);
|
|| MInvoice.PAYMENTRULE_OnCredit.compareTo(paymentRule) == 0)
|
||||||
}
|
{
|
||||||
} // all checks
|
isDebit = false ;
|
||||||
} catch (Exception e) {
|
|
||||||
if (localTrx && trx != null) {
|
|
||||||
trx.rollback();
|
|
||||||
trx.close();
|
|
||||||
trx = null;
|
|
||||||
}
|
}
|
||||||
throw new AdempiereException(e);
|
else if (MInvoice.PAYMENTRULE_DirectDebit.compareTo(paymentRule) == 0)
|
||||||
} finally {
|
{
|
||||||
if (localTrx && trx != null) {
|
isDebit = true ;
|
||||||
trx.commit();
|
}
|
||||||
trx.close();
|
else
|
||||||
|
{
|
||||||
|
isDebit = false ;
|
||||||
|
createDepositBatch = false ;
|
||||||
|
}
|
||||||
|
Trx trx = null;
|
||||||
|
if (trxName == null) {
|
||||||
|
localTrx = true;
|
||||||
|
trxName = Trx.createTrxName("ConfirmPrintMulti");
|
||||||
|
trx = Trx.get(trxName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
MDepositBatch depositBatch = null;
|
||||||
|
if (createDepositBatch)
|
||||||
|
{
|
||||||
|
depositBatch = new MDepositBatch(ctx, 0, trxName) ;
|
||||||
|
depositBatch.setC_BankAccount_ID(c_BankAccount_ID);
|
||||||
|
if (isDebit)
|
||||||
|
{
|
||||||
|
depositBatch.setC_DocType_ID(MDocType.getDocType(Doc.DOCTYPE_ARReceipt));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
depositBatch.setC_DocType_ID(MDocType.getDocType(Doc.DOCTYPE_APPayment));
|
||||||
|
}
|
||||||
|
depositBatch.setDateDeposit(new Timestamp((new Date()).getTime()));
|
||||||
|
depositBatch.setDateDoc(new Timestamp((new Date()).getTime()));
|
||||||
|
depositBatch.saveEx();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < checks.length; i++)
|
||||||
|
{
|
||||||
|
MPaySelectionCheck check = checks[i];
|
||||||
|
if (localTrx)
|
||||||
|
check.set_TrxName(trxName);
|
||||||
|
confirmPrint(check, batch);
|
||||||
|
if (createDepositBatch)
|
||||||
|
{
|
||||||
|
MDepositBatchLine depositBatchLine = new MDepositBatchLine(depositBatch) ;
|
||||||
|
depositBatchLine.setC_Payment_ID(check.getC_Payment_ID());
|
||||||
|
depositBatchLine.setProcessed(true);
|
||||||
|
depositBatchLine.saveEx();
|
||||||
|
}
|
||||||
|
// Get Check Document No
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int no = Integer.parseInt(check.getDocumentNo());
|
||||||
|
if (lastDocumentNo < no)
|
||||||
|
lastDocumentNo = no;
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
s_log.log(Level.SEVERE, "DocumentNo=" + check.getDocumentNo(), ex);
|
||||||
|
}
|
||||||
|
} // all checks
|
||||||
|
|
||||||
|
if (createDepositBatch)
|
||||||
|
{
|
||||||
|
|
||||||
|
depositBatch.setProcessed(true);
|
||||||
|
depositBatch.saveEx();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (localTrx && trx != null) {
|
||||||
|
trx.rollback();
|
||||||
|
trx.close();
|
||||||
|
trx = null;
|
||||||
|
}
|
||||||
|
throw new AdempiereException(e);
|
||||||
|
} finally {
|
||||||
|
if (localTrx && trx != null) {
|
||||||
|
trx.commit();
|
||||||
|
trx.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_log.isLoggable(Level.FINE)) s_log.fine("Last Document No = " + lastDocumentNo);
|
if (s_log.isLoggable(Level.FINE)) s_log.fine("Last Document No = " + lastDocumentNo);
|
||||||
return lastDocumentNo;
|
return lastDocumentNo;
|
||||||
} // confirmPrint
|
} // confirmPrint
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Confirm Print.
|
||||||
|
* Create Payments the first time
|
||||||
|
* @param checks checks
|
||||||
|
* @param batch batch
|
||||||
|
* @return last Document number or 0 if nothing printed
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static int confirmPrint (MPaySelectionCheck[] checks, MPaymentBatch batch)
|
||||||
|
{
|
||||||
|
return confirmPrint (checks,batch,false) ;
|
||||||
|
} // confirmPrint
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
static private CLogger s_log = CLogger.getCLogger (MPaySelectionCheck.class);
|
static private CLogger s_log = CLogger.getCLogger (MPaySelectionCheck.class);
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.io.FileWriter;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.compiere.model.MCurrency;
|
import org.compiere.model.MCurrency;
|
||||||
|
@ -67,11 +68,13 @@ public class GenericPaymentExport implements PaymentExport
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Export to File
|
* Export to File
|
||||||
* @param checks array of checks
|
* @param checks array of checks
|
||||||
|
* @param depositBatch book the payments as single position
|
||||||
|
* @param paymentRule selected payment rule
|
||||||
* @param file file to export checks
|
* @param file file to export checks
|
||||||
* @return number of lines
|
* @return number of lines
|
||||||
*/
|
*/
|
||||||
public int exportToFile (MPaySelectionCheck[] checks, File file, StringBuffer err)
|
public int exportToFile(MPaySelectionCheck[] checks, boolean depositBatch, String paymentRule, File file,
|
||||||
{
|
StringBuffer err) {
|
||||||
if (checks == null || checks.length == 0)
|
if (checks == null || checks.length == 0)
|
||||||
return 0;
|
return 0;
|
||||||
// Must be a file
|
// Must be a file
|
||||||
|
@ -115,6 +118,7 @@ public class GenericPaymentExport implements PaymentExport
|
||||||
.append(x).append("PayDate").append(x).append(",")
|
.append(x).append("PayDate").append(x).append(",")
|
||||||
.append(x).append("Currency").append(x).append(",")
|
.append(x).append("Currency").append(x).append(",")
|
||||||
.append(x).append("PayAmount").append(x).append(",")
|
.append(x).append("PayAmount").append(x).append(",")
|
||||||
|
.append(x).append("DepositBatch").append(x).append(",")
|
||||||
.append(x).append("Comment").append(x)
|
.append(x).append("Comment").append(x)
|
||||||
.append(Env.NL);
|
.append(Env.NL);
|
||||||
fw.write(line.toString());
|
fw.write(line.toString());
|
||||||
|
@ -154,6 +158,7 @@ public class GenericPaymentExport implements PaymentExport
|
||||||
.append(mpp.getParent().getPayDate()).append(",") // PayDate
|
.append(mpp.getParent().getPayDate()).append(",") // PayDate
|
||||||
.append(x).append(MCurrency.getISO_Code(Env.getCtx(), mpp.getParent().getC_Currency_ID())).append(x).append(",") // Currency
|
.append(x).append(MCurrency.getISO_Code(Env.getCtx(), mpp.getParent().getC_Currency_ID())).append(x).append(",") // Currency
|
||||||
.append(mpp.getPayAmt()).append(",") // PayAmount
|
.append(mpp.getPayAmt()).append(",") // PayAmount
|
||||||
|
.append(x).append(depositBatch).append(x).append(",")
|
||||||
.append(x).append(comment.toString()).append(x) // Comment
|
.append(x).append(comment.toString()).append(x) // Comment
|
||||||
.append(Env.NL);
|
.append(Env.NL);
|
||||||
fw.write(line.toString());
|
fw.write(line.toString());
|
||||||
|
@ -249,5 +254,35 @@ public class GenericPaymentExport implements PaymentExport
|
||||||
return bp;
|
return bp;
|
||||||
} // getBPartnerInfo
|
} // getBPartnerInfo
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFilenamePrefix() {
|
||||||
|
String creationDate = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(System.currentTimeMillis()) ;
|
||||||
|
return "payments-" + creationDate ;
|
||||||
|
}
|
||||||
|
|
||||||
} // PaymentExport
|
@Override
|
||||||
|
public String getFilenameSuffix() {
|
||||||
|
return ".csv";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentType() {
|
||||||
|
return "text/csv";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsDepositBatch() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsSeparateBooking() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getDefaultDepositBatch() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // PaymentExporterInterface
|
||||||
|
|
|
@ -24,6 +24,10 @@ import org.compiere.model.MPaySelectionCheck;
|
||||||
* Custom Payment Export Interface
|
* Custom Payment Export Interface
|
||||||
*
|
*
|
||||||
* @author Carlos Ruiz - GlobalQSS
|
* @author Carlos Ruiz - GlobalQSS
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Markus Bozem - IDEMPIERE-1546 / IDEMPIERE-3286
|
||||||
|
*
|
||||||
* @version PaymentExport.java
|
* @version PaymentExport.java
|
||||||
*/
|
*/
|
||||||
public interface PaymentExport
|
public interface PaymentExport
|
||||||
|
@ -34,7 +38,74 @@ public interface PaymentExport
|
||||||
* @param checks array of checks
|
* @param checks array of checks
|
||||||
* @param file file to export checks
|
* @param file file to export checks
|
||||||
* @return number of lines
|
* @return number of lines
|
||||||
|
*
|
||||||
|
* This method is preserved for backward compatibility (old non-OSGi way via fragment),
|
||||||
|
* new interfaces can leave this method unimplemented and must implement the other methods
|
||||||
*/
|
*/
|
||||||
public int exportToFile (MPaySelectionCheck[] checks, File file, StringBuffer err);
|
public default int exportToFile (MPaySelectionCheck[] checks, File file, StringBuffer err) {
|
||||||
|
return exportToFile (checks, false, (String)null, file, err);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Export to file
|
||||||
|
* @param checks array of checks
|
||||||
|
* @param depositBatch create deposit batch
|
||||||
|
* @param file file to export checks
|
||||||
|
* @return number of lines
|
||||||
|
*/
|
||||||
|
public default int exportToFile (MPaySelectionCheck[] checks, boolean depositBatch, String paymentRule, File file, StringBuffer err) {
|
||||||
|
return exportToFile (checks, file, err);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the filename prefix from plugin
|
||||||
|
* e.g. "SEPA-Credit-Transfer-"
|
||||||
|
* @return prefix for filename
|
||||||
|
*/
|
||||||
|
public default String getFilenamePrefix() {
|
||||||
|
return "paymentExport";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the filename suffix from plugin
|
||||||
|
* e.g. ".xml"
|
||||||
|
* @return suffix for filename
|
||||||
|
*/
|
||||||
|
public default String getFilenameSuffix() {
|
||||||
|
return ".txt";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the content type from plugin
|
||||||
|
* e.g. "text/xml" or "text/csv"
|
||||||
|
* @return content type delivered to browser
|
||||||
|
*/
|
||||||
|
public default String getContentType() {
|
||||||
|
return "text/plain";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin supports deposit batch
|
||||||
|
* @return true if supported
|
||||||
|
*/
|
||||||
|
public default boolean supportsDepositBatch() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plugin supports booking payments separate on bank statement (no deposit batch)
|
||||||
|
* @return true if supported
|
||||||
|
*/
|
||||||
|
public default boolean supportsSeparateBooking() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default if supportsDepositBatch is true and supportsSeparateBooking is true
|
||||||
|
* @return true if deposit batch should be selected on default, false if deposit batch should not be selected
|
||||||
|
*/
|
||||||
|
public default boolean getDefaultDepositBatch() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // PaymentExport
|
} // PaymentExport
|
||||||
|
|
|
@ -46,6 +46,7 @@ import static org.compiere.model.SystemIDs.*;
|
||||||
import org.compiere.plaf.CompiereColor;
|
import org.compiere.plaf.CompiereColor;
|
||||||
import org.compiere.print.ReportCtl;
|
import org.compiere.print.ReportCtl;
|
||||||
import org.compiere.print.ReportEngine;
|
import org.compiere.print.ReportEngine;
|
||||||
|
import org.compiere.swing.CCheckBox;
|
||||||
import org.compiere.swing.CComboBox;
|
import org.compiere.swing.CComboBox;
|
||||||
import org.compiere.swing.CLabel;
|
import org.compiere.swing.CLabel;
|
||||||
import org.compiere.swing.CPanel;
|
import org.compiere.swing.CPanel;
|
||||||
|
@ -54,7 +55,6 @@ import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Ini;
|
import org.compiere.util.Ini;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.compiere.util.PaymentExport;
|
|
||||||
import org.compiere.util.ValueNamePair;
|
import org.compiere.util.ValueNamePair;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,6 +65,7 @@ import org.compiere.util.ValueNamePair;
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Carlos Ruiz - GlobalQSS - FR 3132033 - Make payment export class configurable per bank
|
* Carlos Ruiz - GlobalQSS - FR 3132033 - Make payment export class configurable per bank
|
||||||
|
* Markus Bozem: IDEMPIERE-1546 / IDEMPIERE-3286
|
||||||
*/
|
*/
|
||||||
public class VPayPrint extends PayPrint implements FormPanel, ActionListener, VetoableChangeListener
|
public class VPayPrint extends PayPrint implements FormPanel, ActionListener, VetoableChangeListener
|
||||||
{
|
{
|
||||||
|
@ -120,7 +121,10 @@ public class VPayPrint extends PayPrint implements FormPanel, ActionListener, Ve
|
||||||
private VNumber fBalance = new VNumber();
|
private VNumber fBalance = new VNumber();
|
||||||
private CLabel lCurrency = new CLabel();
|
private CLabel lCurrency = new CLabel();
|
||||||
private CLabel fCurrency = new CLabel();
|
private CLabel fCurrency = new CLabel();
|
||||||
|
private CLabel lDepositBatch = new CLabel();
|
||||||
|
private CCheckBox fDepositBatch = new CCheckBox();
|
||||||
|
private CLabel lSumPayments = new CLabel();
|
||||||
|
private VNumber fSumPayments = new VNumber();
|
||||||
/**
|
/**
|
||||||
* Static Init
|
* Static Init
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
@ -133,6 +137,8 @@ public class VPayPrint extends PayPrint implements FormPanel, ActionListener, Ve
|
||||||
southLayout.setAlignment(FlowLayout.RIGHT);
|
southLayout.setAlignment(FlowLayout.RIGHT);
|
||||||
centerPanel.setLayout(centerLayout);
|
centerPanel.setLayout(centerLayout);
|
||||||
//
|
//
|
||||||
|
bPrint.setEnabled(false);
|
||||||
|
bExport.setEnabled(false);
|
||||||
bPrint.addActionListener(this);
|
bPrint.addActionListener(this);
|
||||||
bExport.addActionListener(this);
|
bExport.addActionListener(this);
|
||||||
bCancel.addActionListener(this);
|
bCancel.addActionListener(this);
|
||||||
|
@ -156,6 +162,10 @@ public class VPayPrint extends PayPrint implements FormPanel, ActionListener, Ve
|
||||||
fBalance.setReadWrite(false);
|
fBalance.setReadWrite(false);
|
||||||
fBalance.setDisplayType(DisplayType.Amount);
|
fBalance.setDisplayType(DisplayType.Amount);
|
||||||
lCurrency.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
lCurrency.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
||||||
|
lDepositBatch.setText(Msg.translate(Env.getCtx(), "C_DepositBatch_ID"));
|
||||||
|
lSumPayments.setText(Msg.getMsg(Env.getCtx(), "Sum"));
|
||||||
|
fSumPayments.setReadWrite(false);
|
||||||
|
fSumPayments.setDisplayType(DisplayType.Amount);
|
||||||
//
|
//
|
||||||
southPanel.add(bCancel, null);
|
southPanel.add(bCancel, null);
|
||||||
southPanel.add(bExport, null);
|
southPanel.add(bExport, null);
|
||||||
|
@ -190,6 +200,15 @@ public class VPayPrint extends PayPrint implements FormPanel, ActionListener, Ve
|
||||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 12, 5), 0, 0));
|
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 12, 5), 0, 0));
|
||||||
centerPanel.add(fCurrency, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
|
centerPanel.add(fCurrency, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
|
||||||
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 12, 12), 0, 0));
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 12, 12), 0, 0));
|
||||||
|
|
||||||
|
centerPanel.add(lDepositBatch, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
|
||||||
|
centerPanel.add(fDepositBatch, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0));
|
||||||
|
centerPanel.add(lSumPayments, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
|
||||||
|
centerPanel.add(fSumPayments, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0
|
||||||
|
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 12), 0, 0));
|
||||||
} // VPayPrint
|
} // VPayPrint
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -311,6 +330,9 @@ public class VPayPrint extends PayPrint implements FormPanel, ActionListener, Ve
|
||||||
if(noPayments != null)
|
if(noPayments != null)
|
||||||
fNoPayments.setText(noPayments);
|
fNoPayments.setText(noPayments);
|
||||||
|
|
||||||
|
if(sumPayments != null)
|
||||||
|
fSumPayments.setValue(sumPayments);
|
||||||
|
|
||||||
bProcess.setEnabled(PaymentRule.equals("T"));
|
bProcess.setEnabled(PaymentRule.equals("T"));
|
||||||
|
|
||||||
if(documentNo != null)
|
if(documentNo != null)
|
||||||
|
@ -318,8 +340,43 @@ public class VPayPrint extends PayPrint implements FormPanel, ActionListener, Ve
|
||||||
|
|
||||||
if(msg != null && msg.length() > 0)
|
if(msg != null && msg.length() > 0)
|
||||||
ADialog.error(m_WindowNo, panel, msg);
|
ADialog.error(m_WindowNo, panel, msg);
|
||||||
|
|
||||||
|
getPluginFeatures();
|
||||||
} // loadPaymentRuleInfo
|
} // loadPaymentRuleInfo
|
||||||
|
|
||||||
|
protected void getPluginFeatures()
|
||||||
|
{
|
||||||
|
if (m_C_PaySelection_ID!=0)
|
||||||
|
{
|
||||||
|
if (loadPaymentExportClass (null)>=0)
|
||||||
|
{
|
||||||
|
bExport.setEnabled(true);
|
||||||
|
|
||||||
|
fDepositBatch.setValue(m_PaymentExport.getDefaultDepositBatch());
|
||||||
|
if (m_PaymentExport.supportsDepositBatch() && m_PaymentExport.supportsSeparateBooking())
|
||||||
|
{
|
||||||
|
fDepositBatch.setReadWrite(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fDepositBatch.setReadWrite(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bExport.setEnabled(false);
|
||||||
|
}
|
||||||
|
if (printFormatId!=null && printFormatId!=0)
|
||||||
|
{
|
||||||
|
bPrint.setEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bPrint.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // getPluginFeatures
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Export payments to file
|
* Export payments to file
|
||||||
|
@ -339,7 +396,8 @@ public class VPayPrint extends PayPrint implements FormPanel, ActionListener, Ve
|
||||||
fc.setDialogTitle(Msg.getMsg(Env.getCtx(), "Export"));
|
fc.setDialogTitle(Msg.getMsg(Env.getCtx(), "Export"));
|
||||||
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||||
fc.setMultiSelectionEnabled(false);
|
fc.setMultiSelectionEnabled(false);
|
||||||
fc.setSelectedFile(new java.io.File("paymentExport.txt"));
|
String filename = m_PaymentExport.getFilenamePrefix() + m_PaymentExport.getFilenameSuffix();
|
||||||
|
fc.setSelectedFile(new java.io.File(filename));
|
||||||
if (fc.showSaveDialog(panel) != JFileChooser.APPROVE_OPTION)
|
if (fc.showSaveDialog(panel) != JFileChooser.APPROVE_OPTION)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -349,26 +407,14 @@ public class VPayPrint extends PayPrint implements FormPanel, ActionListener, Ve
|
||||||
if (m_PaymentExportClass == null || m_PaymentExportClass.trim().length() == 0) {
|
if (m_PaymentExportClass == null || m_PaymentExportClass.trim().length() == 0) {
|
||||||
m_PaymentExportClass = "org.compiere.util.GenericPaymentExport";
|
m_PaymentExportClass = "org.compiere.util.GenericPaymentExport";
|
||||||
}
|
}
|
||||||
// Get Payment Export Class
|
|
||||||
PaymentExport custom = null;
|
no = loadPaymentExportClass(err) ;
|
||||||
try
|
|
||||||
|
if (no >= 0)
|
||||||
{
|
{
|
||||||
Class<?> clazz = Class.forName(m_PaymentExportClass);
|
no = m_PaymentExport.exportToFile(m_checks,(Boolean) fDepositBatch.getValue(),PaymentRule, fc.getSelectedFile(), err);
|
||||||
custom = (PaymentExport)clazz.newInstance();
|
|
||||||
no = custom.exportToFile(m_checks, fc.getSelectedFile(), err);
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
|
||||||
no = -1;
|
|
||||||
err.append("No custom PaymentExport class " + m_PaymentExportClass + " - " + e.toString());
|
|
||||||
log.log(Level.SEVERE, err.toString(), e);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
no = -1;
|
|
||||||
err.append("Error in " + m_PaymentExportClass + " check log, " + e.toString());
|
|
||||||
log.log(Level.SEVERE, err.toString(), e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (no >= 0) {
|
if (no >= 0) {
|
||||||
ADialog.info(m_WindowNo, panel, "Saved",
|
ADialog.info(m_WindowNo, panel, "Saved",
|
||||||
fc.getSelectedFile().getAbsolutePath() + "\n"
|
fc.getSelectedFile().getAbsolutePath() + "\n"
|
||||||
|
@ -377,7 +423,7 @@ public class VPayPrint extends PayPrint implements FormPanel, ActionListener, Ve
|
||||||
if (ADialog.ask(m_WindowNo, panel, "VPayPrintSuccess?"))
|
if (ADialog.ask(m_WindowNo, panel, "VPayPrintSuccess?"))
|
||||||
{
|
{
|
||||||
// int lastDocumentNo =
|
// int lastDocumentNo =
|
||||||
MPaySelectionCheck.confirmPrint (m_checks, m_batch);
|
MPaySelectionCheck.confirmPrint (m_checks, m_batch, (Boolean) fDepositBatch.getValue());
|
||||||
// document No not updated
|
// document No not updated
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.adempiere.webui.component.Rows;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
import org.adempiere.webui.editor.WNumberEditor;
|
import org.adempiere.webui.editor.WNumberEditor;
|
||||||
import org.adempiere.webui.editor.WSearchEditor;
|
import org.adempiere.webui.editor.WSearchEditor;
|
||||||
|
import org.adempiere.webui.editor.WYesNoEditor;
|
||||||
import org.adempiere.webui.event.ValueChangeEvent;
|
import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.adempiere.webui.event.ValueChangeListener;
|
import org.adempiere.webui.event.ValueChangeListener;
|
||||||
import org.adempiere.webui.panel.ADForm;
|
import org.adempiere.webui.panel.ADForm;
|
||||||
|
@ -61,7 +62,6 @@ import org.compiere.util.DB;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.compiere.util.PaymentExport;
|
|
||||||
import org.compiere.util.ValueNamePair;
|
import org.compiere.util.ValueNamePair;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
@ -80,6 +80,7 @@ import com.itextpdf.text.pdf.PdfReader;
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Carlos Ruiz - GlobalQSS - FR 3132033 - Make payment export class configurable per bank
|
* Carlos Ruiz - GlobalQSS - FR 3132033 - Make payment export class configurable per bank
|
||||||
|
* Markus Bozem: IDEMPIERE-1546 / IDEMPIERE-3286
|
||||||
*/
|
*/
|
||||||
public class WPayPrint extends PayPrint implements IFormController, EventListener<Event>, ValueChangeListener
|
public class WPayPrint extends PayPrint implements IFormController, EventListener<Event>, ValueChangeListener
|
||||||
{
|
{
|
||||||
|
@ -136,6 +137,11 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
|
||||||
protected WNumberEditor fBalance = new WNumberEditor();
|
protected WNumberEditor fBalance = new WNumberEditor();
|
||||||
protected Label lCurrency = new Label();
|
protected Label lCurrency = new Label();
|
||||||
protected Label fCurrency = new Label();
|
protected Label fCurrency = new Label();
|
||||||
|
protected Label lDepositBatch = new Label();
|
||||||
|
protected WYesNoEditor fDepositBatch = new WYesNoEditor("", "", "Book as one post", false, false, true) ;
|
||||||
|
protected Label lSumPayments = new Label();
|
||||||
|
protected WNumberEditor fSumPayments = new WNumberEditor();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static Init
|
* Static Init
|
||||||
|
@ -168,6 +174,10 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
|
||||||
fBalance.setReadWrite(false);
|
fBalance.setReadWrite(false);
|
||||||
fBalance.getComponent().setIntegral(false);
|
fBalance.getComponent().setIntegral(false);
|
||||||
lCurrency.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
lCurrency.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
||||||
|
lDepositBatch.setText(Msg.translate(Env.getCtx(), "C_DepositBatch_ID"));
|
||||||
|
lSumPayments.setText(Msg.getMsg(Env.getCtx(), "Sum"));
|
||||||
|
fSumPayments.setReadWrite(false);
|
||||||
|
fSumPayments.getComponent().setIntegral(false);
|
||||||
//
|
//
|
||||||
southPanel.addButton(bExport);
|
southPanel.addButton(bExport);
|
||||||
southPanel.addButton(bPrint);
|
southPanel.addButton(bPrint);
|
||||||
|
@ -196,7 +206,17 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
|
||||||
row.appendChild(lNoPayments.rightAlign());
|
row.appendChild(lNoPayments.rightAlign());
|
||||||
row.appendChild(fNoPayments);
|
row.appendChild(fNoPayments);
|
||||||
|
|
||||||
|
row = rows.newRow();
|
||||||
|
row.appendChild(lDepositBatch.rightAlign()) ;
|
||||||
|
row.appendChild(fDepositBatch.getComponent()) ;
|
||||||
|
row.appendChild(lSumPayments.rightAlign()) ;
|
||||||
|
row.appendChild(fSumPayments.getComponent()) ;
|
||||||
|
|
||||||
southPanel.getButton(ConfirmPanel.A_OK).setVisible(false);
|
southPanel.getButton(ConfirmPanel.A_OK).setVisible(false);
|
||||||
|
bExport.setDisabled(true);
|
||||||
|
bPrint.setDisabled(true);
|
||||||
|
fDepositBatch.setReadWrite(false);
|
||||||
|
fDocumentNo.setReadWrite(false);
|
||||||
} // VPayPrint
|
} // VPayPrint
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -319,6 +339,9 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
|
||||||
if(noPayments != null)
|
if(noPayments != null)
|
||||||
fNoPayments.setText(noPayments);
|
fNoPayments.setText(noPayments);
|
||||||
|
|
||||||
|
if(sumPayments != null)
|
||||||
|
fSumPayments.setValue(sumPayments);
|
||||||
|
|
||||||
bProcess.setEnabled(PaymentRule.equals("T"));
|
bProcess.setEnabled(PaymentRule.equals("T"));
|
||||||
|
|
||||||
if(documentNo != null)
|
if(documentNo != null)
|
||||||
|
@ -326,9 +349,45 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
|
||||||
|
|
||||||
if(msg != null && msg.length() > 0)
|
if(msg != null && msg.length() > 0)
|
||||||
FDialog.error(m_WindowNo, form, msg);
|
FDialog.error(m_WindowNo, form, msg);
|
||||||
|
|
||||||
|
getPluginFeatures();
|
||||||
} // loadPaymentRuleInfo
|
} // loadPaymentRuleInfo
|
||||||
|
|
||||||
|
|
||||||
|
protected void getPluginFeatures()
|
||||||
|
{
|
||||||
|
if (m_C_PaySelection_ID!=0)
|
||||||
|
{
|
||||||
|
if (loadPaymentExportClass (null)>=0)
|
||||||
|
{
|
||||||
|
bExport.setDisabled(false);
|
||||||
|
|
||||||
|
fDepositBatch.setValue(m_PaymentExport.getDefaultDepositBatch());
|
||||||
|
if (m_PaymentExport.supportsDepositBatch() && m_PaymentExport.supportsSeparateBooking())
|
||||||
|
{
|
||||||
|
fDepositBatch.setReadWrite(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fDepositBatch.setReadWrite(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bExport.setDisabled(true);
|
||||||
|
}
|
||||||
|
if (printFormatId!=null && printFormatId!=0)
|
||||||
|
{
|
||||||
|
bPrint.setEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bPrint.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // getPluginFeatures
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Export payments to file
|
* Export payments to file
|
||||||
*/
|
*/
|
||||||
|
@ -343,37 +402,28 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get File Info
|
|
||||||
File tempFile = File.createTempFile("paymentExport", ".txt");
|
|
||||||
|
|
||||||
// Create File
|
|
||||||
int no = 0;
|
int no = 0;
|
||||||
StringBuffer err = new StringBuffer("");
|
StringBuffer err = new StringBuffer("");
|
||||||
if (m_PaymentExportClass == null || m_PaymentExportClass.trim().length() == 0) {
|
if (m_PaymentExportClass == null || m_PaymentExportClass.trim().length() == 0) {
|
||||||
m_PaymentExportClass = "org.compiere.util.GenericPaymentExport";
|
m_PaymentExportClass = "org.compiere.util.GenericPaymentExport";
|
||||||
}
|
}
|
||||||
// Get Payment Export Class
|
|
||||||
PaymentExport custom = null;
|
File tempFile = null;
|
||||||
try
|
String filenameForDownload = "";
|
||||||
|
|
||||||
|
no = loadPaymentExportClass(err) ;
|
||||||
|
|
||||||
|
if (no >= 0)
|
||||||
{
|
{
|
||||||
Class<?> clazz = Class.forName(m_PaymentExportClass);
|
// Get File Info
|
||||||
custom = (PaymentExport)clazz.newInstance();
|
tempFile = File.createTempFile(m_PaymentExport.getFilenamePrefix(), m_PaymentExport.getFilenameSuffix());
|
||||||
no = custom.exportToFile(m_checks, tempFile, err);
|
filenameForDownload = m_PaymentExport.getFilenamePrefix() + m_PaymentExport.getFilenameSuffix();
|
||||||
}
|
|
||||||
catch (ClassNotFoundException e)
|
no = m_PaymentExport.exportToFile(m_checks,(Boolean) fDepositBatch.getValue(),PaymentRule, tempFile, err);
|
||||||
{
|
|
||||||
no = -1;
|
|
||||||
err.append("No custom PaymentExport class " + m_PaymentExportClass + " - " + e.toString());
|
|
||||||
log.log(Level.SEVERE, err.toString(), e);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
no = -1;
|
|
||||||
err.append("Error in " + m_PaymentExportClass + " check log, " + e.toString());
|
|
||||||
log.log(Level.SEVERE, err.toString(), e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (no >= 0) {
|
if (no >= 0) {
|
||||||
Filedownload.save(new FileInputStream(tempFile), "plain/text", "paymentExport.txt");
|
Filedownload.save(new FileInputStream(tempFile), m_PaymentExport.getContentType(), filenameForDownload);
|
||||||
FDialog.info(m_WindowNo, form, "Saved",
|
FDialog.info(m_WindowNo, form, "Saved",
|
||||||
Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no);
|
Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no);
|
||||||
|
|
||||||
|
@ -384,7 +434,7 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
|
||||||
{
|
{
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
MPaySelectionCheck.confirmPrint (m_checks, m_batch);
|
MPaySelectionCheck.confirmPrint (m_checks, m_batch, (Boolean) fDepositBatch.getValue());
|
||||||
// document No not updated
|
// document No not updated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
* *
|
* *
|
||||||
* Contributors: *
|
* Contributors: *
|
||||||
* Carlos Ruiz - GlobalQSS: *
|
* Carlos Ruiz - GlobalQSS: *
|
||||||
* FR 3132033 - Make payment export class configurable per bank *
|
* FR 3132033 - Make payment export class configurable per bank
|
||||||
|
* Markus Bozem: IDEMPIERE-1546 / IDEMPIERE-3286 *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.apps.form;
|
package org.compiere.apps.form;
|
||||||
|
|
||||||
|
@ -24,8 +25,11 @@ import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.base.IPaymentExporterFactory;
|
||||||
|
import org.adempiere.base.Service;
|
||||||
import org.compiere.model.MLookupFactory;
|
import org.compiere.model.MLookupFactory;
|
||||||
import org.compiere.model.MLookupInfo;
|
import org.compiere.model.MLookupInfo;
|
||||||
import org.compiere.model.MPaySelectionCheck;
|
import org.compiere.model.MPaySelectionCheck;
|
||||||
|
@ -34,6 +38,7 @@ import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Language;
|
import org.compiere.util.Language;
|
||||||
|
import org.compiere.util.PaymentExport;
|
||||||
import org.compiere.util.ValueNamePair;
|
import org.compiere.util.ValueNamePair;
|
||||||
|
|
||||||
public class PayPrint {
|
public class PayPrint {
|
||||||
|
@ -57,6 +62,7 @@ public class PayPrint {
|
||||||
public String bank;
|
public String bank;
|
||||||
public String currency;
|
public String currency;
|
||||||
public BigDecimal balance;
|
public BigDecimal balance;
|
||||||
|
protected PaymentExport m_PaymentExport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PaySelect changed - load Bank
|
* PaySelect changed - load Bank
|
||||||
|
@ -157,7 +163,8 @@ public class PayPrint {
|
||||||
|
|
||||||
public String noPayments;
|
public String noPayments;
|
||||||
public Integer documentNo;
|
public Integer documentNo;
|
||||||
|
public Double sumPayments;
|
||||||
|
public Integer printFormatId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PaymentRule changed - load DocumentNo, NoPayments,
|
* PaymentRule changed - load DocumentNo, NoPayments,
|
||||||
|
@ -167,19 +174,23 @@ public class PayPrint {
|
||||||
{
|
{
|
||||||
String msg = null;
|
String msg = null;
|
||||||
|
|
||||||
String sql = "SELECT COUNT(*) "
|
String sql = "SELECT COUNT(*),SUM(payamt) "
|
||||||
+ "FROM C_PaySelectionCheck "
|
+ "FROM C_PaySelectionCheck "
|
||||||
+ "WHERE C_PaySelection_ID=?";
|
+ "WHERE C_PaySelection_ID=? AND PaymentRule=?";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement(sql, null);
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
pstmt.setInt(1, C_PaySelection_ID);
|
pstmt.setInt(1, C_PaySelection_ID);
|
||||||
|
pstmt.setString(2, PaymentRule);
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
//
|
//
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
{
|
||||||
noPayments = String.valueOf(rs.getInt(1));
|
noPayments = String.valueOf(rs.getInt(1));
|
||||||
|
sumPayments = rs.getDouble(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
|
@ -192,8 +203,11 @@ public class PayPrint {
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printFormatId = null;
|
||||||
|
documentNo = null;
|
||||||
|
|
||||||
// DocumentNo
|
// DocumentNo
|
||||||
sql = "SELECT CurrentNext "
|
sql = "SELECT CurrentNext, Check_PrintFormat_ID "
|
||||||
+ "FROM C_BankAccountDoc "
|
+ "FROM C_BankAccountDoc "
|
||||||
+ "WHERE C_BankAccount_ID=? AND PaymentRule=? AND IsActive='Y'";
|
+ "WHERE C_BankAccount_ID=? AND PaymentRule=? AND IsActive='Y'";
|
||||||
try
|
try
|
||||||
|
@ -204,7 +218,10 @@ public class PayPrint {
|
||||||
rs = pstmt.executeQuery();
|
rs = pstmt.executeQuery();
|
||||||
//
|
//
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
|
{
|
||||||
documentNo = new Integer(rs.getInt(1));
|
documentNo = new Integer(rs.getInt(1));
|
||||||
|
printFormatId = new Integer(rs.getInt(2));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "VPayPrint.loadPaymentRuleInfo - No active BankAccountDoc for C_BankAccount_ID="
|
log.log(Level.SEVERE, "VPayPrint.loadPaymentRuleInfo - No active BankAccountDoc for C_BankAccount_ID="
|
||||||
|
@ -225,4 +242,50 @@ public class PayPrint {
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
} // loadPaymentRuleInfo
|
} // loadPaymentRuleInfo
|
||||||
|
|
||||||
|
protected int loadPaymentExportClass (StringBuffer err)
|
||||||
|
{
|
||||||
|
m_PaymentExport = null ;
|
||||||
|
|
||||||
|
if (m_PaymentExportClass == null || m_PaymentExportClass.trim().length() == 0) {
|
||||||
|
m_PaymentExportClass = "org.compiere.util.GenericPaymentExport";
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<IPaymentExporterFactory> factories = Service.locator().list(IPaymentExporterFactory.class).getServices();
|
||||||
|
if (factories != null && !factories.isEmpty()) {
|
||||||
|
for(IPaymentExporterFactory factory : factories) {
|
||||||
|
m_PaymentExport = factory.newPaymentExporterInstance(m_PaymentExportClass);
|
||||||
|
if (m_PaymentExport != null)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_PaymentExport == null)
|
||||||
|
{
|
||||||
|
Class<?> clazz = Class.forName (m_PaymentExportClass);
|
||||||
|
m_PaymentExport = (PaymentExport)clazz.newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException e)
|
||||||
|
{
|
||||||
|
if (err!=null)
|
||||||
|
{
|
||||||
|
err.append("No custom PaymentExport class " + m_PaymentExportClass + " - " + e.toString());
|
||||||
|
log.log(Level.SEVERE, err.toString(), e);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (err!=null)
|
||||||
|
{
|
||||||
|
err.append("Error in " + m_PaymentExportClass + " check log, " + e.toString());
|
||||||
|
log.log(Level.SEVERE, err.toString(), e);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0 ;
|
||||||
|
} // loadPaymentExportClass
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue